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 ) {
 
   74     INTREPID2_TEST_FOR_EXCEPTION( worksetCell.rank() != 3, std::invalid_argument,
 
   75                                   ">>> ERROR (Intrepid2::CellTools::setJacobian): rank = 3 required for worksetCell array." );
 
   80     INTREPID2_TEST_FOR_EXCEPTION( worksetCell.extent(2) != cellTopo.getDimension(), std::invalid_argument,
 
   81                                   ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (spatial dimension) of worksetCell array  does not match cell dimension." );
 
   85     const auto pointRank = points.rank();
 
   86     INTREPID2_TEST_FOR_EXCEPTION( pointRank != 2 &&
 
   87                                   pointRank != 3, std::invalid_argument,
 
   88                                   ">>> ERROR (Intrepid2::CellTools::setJacobian): points must have rank 2 or 3." );
 
   92       INTREPID2_TEST_FOR_EXCEPTION( points.extent(1) != cellTopo.getDimension(), std::invalid_argument,
 
   93                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 1 (spatial dimension) of points array does not match cell dimension." );
 
   95       INTREPID2_TEST_FOR_EXCEPTION( jacobian.rank() != 4, std::invalid_argument, 
 
   96                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): rank = 4 required for jacobian array." );
 
   98       INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(0) != worksetCell.extent(0), std::invalid_argument,
 
   99                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 0 (number of cells) of jacobian array must equal dim 0 of worksetCell array." );
 
  101       INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(1) != points.extent(0), std::invalid_argument,
 
  102                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 1 (number of points) of jacobian array must equal dim 0 of points array." );
 
  104       INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != points.extent(1), std::invalid_argument,
 
  105                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (spatial dimension) of jacobian array must equal dim 1 of points array." );
 
  107       INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != jacobian.extent(3), std::invalid_argument,
 
  108                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 = dim 3 (same spatial dimensions) required for jacobian array." );
 
  110       INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(3) < 1 || jacobian.extent(3) > 3, std::invalid_argument,
 
  111                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 and dim 3 (spatial dimensions) must be between 1 and 3." );
 
  115       INTREPID2_TEST_FOR_EXCEPTION( points.extent(0) != worksetCell.extent(0), std::invalid_argument,
 
  116                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 0 (number of cells) of points array must equal dim 0 of cellWorkset array");
 
  118       INTREPID2_TEST_FOR_EXCEPTION( points.extent(2) != cellTopo.getDimension(), std::invalid_argument,
 
  119                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (spatial dimension) of points array does not match cell dimension");
 
  122       INTREPID2_TEST_FOR_EXCEPTION( jacobian.rank() != 4, std::invalid_argument,
 
  123                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): rank = 4 required for jacobian array." );                                    
 
  125       INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(0) != points.extent(0), std::invalid_argument,
 
  126                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 0 (number of cells) of jacobian array must equal dim 0 of points array");
 
  128       INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(1) != points.extent(1), std::invalid_argument,
 
  129                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 1 (number of points) of jacobian array must equal dim 1 of points array");
 
  131       INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != points.extent(2), std::invalid_argument,
 
  132                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 (spatial dimension) of jacobian array must equal dim 2 of points array");
 
  134       INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(2) != jacobian.extent(3), std::invalid_argument,
 
  135                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 = dim 3 (same spatial dimensions) required for jacobian array. ");
 
  137       INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(3) < 1 || jacobian.extent(3) > 3, std::invalid_argument,
 
  138                                     ">>> ERROR (Intrepid2::CellTools::setJacobian): dim 2 and dim 3 (spatial dimensions) must be between 1 and 3." );
 
  144   template<
typename jacobianInvViewType, 
 
  145            typename jacobianViewType>
 
  147   CellTools_setJacobianInvArgs( 
const jacobianInvViewType jacobianInv,
 
  148                                 const jacobianViewType    jacobian ) {
 
  151     const ordinal_type jacoRank = jacobian.rank();
 
  152     INTREPID2_TEST_FOR_EXCEPTION( jacoRank != 4 && 
 
  153                                   jacoRank != 3, std::invalid_argument,
 
  154                                   ">>> ERROR (Intrepid2::CellTools::setJacobianInv): rank = 4 or 3 required for jacobian array." );
 
  157     INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) != jacobian.extent(jacoRank - 2), std::invalid_argument,
 
  158                                   ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-2) = dim(rank-2) (same spatial dimensions) required for jacobian array." );
 
  160     INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) < 1 || 
 
  161                                   jacobian.extent(jacoRank - 1) > 3, std::invalid_argument,
 
  162                                   ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-1) and dim(rank-2) (spatial dimensions) must be between 1 and 3." );
 
  165     const ordinal_type jacoInvRank = jacobianInv.rank();
 
  166     INTREPID2_TEST_FOR_EXCEPTION( jacoInvRank != jacoRank, std::invalid_argument, 
 
  167                                   ">>> ERROR (Intrepid2::CellTools::setJacobianInv): jacobian rank does not match to jacobianInv." );
 
  169     for (ordinal_type i=0;i<jacoRank;++i) {
 
  170       INTREPID2_TEST_FOR_EXCEPTION( jacobianInv.extent(i) != jacobian.extent(i), std::invalid_argument,
 
  171                                     ">>> ERROR (Intrepid2::CellTools::setJacobianInv): jacobian dimension (i) does not match to jacobianInv dimension (i)." );
 
  176   template<
typename jacobianDetViewType, 
 
  177            typename jacobianViewType>
 
  179   CellTools_setJacobianDetArgs( 
const jacobianDetViewType jacobianDet,
 
  180                                 const jacobianViewType    jacobian ) {
 
  183     const ordinal_type jacoRank = jacobian.rank();
 
  184     INTREPID2_TEST_FOR_EXCEPTION( jacoRank != 4 &&
 
  185                                   jacoRank != 3, std::invalid_argument,
 
  186                                   ">>> ERROR (Intrepid2::CellTools::setJacobianInv): rank = 4 or 3 required for jacobian array." );
 
  189     INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) != jacobian.extent(jacoRank - 2), std::invalid_argument,
 
  190                                   ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-2) = dim(rank-2) (same spatial dimensions) required for jacobian array." );
 
  192     INTREPID2_TEST_FOR_EXCEPTION( jacobian.extent(jacoRank - 1) < 1 || 
 
  193                                   jacobian.extent(jacoRank - 1) > 3, std::invalid_argument,
 
  194                                   ">>> ERROR (Intrepid2::CellTools::setJacobianInv): dim(rank-1) and dim(rank-2) (spatial dimensions) must be between 1 and 3." );
 
  197     const ordinal_type jacoDetRank = jacobianDet.rank();
 
  200     INTREPID2_TEST_FOR_EXCEPTION( jacoDetRank != (jacoRank-2), std::invalid_argument,
 
  201                                   ">>> ERROR (Intrepid2::CellTools::setJacobianDetArgs): rank = 2 required for jacobianDet if jacobian is rank-4." );
 
  203     for (ordinal_type i=0;i<jacoDetRank;++i) {
 
  204       INTREPID2_TEST_FOR_EXCEPTION( jacobianDet.extent(i) != jacobian.extent(i), std::invalid_argument,
 
  205                                     ">>> ERROR (Intrepid2::CellTools::setJacobianDetArgs): jacobianDet dimension (i) does not match to jacobian dimension (i)." );
 
  211   template<
typename physPointViewType,
 
  212            typename refPointViewType,
 
  213            typename worksetCellViewType>
 
  215   CellTools_mapToPhysicalFrameArgs( 
const physPointViewType    physPoints,
 
  216                                     const refPointViewType     refPoints,
 
  217                                     const worksetCellViewType  worksetCell,
 
  218                                     const shards::CellTopology cellTopo ) {
 
  220     INTREPID2_TEST_FOR_EXCEPTION( worksetCell.rank() != 3, std::invalid_argument,
 
  221                                   ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): rank = 3 required for worksetCell array." );
 
  227     INTREPID2_TEST_FOR_EXCEPTION( worksetCell.extent(2) != cellTopo.getDimension(), std::invalid_argument,
 
  228                                   ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 2 (spatial dimension) of worksetCell array  does not match cell dimension." );
 
  232     const ordinal_type refPointRank = refPoints.rank();
 
  233     const ordinal_type physPointRank = physPoints.rank();
 
  235     INTREPID2_TEST_FOR_EXCEPTION( refPointRank != 2 &&
 
  236                                   refPointRank != 3, std::invalid_argument,
 
  237                                   ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): refPoints requires rank 2 or 3." );
 
  239     switch (refPointRank) {
 
  242       INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(1) != cellTopo.getDimension(), std::invalid_argument,
 
  243                                     ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 1 (spatial dimension) of refPoints array does not match cell dimension." );
 
  245       INTREPID2_TEST_FOR_EXCEPTION( physPoints.rank() != 3, std::invalid_argument,
 
  246                                     ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): rank = 3 required for physPoints array for the default whichCell value." );
 
  248       INTREPID2_TEST_FOR_EXCEPTION( physPoints.extent(0) != worksetCell.extent(0), std::invalid_argument,
 
  249                                     ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 0 (number of cells) of physPoints array must equal dim 0 of worksetCell array." );
 
  251       INTREPID2_TEST_FOR_EXCEPTION( physPoints.extent(1) != refPoints.extent(0), std::invalid_argument,
 
  252                                     ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 1 (number of points) of physPoints array must equal dim 0 of refPoints array." ); 
 
  254       INTREPID2_TEST_FOR_EXCEPTION( physPoints.extent(2) != cellTopo.getDimension(), std::invalid_argument,
 
  255                                     ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 2 (spatial dimension) does not match cell dimension." );  
 
  261       INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(0) != worksetCell.extent(0), std::invalid_argument,
 
  262                                     ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 0 (number of cells) of refPoints and worksetCell arraya are required to match." );
 
  264       INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(2) != cellTopo.getDimension(), std::invalid_argument,
 
  265                                     ">>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): dim 2 (spatial dimension) of refPoints array does not match cell dimension." );
 
  268       INTREPID2_TEST_FOR_EXCEPTION( refPointRank != physPointRank, std::invalid_argument, 
 
  269                                     " >>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): refPoints rank does not match to physPoints rank." );
 
  271       for (ordinal_type i=0;i<refPointRank;++i) {
 
  272         INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(i) != physPoints.extent(i), std::invalid_argument, 
 
  273                                       " >>> ERROR (Intrepid2::CellTools::mapToPhysicalFrame): refPoints dimension(i) does not match to physPoints dimension(i)." );
 
  280   template<
typename refPointViewType, 
 
  281            typename physPointViewType,
 
  282            typename worksetCellViewType>
 
  284   CellTools_mapToReferenceFrameArgs( 
const refPointViewType     refPoints,
 
  285                                      const physPointViewType    physPoints,
 
  286                                      const worksetCellViewType  worksetCell,
 
  287                                      const shards::CellTopology cellTopo ) {
 
  289     const ordinal_type worksetCellRank = worksetCell.rank();
 
  290     INTREPID2_TEST_FOR_EXCEPTION( worksetCellRank != 3, std::invalid_argument,
 
  291                                   ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): rank = 3 required for worksetCell array" );
 
  296     INTREPID2_TEST_FOR_EXCEPTION( worksetCell.extent(2) != cellTopo.getDimension(), std::invalid_argument,
 
  297                                   ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): dim 2 (spatial dimension) of worksetCell array  does not match cell dimension" );
 
  302     const ordinal_type physPointRank = physPoints.rank();
 
  303     const ordinal_type refPointRank = refPoints.rank();
 
  305     INTREPID2_TEST_FOR_EXCEPTION( refPointRank != 2 &&
 
  306                                   refPointRank != 3, std::invalid_argument, 
 
  307                                   ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): refPoint must have rank 2 or 3." );
 
  309     INTREPID2_TEST_FOR_EXCEPTION( physPointRank != refPointRank, std::invalid_argument, 
 
  310                                   ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): physPoints rank does not match refPoints rank." );
 
  311     for (ordinal_type i=0;i<refPointRank;++i) {
 
  312       INTREPID2_TEST_FOR_EXCEPTION( refPoints.extent(i) != physPoints.extent(i), std::invalid_argument, 
 
  313                                     ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): physPoints dimension (i) does not match refPoints dimension (i)." );
 
  317   template<
typename refPointViewType, 
 
  318            typename initGuessViewType,
 
  319            typename physPointViewType,
 
  320            typename worksetCellViewType>
 
  321   void CellTools_mapToReferenceFrameInitGuessArgs( 
const refPointViewType     refPoints,
 
  322                                                    const initGuessViewType    initGuess,
 
  323                                                    const physPointViewType    physPoints,
 
  324                                                    const worksetCellViewType  worksetCell,
 
  325                                                    const shards::CellTopology cellTopo ) {
 
  327     CellTools_mapToReferenceFrameArgs(refPoints, physPoints, worksetCell, cellTopo);
 
  330     INTREPID2_TEST_FOR_EXCEPTION( initGuess.rank() != physPoints.rank(), std::invalid_argument, 
 
  331                                   ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): InitGuess must have the same rank as physPoints");         
 
  333     const ordinal_type r = initGuess.rank();
 
  334     for (ordinal_type i=0;i<r;++i) {
 
  335       INTREPID2_TEST_FOR_EXCEPTION( initGuess.extent(i) != physPoints.extent(i), std::invalid_argument, 
 
  336                                     ">>> ERROR (Intrepid2::CellTools::mapToReferenceFrame): InitGuess dimension (i) does not match ot physPoints dimension(i).");