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." );
51 const auto pointRank = points.rank();
52 INTREPID2_TEST_FOR_EXCEPTION( pointRank != 2 &&
53 pointRank != 3, std::invalid_argument,
54 ">>> ERROR (Intrepid2::CellTools::setJacobian): points must have rank 2 or 3." );
56 const int endCellResolved = (endCell == -1) ? worksetCell.extent_int(0) : endCell;
57 const int numCells = endCellResolved - startCell;
59 INTREPID2_TEST_FOR_EXCEPTION(startCell < 0, std::invalid_argument,
"Invalid startCell");
60 INTREPID2_TEST_FOR_EXCEPTION(startCell >= worksetCell.extent_int(0), std::invalid_argument,
"startCell is out of bounds in workset.");
61 INTREPID2_TEST_FOR_EXCEPTION(endCellResolved > worksetCell.extent_int(0), std::invalid_argument,
"resolved endCell is out of bounds in workset.");
66 INTREPID2_TEST_FOR_EXCEPTION( jacobian.rank() != 4, std::invalid_argument,
67 ">>> ERROR (Intrepid2::CellTools::setJacobian): rank = 4 required for jacobian array." );
69 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent_int(0) != numCells, std::invalid_argument,
70 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 0 (number of cells) of jacobian array must equal number of cells requested from in the workset." );
72 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(1) != points.extent(0), std::invalid_argument,
73 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 1 (number of points) of jacobian array must equal dim 0 of points array." );
75 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != worksetCell.extent(2), std::invalid_argument,
76 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (range dimension) of jacobian array must equal dim 2 of worksetCell (phys points) array");
78 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(3) != points.extent(1), std::invalid_argument,
79 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 3 (domain dimension) of Jacobian array must equal dim 1 (spatial dimension) of points array. " );
81 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(3) < 1 || jacobian.extent(3) > 3, std::invalid_argument,
82 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 and dim 3 (spatial dimensions) must be between 1 and 3." );
86 INTREPID2_TEST_FOR_EXCEPTION( points.extent_int(0) != numCells, std::invalid_argument,
87 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 0 (number of cells) of points array must equal number of cells requested from in the workset.");
91 INTREPID2_TEST_FOR_EXCEPTION( jacobian.rank() != 4, std::invalid_argument,
92 ">>> ERROR (Intrepid2::CellTools::setJacobian): rank = 4 required for jacobian array." );
94 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(0) != points.extent(0), std::invalid_argument,
95 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 0 (number of cells) of jacobian array must equal dim 0 of points array");
97 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(1) != points.extent(1), std::invalid_argument,
98 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 1 (number of points) of jacobian array must equal dim 1 of points array");
100 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != worksetCell.extent(2), std::invalid_argument,
101 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (range dimension) of jacobian array must equal dim 2 of worksetCell (phys points) array");
103 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(3) != points.extent(2), std::invalid_argument,
104 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 3 (domain dimension) of Jacobian array must equal dim 2 (spatial dimension) of points array. ");
106 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(3) < 1 || jacobian.extent(3) > 3, std::invalid_argument,
107 ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 and dim 3 (spatial dimensions) must be between 1 and 3." );
113 template<
typename jacobianInvViewType,
114 typename jacobianViewType>
117 const jacobianViewType jacobian ) {
120 const ordinal_type jacoRank = jacobian.rank();
121 INTREPID2_TEST_FOR_EXCEPTION( jacoRank != 4 &&
122 jacoRank != 3, std::invalid_argument,
123 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): rank = 4 or 3 required for jacobian array." );
126 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) != jacobian.extent(jacoRank - 2), std::invalid_argument,
127 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-2) = dim(rank-2) (same spatial dimensions) required for jacobian array." );
129 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) < 1 ||
130 jacobian.extent(jacoRank - 1) > 3, std::invalid_argument,
131 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-1) and dim(rank-2) (spatial dimensions) must be between 1 and 3." );
134 const ordinal_type jacoInvRank = jacobianInv.rank();
135 INTREPID2_TEST_FOR_EXCEPTION( jacoInvRank != jacoRank, std::invalid_argument,
136 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): jacobian rank does not match to jacobianInv." );
138 for (ordinal_type i=0;i<jacoRank;++i) {
139 INTREPID2_TEST_FOR_EXCEPTION( jacobianInv.extent(i) != jacobian.extent(i), std::invalid_argument,
140 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): jacobian dimension (i) does not match to jacobianInv dimension (i)." );
145 template<
typename jacobianDetViewType,
146 typename jacobianViewType>
149 const jacobianViewType jacobian ) {
152 const ordinal_type jacoRank = jacobian.rank();
153 INTREPID2_TEST_FOR_EXCEPTION( jacoRank != 4 &&
154 jacoRank != 3, std::invalid_argument,
155 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): rank = 4 or 3 required for jacobian array." );
158 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) != jacobian.extent(jacoRank - 2), std::invalid_argument,
159 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-2) = dim(rank-2) (same spatial dimensions) required for jacobian array." );
161 INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) < 1 ||
162 jacobian.extent(jacoRank - 1) > 3, std::invalid_argument,
163 ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-1) and dim(rank-2) (spatial dimensions) must be between 1 and 3." );
166 const ordinal_type jacoDetRank = jacobianDet.rank();
169 INTREPID2_TEST_FOR_EXCEPTION( jacoDetRank != (jacoRank-2), std::invalid_argument,
170 ">>> ERROR (Intrepid2::CellTools::setJacobianDetArgs): rank = 2 required for jacobianDet if jacobian is rank-4." );
172 for (ordinal_type i=0;i<jacoDetRank;++i) {
173 INTREPID2_TEST_FOR_EXCEPTION( jacobianDet.extent(i) != jacobian.extent(i), std::invalid_argument,
174 ">>> ERROR (Intrepid2::CellTools::setJacobianDetArgs): jacobianDet dimension (i) does not match to jacobian dimension (i)." );
180 template<
typename physPointViewType,
181 typename refPointViewType,
182 typename worksetCellViewType>
185 const refPointViewType refPoints,
186 const worksetCellViewType worksetCell,
187 const shards::CellTopology cellTopo ) {
189 INTREPID2_TEST_FOR_EXCEPTION( (worksetCell.rank() != 3) || (physPoints.rank() != 3), std::invalid_argument,
190 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): rank = 3 required for worksetCell and physPoints arrays." );
197 INTREPID2_TEST_FOR_EXCEPTION( worksetCell.extent(2) < cellTopo.getDimension(), std::invalid_argument,
198 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 2 (spatial dimension) of worksetCell array is smaller than the cell dimension." );
200 INTREPID2_TEST_FOR_EXCEPTION( physPoints.extent(2) != worksetCell.extent(2), std::invalid_argument,
201 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): physPoints and worksetCell should have the same spatial dimension." );
205 const ordinal_type refPointRank = refPoints.rank();
206 const ordinal_type physPointRank = physPoints.rank();
208 INTREPID2_TEST_FOR_EXCEPTION( refPointRank != 2 &&
209 refPointRank != 3, std::invalid_argument,
210 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): refPoints requires rank 2 or 3." );
212 switch (refPointRank) {
215 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(1) != cellTopo.getDimension(), std::invalid_argument,
216 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 1 (spatial dimension) of refPoints array does not match cell dimension." );
218 INTREPID2_TEST_FOR_EXCEPTION( physPoints.rank() != 3, std::invalid_argument,
219 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): rank = 3 required for physPoints array for the default whichCell value." );
221 INTREPID2_TEST_FOR_EXCEPTION( cellTopo.getDimension() > worksetCell.extent(2), std::invalid_argument,
222 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): reference dimension cannot exceed physical dimension." );
224 INTREPID2_TEST_FOR_EXCEPTION( physPoints.extent(0) != worksetCell.extent(0), std::invalid_argument,
225 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 0 (number of cells) of physPoints array must equal dim 0 of worksetCell array." );
227 INTREPID2_TEST_FOR_EXCEPTION( physPoints.extent(1) != refPoints.extent(0), std::invalid_argument,
228 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 1 (number of points) of physPoints array must equal dim 0 of refPoints array." );
236 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(0) != worksetCell.extent(0), std::invalid_argument,
237 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 0 (number of cells) of refPoints and worksetCell arraya are required to match." );
239 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(2) != cellTopo.getDimension(), std::invalid_argument,
240 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 2 (spatial dimension) of refPoints array does not match cell dimension." );
242 INTREPID2_TEST_FOR_EXCEPTION( cellTopo.getDimension() > worksetCell.extent(2), std::invalid_argument,
243 ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): reference dimension cannot exceed physical 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>
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" );
277 const ordinal_type physPointRank = physPoints.rank();
278 const ordinal_type refPointRank = refPoints.rank();
280 INTREPID2_TEST_FOR_EXCEPTION( refPointRank != 3, std::invalid_argument,
281 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): refPoint must have rank 3." );
283 INTREPID2_TEST_FOR_EXCEPTION( physPointRank != 3, std::invalid_argument,
284 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): physPoints must have rank 3." );
285 for (ordinal_type i=0;i<refPointRank-1;++i) {
286 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(i) != physPoints.extent(i), std::invalid_argument,
287 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): physPoints dimension (i) does not match refPoints dimension (i)." );
290 const ordinal_type physDim = worksetCell.extent_int(2);
292 INTREPID2_TEST_FOR_EXCEPTION( physPoints.extent_int(2) != physDim, std::invalid_argument,
293 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): "
294 "physPoints.extent(2) must match worksetCell.extent(2)." );
296 INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(2) != cellTopo.getDimension(), std::invalid_argument,
297 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): "
298 "refPoints.extent(2) must match the expected reference output dimension for cellTopo." );
302 template<
typename refPointViewType,
303 typename initGuessViewType,
304 typename physPointViewType,
305 typename worksetCellViewType>
306 void CellTools_mapToReferenceFrameInitGuessArgs(
const refPointViewType refPoints,
307 const initGuessViewType initGuess,
308 const physPointViewType physPoints,
309 const worksetCellViewType worksetCell,
310 const shards::CellTopology cellTopo ) {
312 CellTools_mapToReferenceFrameArgs(refPoints, physPoints, worksetCell, cellTopo);
315 INTREPID2_TEST_FOR_EXCEPTION( initGuess.rank() != refPoints.rank(), std::invalid_argument,
316 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrameInitGuess): InitGuess must have the same rank as refPoints");
318 const ordinal_type r = initGuess.rank();
319 for (ordinal_type i=0;i<r;++i) {
320 INTREPID2_TEST_FOR_EXCEPTION( initGuess.extent(i) != refPoints.extent(i), std::invalid_argument,
321 ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrameInitGuess): InitGuess dimension (i) does not match ot refPoints dimension(i).");