49 #ifndef __INTREPID2_CELLTOOLS_DEF_VALIDATE_ARGUMENTS_HPP__
50 #define __INTREPID2_CELLTOOLS_DEF_VALIDATE_ARGUMENTS_HPP__
53 #if defined (__clang__) && !defined (__INTEL_COMPILER)
54 #pragma clang system_header
65 template<
typename jacobianViewType,
66 typename PointViewType,
67 typename worksetCellViewType>
69 CellTools_setJacobianArgs(
const jacobianViewType jacobian,
70 const PointViewType points,
71 const worksetCellViewType worksetCell,
72 const shards::CellTopology cellTopo,
73 const int startCell,
const int endCell) {
75 INTREPID2_TEST_FOR_EXCEPTION( worksetCell.rank() != 3, std::invalid_argument,
76 ">>> ERROR (Intrepid2::CellTools::setJacobian): rank = 3 required for worksetCell array." );
81 INTREPID2_TEST_FOR_EXCEPTION( worksetCell.extent(2) != cellTopo.getDimension(), std::invalid_argument,
82 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (spatial dimension) of worksetCell array does not match cell dimension." );
86 const auto pointRank = points.rank();
87 INTREPID2_TEST_FOR_EXCEPTION( pointRank != 2 &&
88 pointRank != 3, std::invalid_argument,
89 ">>> ERROR (Intrepid2::CellTools::setJacobian): points must have rank 2 or 3." );
91 const int endCellResolved = (endCell == -1) ? worksetCell.extent_int(0) : endCell;
92 const int numCells = endCellResolved - startCell;
94 INTREPID2_TEST_FOR_EXCEPTION(startCell < 0, std::invalid_argument,
"Invalid startCell");
95 INTREPID2_TEST_FOR_EXCEPTION(startCell >= worksetCell.extent_int(0), std::invalid_argument,
"startCell is out of bounds in workset.");
96 INTREPID2_TEST_FOR_EXCEPTION(endCellResolved > worksetCell.extent_int(0), std::invalid_argument,
"resolved endCell is out of bounds in workset.");
100 INTREPID2_TEST_FOR_EXCEPTION( points.extent(1) != cellTopo.getDimension(), std::invalid_argument,
101 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 1 (spatial dimension) of points array does not match cell dimension." );
103 INTREPID2_TEST_FOR_EXCEPTION( jacobian.rank() != 4, std::invalid_argument,
104 ">>> ERROR (Intrepid2::CellTools::setJacobian): rank = 4 required for jacobian array." );
106 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent_int(0) != numCells, std::invalid_argument,
107 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 0 (number of cells) of jacobian array must equal number of cells requested from in the workset." );
109 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(1) != points.extent(0), std::invalid_argument,
110 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 1 (number of points) of jacobian array must equal dim 0 of points array." );
112 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != points.extent(1), std::invalid_argument,
113 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (spatial dimension) of jacobian array must equal dim 1 of points array." );
115 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != jacobian.extent(3), std::invalid_argument,
116 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 = dim 3 (same spatial dimensions) required for jacobian array." );
118 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(3) < 1 || jacobian.extent(3) > 3, std::invalid_argument,
119 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 and dim 3 (spatial dimensions) must be between 1 and 3." );
123 INTREPID2_TEST_FOR_EXCEPTION( points.extent_int(0) != numCells, std::invalid_argument,
124 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 0 (number of cells) of points array must equal number of cells requested from in the workset.");
126 INTREPID2_TEST_FOR_EXCEPTION( points.extent(2) != cellTopo.getDimension(), std::invalid_argument,
127 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (spatial dimension) of points array does not match cell dimension");
130 INTREPID2_TEST_FOR_EXCEPTION( jacobian.rank() != 4, std::invalid_argument,
131 ">>> ERROR (Intrepid2::CellTools::setJacobian): rank = 4 required for jacobian array." );
133 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(0) != points.extent(0), std::invalid_argument,
134 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 0 (number of cells) of jacobian array must equal dim 0 of points array");
136 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(1) != points.extent(1), std::invalid_argument,
137 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 1 (number of points) of jacobian array must equal dim 1 of points array");
139 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != points.extent(2), std::invalid_argument,
140 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (spatial dimension) of jacobian array must equal dim 2 of points array");
142 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != jacobian.extent(3), std::invalid_argument,
143 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 = dim 3 (same spatial dimensions) required for jacobian array. ");
145 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(3) < 1 || jacobian.extent(3) > 3, std::invalid_argument,
146 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 and dim 3 (spatial dimensions) must be between 1 and 3." );
152 template<
typename jacobianInvViewType,
153 typename jacobianViewType>
155 CellTools_setJacobianInvArgs(
const jacobianInvViewType jacobianInv,
156 const jacobianViewType jacobian ) {
159 const ordinal_type jacoRank = jacobian.rank();
160 INTREPID2_TEST_FOR_EXCEPTION( jacoRank != 4 &&
161 jacoRank != 3, std::invalid_argument,
162 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): rank = 4 or 3 required for jacobian array." );
165 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) != jacobian.extent(jacoRank - 2), std::invalid_argument,
166 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-2) = dim(rank-2) (same spatial dimensions) required for jacobian array." );
168 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) < 1 ||
169 jacobian.extent(jacoRank - 1) > 3, std::invalid_argument,
170 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-1) and dim(rank-2) (spatial dimensions) must be between 1 and 3." );
173 const ordinal_type jacoInvRank = jacobianInv.rank();
174 INTREPID2_TEST_FOR_EXCEPTION( jacoInvRank != jacoRank, std::invalid_argument,
175 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): jacobian rank does not match to jacobianInv." );
177 for (ordinal_type i=0;i<jacoRank;++i) {
178 INTREPID2_TEST_FOR_EXCEPTION( jacobianInv.extent(i) != jacobian.extent(i), std::invalid_argument,
179 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): jacobian dimension (i) does not match to jacobianInv dimension (i)." );
184 template<
typename jacobianDetViewType,
185 typename jacobianViewType>
187 CellTools_setJacobianDetArgs(
const jacobianDetViewType jacobianDet,
188 const jacobianViewType jacobian ) {
191 const ordinal_type jacoRank = jacobian.rank();
192 INTREPID2_TEST_FOR_EXCEPTION( jacoRank != 4 &&
193 jacoRank != 3, std::invalid_argument,
194 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): rank = 4 or 3 required for jacobian array." );
197 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) != jacobian.extent(jacoRank - 2), std::invalid_argument,
198 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-2) = dim(rank-2) (same spatial dimensions) required for jacobian array." );
200 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) < 1 ||
201 jacobian.extent(jacoRank - 1) > 3, std::invalid_argument,
202 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-1) and dim(rank-2) (spatial dimensions) must be between 1 and 3." );
205 const ordinal_type jacoDetRank = jacobianDet.rank();
208 INTREPID2_TEST_FOR_EXCEPTION( jacoDetRank != (jacoRank-2), std::invalid_argument,
209 ">>> ERROR (Intrepid2::CellTools::setJacobianDetArgs): rank = 2 required for jacobianDet if jacobian is rank-4." );
211 for (ordinal_type i=0;i<jacoDetRank;++i) {
212 INTREPID2_TEST_FOR_EXCEPTION( jacobianDet.extent(i) != jacobian.extent(i), std::invalid_argument,
213 ">>> ERROR (Intrepid2::CellTools::setJacobianDetArgs): jacobianDet dimension (i) does not match to jacobian dimension (i)." );
219 template<
typename physPointViewType,
220 typename refPointViewType,
221 typename worksetCellViewType>
223 CellTools_mapToPhysicalFrameArgs(
const physPointViewType physPoints,
224 const refPointViewType refPoints,
225 const worksetCellViewType worksetCell,
226 const shards::CellTopology cellTopo ) {
228 INTREPID2_TEST_FOR_EXCEPTION( (worksetCell.rank() != 3) || (physPoints.rank() != 3), std::invalid_argument,
229 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): rank = 3 required for worksetCell and physPoints arrays." );
236 INTREPID2_TEST_FOR_EXCEPTION( worksetCell.extent(2) < cellTopo.getDimension(), std::invalid_argument,
237 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 2 (spatial dimension) of worksetCell array is smaller than the cell dimension." );
239 INTREPID2_TEST_FOR_EXCEPTION( physPoints.extent(2) != worksetCell.extent(2), std::invalid_argument,
240 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): physPoints and worksetCell should have the same spatial dimension." );
244 const ordinal_type refPointRank = refPoints.rank();
245 const ordinal_type physPointRank = physPoints.rank();
247 INTREPID2_TEST_FOR_EXCEPTION( refPointRank != 2 &&
248 refPointRank != 3, std::invalid_argument,
249 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): refPoints requires rank 2 or 3." );
251 switch (refPointRank) {
254 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(1) != cellTopo.getDimension(), std::invalid_argument,
255 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 1 (spatial dimension) of refPoints array does not match cell dimension." );
257 INTREPID2_TEST_FOR_EXCEPTION( physPoints.rank() != 3, std::invalid_argument,
258 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): rank = 3 required for physPoints array for the default whichCell value." );
260 INTREPID2_TEST_FOR_EXCEPTION( physPoints.extent(0) != worksetCell.extent(0), std::invalid_argument,
261 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 0 (number of cells) of physPoints array must equal dim 0 of worksetCell array." );
263 INTREPID2_TEST_FOR_EXCEPTION( physPoints.extent(1) != refPoints.extent(0), std::invalid_argument,
264 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 1 (number of points) of physPoints array must equal dim 0 of refPoints array." );
272 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(0) != worksetCell.extent(0), std::invalid_argument,
273 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 0 (number of cells) of refPoints and worksetCell arraya are required to match." );
275 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(2) != cellTopo.getDimension(), std::invalid_argument,
276 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 2 (spatial dimension) of refPoints array does not match cell dimension." );
279 INTREPID2_TEST_FOR_EXCEPTION( refPointRank != physPointRank, std::invalid_argument,
280 " >>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): refPoints rank does not match to physPoints rank." );
282 for (ordinal_type i=0;i<refPointRank-1;++i) {
283 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(i) != physPoints.extent(i), std::invalid_argument,
284 " >>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): refPoints dimension(i) does not match to physPoints dimension(i)." );
291 template<
typename refPointViewType,
292 typename physPointViewType,
293 typename worksetCellViewType>
295 CellTools_mapToReferenceFrameArgs(
const refPointViewType refPoints,
296 const physPointViewType physPoints,
297 const worksetCellViewType worksetCell,
298 const shards::CellTopology cellTopo ) {
300 const ordinal_type worksetCellRank = worksetCell.rank();
301 INTREPID2_TEST_FOR_EXCEPTION( worksetCellRank != 3, std::invalid_argument,
302 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): rank = 3 required for worksetCell array" );
307 INTREPID2_TEST_FOR_EXCEPTION( worksetCell.extent(2) != cellTopo.getDimension(), std::invalid_argument,
308 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): dim 2 (spatial dimension) of worksetCell array does not match cell dimension" );
313 const ordinal_type physPointRank = physPoints.rank();
314 const ordinal_type refPointRank = refPoints.rank();
316 INTREPID2_TEST_FOR_EXCEPTION( refPointRank != 2 &&
317 refPointRank != 3, std::invalid_argument,
318 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): refPoint must have rank 2 or 3." );
320 INTREPID2_TEST_FOR_EXCEPTION( physPointRank != refPointRank, std::invalid_argument,
321 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): physPoints rank does not match refPoints rank." );
322 for (ordinal_type i=0;i<refPointRank;++i) {
323 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(i) != physPoints.extent(i), std::invalid_argument,
324 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): physPoints dimension (i) does not match refPoints dimension (i)." );
328 template<
typename refPointViewType,
329 typename initGuessViewType,
330 typename physPointViewType,
331 typename worksetCellViewType>
332 void CellTools_mapToReferenceFrameInitGuessArgs(
const refPointViewType refPoints,
333 const initGuessViewType initGuess,
334 const physPointViewType physPoints,
335 const worksetCellViewType worksetCell,
336 const shards::CellTopology cellTopo ) {
338 CellTools_mapToReferenceFrameArgs(refPoints, physPoints, worksetCell, cellTopo);
341 INTREPID2_TEST_FOR_EXCEPTION( initGuess.rank() != physPoints.rank(), std::invalid_argument,
342 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): InitGuess must have the same rank as physPoints");
344 const ordinal_type r = initGuess.rank();
345 for (ordinal_type i=0;i<r;++i) {
346 INTREPID2_TEST_FOR_EXCEPTION( initGuess.extent(i) != physPoints.extent(i), std::invalid_argument,
347 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): InitGuess dimension (i) does not match ot physPoints dimension(i).");