16 #ifndef __INTREPID2_CELLTOOLS_DEF_VALIDATE_ARGUMENTS_HPP__
17 #define __INTREPID2_CELLTOOLS_DEF_VALIDATE_ARGUMENTS_HPP__
20 #if defined (__clang__) && !defined (__INTEL_COMPILER)
21 #pragma clang system_header
32 template<
typename jacobianViewType,
33 typename PointViewType,
34 typename worksetCellViewType>
36 CellTools_setJacobianArgs(
const jacobianViewType jacobian,
37 const PointViewType points,
38 const worksetCellViewType worksetCell,
39 const shards::CellTopology cellTopo,
40 const int startCell,
const int endCell) {
42 INTREPID2_TEST_FOR_EXCEPTION( worksetCell.rank() != 3, std::invalid_argument,
43 ">>> ERROR (Intrepid2::CellTools::setJacobian): rank = 3 required for worksetCell array." );
48 INTREPID2_TEST_FOR_EXCEPTION( worksetCell.extent(2) != cellTopo.getDimension(), std::invalid_argument,
49 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (spatial dimension) of worksetCell array does not match cell dimension." );
53 const auto pointRank = points.rank();
54 INTREPID2_TEST_FOR_EXCEPTION( pointRank != 2 &&
55 pointRank != 3, std::invalid_argument,
56 ">>> ERROR (Intrepid2::CellTools::setJacobian): points must have rank 2 or 3." );
58 const int endCellResolved = (endCell == -1) ? worksetCell.extent_int(0) : endCell;
59 const int numCells = endCellResolved - startCell;
61 INTREPID2_TEST_FOR_EXCEPTION(startCell < 0, std::invalid_argument,
"Invalid startCell");
62 INTREPID2_TEST_FOR_EXCEPTION(startCell >= worksetCell.extent_int(0), std::invalid_argument,
"startCell is out of bounds in workset.");
63 INTREPID2_TEST_FOR_EXCEPTION(endCellResolved > worksetCell.extent_int(0), std::invalid_argument,
"resolved endCell is out of bounds in workset.");
67 INTREPID2_TEST_FOR_EXCEPTION( points.extent(1) != cellTopo.getDimension(), std::invalid_argument,
68 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 1 (spatial dimension) of points array does not match cell dimension." );
70 INTREPID2_TEST_FOR_EXCEPTION( jacobian.rank() != 4, std::invalid_argument,
71 ">>> ERROR (Intrepid2::CellTools::setJacobian): rank = 4 required for jacobian array." );
73 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent_int(0) != numCells, std::invalid_argument,
74 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 0 (number of cells) of jacobian array must equal number of cells requested from in the workset." );
76 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(1) != points.extent(0), std::invalid_argument,
77 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 1 (number of points) of jacobian array must equal dim 0 of points array." );
79 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != points.extent(1), std::invalid_argument,
80 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (spatial dimension) of jacobian array must equal dim 1 of points array." );
82 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != jacobian.extent(3), std::invalid_argument,
83 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 = dim 3 (same spatial dimensions) required for jacobian array." );
85 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(3) < 1 || jacobian.extent(3) > 3, std::invalid_argument,
86 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 and dim 3 (spatial dimensions) must be between 1 and 3." );
90 INTREPID2_TEST_FOR_EXCEPTION( points.extent_int(0) != numCells, std::invalid_argument,
91 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 0 (number of cells) of points array must equal number of cells requested from in the workset.");
93 INTREPID2_TEST_FOR_EXCEPTION( points.extent(2) != cellTopo.getDimension(), std::invalid_argument,
94 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (spatial dimension) of points array does not match cell dimension");
97 INTREPID2_TEST_FOR_EXCEPTION( jacobian.rank() != 4, std::invalid_argument,
98 ">>> ERROR (Intrepid2::CellTools::setJacobian): rank = 4 required for jacobian array." );
100 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(0) != points.extent(0), std::invalid_argument,
101 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 0 (number of cells) of jacobian array must equal dim 0 of points array");
103 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(1) != points.extent(1), std::invalid_argument,
104 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 1 (number of points) of jacobian array must equal dim 1 of points array");
106 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != points.extent(2), std::invalid_argument,
107 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (spatial dimension) of jacobian array must equal dim 2 of points array");
109 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != jacobian.extent(3), std::invalid_argument,
110 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 = dim 3 (same spatial dimensions) required for jacobian array. ");
112 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(3) < 1 || jacobian.extent(3) > 3, std::invalid_argument,
113 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 and dim 3 (spatial dimensions) must be between 1 and 3." );
119 template<
typename jacobianInvViewType,
120 typename jacobianViewType>
122 CellTools_setJacobianInvArgs(
const jacobianInvViewType jacobianInv,
123 const jacobianViewType jacobian ) {
126 const ordinal_type jacoRank = jacobian.rank();
127 INTREPID2_TEST_FOR_EXCEPTION( jacoRank != 4 &&
128 jacoRank != 3, std::invalid_argument,
129 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): rank = 4 or 3 required for jacobian array." );
132 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) != jacobian.extent(jacoRank - 2), std::invalid_argument,
133 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-2) = dim(rank-2) (same spatial dimensions) required for jacobian array." );
135 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) < 1 ||
136 jacobian.extent(jacoRank - 1) > 3, std::invalid_argument,
137 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-1) and dim(rank-2) (spatial dimensions) must be between 1 and 3." );
140 const ordinal_type jacoInvRank = jacobianInv.rank();
141 INTREPID2_TEST_FOR_EXCEPTION( jacoInvRank != jacoRank, std::invalid_argument,
142 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): jacobian rank does not match to jacobianInv." );
144 for (ordinal_type i=0;i<jacoRank;++i) {
145 INTREPID2_TEST_FOR_EXCEPTION( jacobianInv.extent(i) != jacobian.extent(i), std::invalid_argument,
146 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): jacobian dimension (i) does not match to jacobianInv dimension (i)." );
151 template<
typename jacobianDetViewType,
152 typename jacobianViewType>
154 CellTools_setJacobianDetArgs(
const jacobianDetViewType jacobianDet,
155 const jacobianViewType jacobian ) {
158 const ordinal_type jacoRank = jacobian.rank();
159 INTREPID2_TEST_FOR_EXCEPTION( jacoRank != 4 &&
160 jacoRank != 3, std::invalid_argument,
161 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): rank = 4 or 3 required for jacobian array." );
164 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) != jacobian.extent(jacoRank - 2), std::invalid_argument,
165 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-2) = dim(rank-2) (same spatial dimensions) required for jacobian array." );
167 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) < 1 ||
168 jacobian.extent(jacoRank - 1) > 3, std::invalid_argument,
169 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-1) and dim(rank-2) (spatial dimensions) must be between 1 and 3." );
172 const ordinal_type jacoDetRank = jacobianDet.rank();
175 INTREPID2_TEST_FOR_EXCEPTION( jacoDetRank != (jacoRank-2), std::invalid_argument,
176 ">>> ERROR (Intrepid2::CellTools::setJacobianDetArgs): rank = 2 required for jacobianDet if jacobian is rank-4." );
178 for (ordinal_type i=0;i<jacoDetRank;++i) {
179 INTREPID2_TEST_FOR_EXCEPTION( jacobianDet.extent(i) != jacobian.extent(i), std::invalid_argument,
180 ">>> ERROR (Intrepid2::CellTools::setJacobianDetArgs): jacobianDet dimension (i) does not match to jacobian dimension (i)." );
186 template<
typename physPointViewType,
187 typename refPointViewType,
188 typename worksetCellViewType>
190 CellTools_mapToPhysicalFrameArgs(
const physPointViewType physPoints,
191 const refPointViewType refPoints,
192 const worksetCellViewType worksetCell,
193 const shards::CellTopology cellTopo ) {
195 INTREPID2_TEST_FOR_EXCEPTION( (worksetCell.rank() != 3) || (physPoints.rank() != 3), std::invalid_argument,
196 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): rank = 3 required for worksetCell and physPoints arrays." );
203 INTREPID2_TEST_FOR_EXCEPTION( worksetCell.extent(2) < cellTopo.getDimension(), std::invalid_argument,
204 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 2 (spatial dimension) of worksetCell array is smaller than the cell dimension." );
206 INTREPID2_TEST_FOR_EXCEPTION( physPoints.extent(2) != worksetCell.extent(2), std::invalid_argument,
207 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): physPoints and worksetCell should have the same spatial dimension." );
211 const ordinal_type refPointRank = refPoints.rank();
212 const ordinal_type physPointRank = physPoints.rank();
214 INTREPID2_TEST_FOR_EXCEPTION( refPointRank != 2 &&
215 refPointRank != 3, std::invalid_argument,
216 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): refPoints requires rank 2 or 3." );
218 switch (refPointRank) {
221 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(1) != cellTopo.getDimension(), std::invalid_argument,
222 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 1 (spatial dimension) of refPoints array does not match cell dimension." );
224 INTREPID2_TEST_FOR_EXCEPTION( physPoints.rank() != 3, std::invalid_argument,
225 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): rank = 3 required for physPoints array for the default whichCell value." );
227 INTREPID2_TEST_FOR_EXCEPTION( physPoints.extent(0) != worksetCell.extent(0), std::invalid_argument,
228 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 0 (number of cells) of physPoints array must equal dim 0 of worksetCell array." );
230 INTREPID2_TEST_FOR_EXCEPTION( physPoints.extent(1) != refPoints.extent(0), std::invalid_argument,
231 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 1 (number of points) of physPoints array must equal dim 0 of refPoints array." );
239 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(0) != worksetCell.extent(0), std::invalid_argument,
240 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 0 (number of cells) of refPoints and worksetCell arraya are required to match." );
242 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(2) != cellTopo.getDimension(), std::invalid_argument,
243 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 2 (spatial dimension) of refPoints array does not match cell dimension." );
246 INTREPID2_TEST_FOR_EXCEPTION( refPointRank != physPointRank, std::invalid_argument,
247 " >>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): refPoints rank does not match to physPoints rank." );
249 for (ordinal_type i=0;i<refPointRank-1;++i) {
250 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(i) != physPoints.extent(i), std::invalid_argument,
251 " >>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): refPoints dimension(i) does not match to physPoints dimension(i)." );
258 template<
typename refPointViewType,
259 typename physPointViewType,
260 typename worksetCellViewType>
262 CellTools_mapToReferenceFrameArgs(
const refPointViewType refPoints,
263 const physPointViewType physPoints,
264 const worksetCellViewType worksetCell,
265 const shards::CellTopology cellTopo ) {
267 const ordinal_type worksetCellRank = worksetCell.rank();
268 INTREPID2_TEST_FOR_EXCEPTION( worksetCellRank != 3, std::invalid_argument,
269 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): rank = 3 required for worksetCell array" );
274 INTREPID2_TEST_FOR_EXCEPTION( worksetCell.extent(2) != cellTopo.getDimension(), std::invalid_argument,
275 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): dim 2 (spatial dimension) of worksetCell array does not match cell dimension" );
280 const ordinal_type physPointRank = physPoints.rank();
281 const ordinal_type refPointRank = refPoints.rank();
283 INTREPID2_TEST_FOR_EXCEPTION( refPointRank != 2 &&
284 refPointRank != 3, std::invalid_argument,
285 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): refPoint must have rank 2 or 3." );
287 INTREPID2_TEST_FOR_EXCEPTION( physPointRank != refPointRank, std::invalid_argument,
288 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): physPoints rank does not match refPoints rank." );
289 for (ordinal_type i=0;i<refPointRank;++i) {
290 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(i) != physPoints.extent(i), std::invalid_argument,
291 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): physPoints dimension (i) does not match refPoints dimension (i)." );
295 template<
typename refPointViewType,
296 typename initGuessViewType,
297 typename physPointViewType,
298 typename worksetCellViewType>
299 void CellTools_mapToReferenceFrameInitGuessArgs(
const refPointViewType refPoints,
300 const initGuessViewType initGuess,
301 const physPointViewType physPoints,
302 const worksetCellViewType worksetCell,
303 const shards::CellTopology cellTopo ) {
305 CellTools_mapToReferenceFrameArgs(refPoints, physPoints, worksetCell, cellTopo);
308 INTREPID2_TEST_FOR_EXCEPTION( initGuess.rank() != physPoints.rank(), std::invalid_argument,
309 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): InitGuess must have the same rank as physPoints");
311 const ordinal_type r = initGuess.rank();
312 for (ordinal_type i=0;i<r;++i) {
313 INTREPID2_TEST_FOR_EXCEPTION( initGuess.extent(i) != physPoints.extent(i), std::invalid_argument,
314 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): InitGuess dimension (i) does not match ot physPoints dimension(i).");