48 #ifndef __INTREPID2_ORIENTATIONTOOLS_DEF_MATRIX_DATA_HPP__ 
   49 #define __INTREPID2_ORIENTATIONTOOLS_DEF_MATRIX_DATA_HPP__ 
   52 #if defined (__clang__) && !defined (__INTEL_COMPILER) 
   53 #pragma clang system_header 
   58   template<
typename SpT>
 
   59   template<
typename BasisType>
 
   60   typename OrientationTools<SpT>::CoeffMatrixDataViewType
 
   61   OrientationTools<SpT>::createCoeffMatrixInternal(
const BasisType* basis) {
 
   62     const ordinal_type order(basis->getDegree());
 
   63     const std::string name(basis->getName());
 
   64     CoeffMatrixDataViewType matData;
 
   66     using ExecutionSpace  = 
typename BasisType::ExecutionSpace;
 
   67     using OutputValueType = 
typename BasisType::OutputValueType;
 
   68     using PointValueType  = 
typename BasisType::PointValueType;
 
   70     using hostExecutionSpace = Kokkos::DefaultHostExecutionSpace;
 
   72     auto ordinalToTag = basis->getAllDofTags();
 
   73     auto tagToOrdinal = basis->getAllDofOrdinal();
 
   81     if((basis->getBaseCellTopology().getKey() == shards::getCellTopologyData<shards::Quadrilateral<4> >()->key)
 
   82       && (basis->getFunctionSpace() == FUNCTION_SPACE_HGRAD)) {
 
   84         const ordinal_type matDim = ordinalToTag(tagToOrdinal(1, 0, 0), 3), numEdges = 4, numOrts = 2;
 
   85         matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::"+name,
 
   91         if(
dynamic_cast<const typename NodalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HGRAD_QUAD*
>(basis)) {
 
   92             typename NodalBasisFamily<hostExecutionSpace>::HGRAD_QUAD hostBasis(order);
 
   93             init_HGRAD_QUAD(matData, &hostBasis);
 
   94         } 
else if(
dynamic_cast<const typename DerivedNodalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HGRAD_QUAD*
>(basis)) {
 
   95             typename DerivedNodalBasisFamily<hostExecutionSpace>::HGRAD_QUAD hostBasis(order);
 
   96             init_HGRAD_QUAD(matData, &hostBasis);
 
   97         } 
else if(
dynamic_cast<const typename HierarchicalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HGRAD_QUAD*
>(basis)) {
 
   98           typename HierarchicalBasisFamily<hostExecutionSpace>::HGRAD_QUAD hostBasis(order);
 
   99           init_HGRAD_QUAD(matData, &hostBasis);
 
  103         matData = CoeffMatrixDataViewType();
 
  106     else if((basis->getBaseCellTopology().getKey() == shards::getCellTopologyData<shards::Hexahedron<8> >()->key)
 
  107         && (basis->getFunctionSpace() == FUNCTION_SPACE_HGRAD)) {
 
  109         const ordinal_type matDim = ordinalToTag(tagToOrdinal(2, 0, 0), 3), numSubcells = 18, numOrts = 8;
 
  110         matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::Intrepid2_HGRAD_HEX_Cn_FEM",
 
  116         if(
dynamic_cast<const typename NodalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HGRAD_HEX*
>(basis)) {
 
  117             typename NodalBasisFamily<hostExecutionSpace>::HGRAD_HEX hostBasis(order);
 
  118             init_HGRAD_HEX(matData, &hostBasis);
 
  119         } 
else if(
dynamic_cast<const typename DerivedNodalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HGRAD_HEX*
>(basis)) {
 
  120             typename DerivedNodalBasisFamily<hostExecutionSpace>::HGRAD_HEX hostBasis(order);
 
  121             init_HGRAD_HEX(matData, &hostBasis);
 
  122         } 
else if(
dynamic_cast<const typename HierarchicalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HGRAD_HEX*
>(basis)) {
 
  123           typename HierarchicalBasisFamily<hostExecutionSpace>::HGRAD_HEX hostBasis(order);
 
  124           init_HGRAD_HEX(matData, &hostBasis);
 
  128         matData = CoeffMatrixDataViewType();
 
  131     else if((basis->getBaseCellTopology().getKey() == shards::getCellTopologyData<shards::Triangle<3> >()->key)
 
  132         && (basis->getFunctionSpace() == FUNCTION_SPACE_HGRAD)) {
 
  134         const ordinal_type matDim = ordinalToTag(tagToOrdinal(1, 0, 0), 3), numEdges = 3, numOrts = 2;      
 
  135         matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::Intrepid2_HGRAD_TRI_Cn_FEM",
 
  141         Basis_HGRAD_TRI_Cn_FEM<hostExecutionSpace> hostBasis(order);
 
  142         init_HGRAD_TRI(matData, &hostBasis);
 
  145         matData = CoeffMatrixDataViewType();
 
  148     else if((basis->getBaseCellTopology().getKey() == shards::getCellTopologyData<shards::Tetrahedron<4> >()->key)
 
  149         && (basis->getFunctionSpace() == FUNCTION_SPACE_HGRAD)) {
 
  151         matDim = max(ordinalToTag(tagToOrdinal(1, 0, 0), 3),
 
  152                      ordinalToTag(tagToOrdinal(2, 0, 0), 3)),
 
  153         numSubcells = 10, numOrts = 6;
 
  154       matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::Intrepid2_HGRAD_TET_Cn_FEM",
 
  160       Basis_HGRAD_TET_Cn_FEM<hostExecutionSpace> hostBasis(order);
 
  161       init_HGRAD_TET(matData, &hostBasis);
 
  168     else if((basis->getBaseCellTopology().getKey() == shards::getCellTopologyData<shards::Quadrilateral<4> >()->key)
 
  169         && (basis->getFunctionSpace() == FUNCTION_SPACE_HCURL)) {
 
  170       const ordinal_type matDim = ordinalToTag(tagToOrdinal(1, 0, 0), 3), numEdges = 4, numOrts = 2;
 
  171       matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::Intrepid2_HCURL_QUAD_In_FEM",
 
  177       if (name == 
"Intrepid2_HCURL_QUAD_I1_FEM") {
 
  178         for (ordinal_type edgeId=0;edgeId<numEdges;++edgeId)
 
  179           init_EDGE_ELEMENT_I1_FEM(matData, edgeId);
 
  180       } 
else if(
dynamic_cast<const typename NodalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HCURL_QUAD*
>(basis)) {
 
  181           typename NodalBasisFamily<hostExecutionSpace>::HCURL_QUAD hostBasis(order);
 
  182           init_HCURL_QUAD(matData, &hostBasis);
 
  183       } 
else if(
dynamic_cast<const typename DerivedNodalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HCURL_QUAD*
>(basis)) {
 
  184           typename DerivedNodalBasisFamily<hostExecutionSpace>::HCURL_QUAD hostBasis(order);
 
  185           init_HCURL_QUAD(matData, &hostBasis);
 
  186       } 
else if(
dynamic_cast<const typename HierarchicalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HCURL_QUAD*
>(basis)) {
 
  187         typename HierarchicalBasisFamily<hostExecutionSpace>::HCURL_QUAD hostBasis(order);
 
  188         init_HCURL_QUAD(matData, &hostBasis);
 
  191     else if((basis->getBaseCellTopology().getKey() == shards::getCellTopologyData<shards::Hexahedron<8> >()->key)
 
  192         && (basis->getFunctionSpace() == FUNCTION_SPACE_HCURL)) {
 
  194       const ordinal_type matDim = ordinalToTag(tagToOrdinal((order < 2 ? 1 : 2), 0, 0), 3), numSubcells = (order < 2 ? 12 : 18), numOrts = 8;
 
  195       matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::Intrepid2_HCURL_HEX_In_FEM",
 
  201       if (name == 
"Intrepid2_HCURL_HEX_I1_FEM") {
 
  202         for (ordinal_type edgeId=0;edgeId<numSubcells;++edgeId)
 
  203           init_EDGE_ELEMENT_I1_FEM(matData, edgeId);
 
  204       } 
else if(
dynamic_cast<const typename NodalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HCURL_HEX*
>(basis)) {
 
  205           typename NodalBasisFamily<hostExecutionSpace>::HCURL_HEX hostBasis(order);
 
  206           init_HCURL_HEX(matData, &hostBasis);
 
  207       } 
else if(
dynamic_cast<const typename DerivedNodalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HCURL_HEX*
>(basis)) {
 
  208           typename DerivedNodalBasisFamily<hostExecutionSpace>::HCURL_HEX hostBasis(order);
 
  209           init_HCURL_HEX(matData, &hostBasis);
 
  210       } 
else if(
dynamic_cast<const typename HierarchicalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HCURL_HEX*
>(basis)) {
 
  211         typename HierarchicalBasisFamily<hostExecutionSpace>::HCURL_HEX hostBasis(order);
 
  212         init_HCURL_HEX(matData, &hostBasis);
 
  215     else if((basis->getBaseCellTopology().getKey() == shards::getCellTopologyData<shards::Triangle<3> >()->key)
 
  216         && (basis->getFunctionSpace() == FUNCTION_SPACE_HCURL)) {
 
  217       const ordinal_type matDim = ordinalToTag(tagToOrdinal(1, 0, 0), 3), numEdges = 3, numOrts = 2;
 
  218       matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::Intrepid2_HCURL_TRI_In_FEM",
 
  224       if (name == 
"Intrepid2_HCURL_TRI_I1_FEM") {
 
  225         for (ordinal_type edgeId=0;edgeId<numEdges;++edgeId)
 
  226           init_EDGE_ELEMENT_I1_FEM(matData, edgeId);
 
  227       } 
else if (name == 
"Intrepid2_HCURL_TRI_In_FEM") {
 
  228         Basis_HCURL_TRI_In_FEM<hostExecutionSpace> hostBasis(order);
 
  229         init_HCURL_TRI(matData, &hostBasis);
 
  232     else if((basis->getBaseCellTopology().getKey() == shards::getCellTopologyData<shards::Tetrahedron<4> >()->key)
 
  233         && (basis->getFunctionSpace() == FUNCTION_SPACE_HCURL)) {
 
  234       const ordinal_type matDim = ordinalToTag(tagToOrdinal((order < 2 ? 1 : 2), 0, 0), 3), numSubcells = (order < 2 ? 6 : 10), numOrts = 6;
 
  235       matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::Intrepid2_HCURL_TET_In_FEM",
 
  241       if (name == 
"Intrepid2_HCURL_TET_I1_FEM") {
 
  242         for (ordinal_type edgeId=0;edgeId<numSubcells;++edgeId)
 
  243           init_EDGE_ELEMENT_I1_FEM(matData, edgeId);
 
  244       } 
else if (name == 
"Intrepid2_HCURL_TET_In_FEM") {
 
  245         Basis_HCURL_TET_In_FEM<hostExecutionSpace> hostBasis(order);
 
  246         init_HCURL_TET(matData, &hostBasis);
 
  254     else if((basis->getBaseCellTopology().getKey() == shards::getCellTopologyData<shards::Quadrilateral<4> >()->key)
 
  255         && (basis->getFunctionSpace() == FUNCTION_SPACE_HDIV)) {
 
  257       const ordinal_type matDim = ordinalToTag(tagToOrdinal(1, 0, 0), 3), numEdges = 4, numOrts = 2;
 
  258       matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::Intrepid2_HCURL_QUAD_In_FEM",
 
  264       if (name == 
"Intrepid2_HDIV_QUAD_I1_FEM") {
 
  265         for (ordinal_type edgeId=0;edgeId<numEdges;++edgeId)
 
  266           init_EDGE_ELEMENT_I1_FEM(matData, edgeId);
 
  267       } 
else if(
dynamic_cast<const typename NodalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HDIV_QUAD*
>(basis)) {
 
  268           typename NodalBasisFamily<hostExecutionSpace>::HDIV_QUAD hostBasis(order);
 
  269           init_HDIV_QUAD(matData, &hostBasis);
 
  270       } 
else if(
dynamic_cast<const typename DerivedNodalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HDIV_QUAD*
>(basis)) {
 
  271           typename DerivedNodalBasisFamily<hostExecutionSpace>::HDIV_QUAD hostBasis(order);
 
  272           init_HDIV_QUAD(matData, &hostBasis);
 
  273       } 
else if(
dynamic_cast<const typename HierarchicalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HDIV_QUAD*
>(basis)) {
 
  274         typename HierarchicalBasisFamily<hostExecutionSpace>::HDIV_QUAD hostBasis(order);
 
  275         init_HDIV_QUAD(matData, &hostBasis);
 
  278     else if((basis->getBaseCellTopology().getKey() == shards::getCellTopologyData<shards::Hexahedron<8> >()->key)
 
  279         && (basis->getFunctionSpace() == FUNCTION_SPACE_HDIV)) {
 
  280       const ordinal_type matDim = ordinalToTag(tagToOrdinal(2, 0, 0), 3), numSubcells = 6, numOrts = 8;
 
  281       matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::Intrepid2_HDIV_HEX_In_FEM",
 
  287       if (name == 
"Intrepid2_HDIV_HEX_I1_FEM") {
 
  288         for (ordinal_type faceId=0;faceId<numSubcells;++faceId)
 
  289           init_QUAD_FACE_ELEMENT_I1_FEM(matData, faceId);
 
  290       } 
else if(
dynamic_cast<const typename NodalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HDIV_HEX*
>(basis)) {
 
  291           typename NodalBasisFamily<hostExecutionSpace>::HDIV_HEX hostBasis(order);
 
  292           init_HDIV_HEX(matData, &hostBasis);
 
  293       } 
else if(
dynamic_cast<const typename DerivedNodalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HDIV_HEX*
>(basis)) {
 
  294           typename DerivedNodalBasisFamily<hostExecutionSpace>::HDIV_HEX hostBasis(order);
 
  295           init_HDIV_HEX(matData, &hostBasis);
 
  296       } 
else if(
dynamic_cast<const typename HierarchicalBasisFamily<ExecutionSpace, OutputValueType, PointValueType>::HDIV_HEX*
>(basis)) {
 
  297         typename HierarchicalBasisFamily<hostExecutionSpace>::HDIV_HEX hostBasis(order);
 
  298         init_HDIV_HEX(matData, &hostBasis);
 
  301     else if((basis->getBaseCellTopology().getKey() == shards::getCellTopologyData<shards::Triangle<3> >()->key)
 
  302         && (basis->getFunctionSpace() == FUNCTION_SPACE_HDIV)) {
 
  303       const ordinal_type matDim = ordinalToTag(tagToOrdinal(1, 0, 0), 3), numEdges = 3, numOrts = 2;
 
  304       matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::Intrepid2_HDIV_TRI_In_FEM",
 
  309       if (name == 
"Intrepid2_HDIV_TRI_I1_FEM") {
 
  310         for (ordinal_type edgeId=0;edgeId<numEdges;++edgeId)
 
  311           init_EDGE_ELEMENT_I1_FEM(matData, edgeId);
 
  312       } 
else if (name == 
"Intrepid2_HDIV_TRI_In_FEM") {
 
  313         Basis_HDIV_TRI_In_FEM<hostExecutionSpace> hostBasis(order);
 
  314         init_HDIV_TRI(matData, &hostBasis);
 
  317     else if((basis->getBaseCellTopology().getKey() == shards::getCellTopologyData<shards::Tetrahedron<4> >()->key)
 
  318         && (basis->getFunctionSpace() == FUNCTION_SPACE_HDIV)) {
 
  319       const ordinal_type matDim = ordinalToTag(tagToOrdinal(2, 0, 0), 3), numSubcells = 4, numOrts = 6;
 
  320       matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::Intrepid2_HDIV_TET_In_FEM",
 
  326       if (name == 
"Intrepid2_HDIV_TET_I1_FEM") {
 
  327         for (ordinal_type faceId=0;faceId<numSubcells;++faceId)
 
  328           init_TRI_FACE_ELEMENT_I1_FEM(matData, faceId);
 
  329       } 
else if (name == 
"Intrepid2_HDIV_TET_In_FEM") {
 
  330         Basis_HDIV_TET_In_FEM<hostExecutionSpace> hostBasis(order);
 
  331         init_HDIV_TET(matData, &hostBasis);
 
  339     else if (name == 
"Intrepid2_HCURL_WEDGE_I1_FEM") {
 
  340       const ordinal_type matDim = 1, numEdges = 9, numOrts = 2;
 
  341       matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::Intrepid2_HCURL_WEDGE_I1_FEM",
 
  346       for (ordinal_type edgeId=0;edgeId<numEdges;++edgeId)
 
  347         init_EDGE_ELEMENT_I1_FEM(matData, edgeId);
 
  354     else if (name == 
"Intrepid2_HDIV_WEDGE_I1_FEM") {
 
  355       const ordinal_type matDim = 1, numFaces = 5, numOrts = 8;
 
  356       matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::Intrepid2_HDIV_WEDGE_I1_FEM",
 
  361       ordinal_type faceId = 0;
 
  362       for ( ;faceId<3;++faceId) 
 
  363         init_QUAD_FACE_ELEMENT_I1_FEM(matData, faceId);
 
  364       for ( ;faceId<numFaces;++faceId) 
 
  365         init_TRI_FACE_ELEMENT_I1_FEM(matData, faceId);
 
  374   template<
typename SpT>
 
  375   template<
typename BasisType>
 
  377   OrientationTools<SpT>::
 
  378   init_HGRAD_QUAD(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  379                        BasisType 
const *cellBasis) {
 
  380     const ordinal_type order(cellBasis->getDegree());
 
  381     Basis_HGRAD_LINE_Cn_FEM<typename BasisType::ExecutionSpace> lineBasis(order);
 
  383     const ordinal_type numEdge = 4, numOrt = 2;
 
  384     for (ordinal_type edgeId=0;edgeId<numEdge;++edgeId)
 
  385       for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
 
  386         auto mat = Kokkos::subview(matData, 
 
  388                                    Kokkos::ALL(), Kokkos::ALL());
 
  390                                                      lineBasis, *cellBasis,
 
  395   template<
typename SpT>
 
  396   template<
typename BasisType>
 
  398   OrientationTools<SpT>::
 
  399   init_HCURL_QUAD(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  400                        BasisType 
const *cellBasis) {
 
  401     const ordinal_type order(cellBasis->getDegree());
 
  402     Basis_HGRAD_LINE_Cn_FEM<typename BasisType::ExecutionSpace> bubbleBasis(order-1, POINTTYPE_GAUSS);
 
  404     const ordinal_type numEdge = 4, numOrt = 2;
 
  405     for (ordinal_type edgeId=0;edgeId<numEdge;++edgeId)
 
  406       for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
 
  407         auto mat = Kokkos::subview(matData, 
 
  409                                    Kokkos::ALL(), Kokkos::ALL());
 
  411                                                      bubbleBasis, *cellBasis,
 
  416   template<
typename SpT>
 
  417   template<
typename BasisType>
 
  419   OrientationTools<SpT>::
 
  420   init_HDIV_QUAD(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  421                           BasisType 
const *cellBasis) {
 
  422     const ordinal_type order(cellBasis->getDegree());
 
  423     Basis_HGRAD_LINE_Cn_FEM<typename BasisType::ExecutionSpace> bubbleBasis(order-1, POINTTYPE_GAUSS);
 
  425     const ordinal_type numEdge = 4, numOrt = 2;
 
  426     for (ordinal_type edgeId=0;edgeId<numEdge;++edgeId)
 
  427       for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
 
  428         auto mat = Kokkos::subview(matData, 
 
  430                                    Kokkos::ALL(), Kokkos::ALL());
 
  432                                                     bubbleBasis, *cellBasis,
 
  441   template<
typename SpT>
 
  442   template<
typename BasisType>
 
  444   OrientationTools<SpT>::
 
  445   init_HGRAD_HEX(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  446                                  BasisType 
const *cellBasis) {
 
  447       const ordinal_type order(cellBasis->getDegree());
 
  448       Basis_HGRAD_LINE_Cn_FEM<typename BasisType::ExecutionSpace> lineBasis(order);
 
  449       Basis_HGRAD_QUAD_Cn_FEM<typename BasisType::ExecutionSpace> quadBasis(order);
 
  451       const ordinal_type numEdge = 12, numFace = 6;    
 
  453         const ordinal_type numOrt = 2;
 
  454         for (ordinal_type edgeId=0;edgeId<numEdge;++edgeId)
 
  455           for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
 
  456             auto mat = Kokkos::subview(matData, 
 
  458                                        Kokkos::ALL(), Kokkos::ALL());
 
  460                                                          lineBasis, *cellBasis,
 
  465         const ordinal_type numOrt = 8;
 
  466         for (ordinal_type faceId=0;faceId<numFace;++faceId)
 
  467           for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
 
  468             auto mat = Kokkos::subview(matData, 
 
  469                                        numEdge+faceId, faceOrt,
 
  470                                        Kokkos::ALL(), Kokkos::ALL());
 
  472                                                          quadBasis, *cellBasis,
 
  478   template<
typename SpT>
 
  479   template<
typename BasisType>
 
  481   OrientationTools<SpT>::
 
  482   init_HCURL_HEX(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  483       BasisType 
const *cellBasis) {
 
  484     const ordinal_type order(cellBasis->getDegree());
 
  485     Basis_HGRAD_LINE_Cn_FEM<typename BasisType::ExecutionSpace> bubbleBasis(order-1, POINTTYPE_GAUSS);
 
  486     Basis_HCURL_QUAD_In_FEM<typename BasisType::ExecutionSpace> quadBasis(order);
 
  488     const ordinal_type numEdge = 12, numFace = 6;    
 
  490       const ordinal_type numOrt = 2;
 
  491       for (ordinal_type edgeId=0;edgeId<numEdge;++edgeId)
 
  492         for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
 
  493           auto mat = Kokkos::subview(matData, 
 
  495                                      Kokkos::ALL(), Kokkos::ALL());
 
  497                                                        bubbleBasis, *cellBasis,
 
  502       const ordinal_type numOrt = 8;
 
  503       for (ordinal_type faceId=0;faceId<numFace;++faceId)
 
  504         for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
 
  505           auto mat = Kokkos::subview(matData, 
 
  506                                      numEdge+faceId, faceOrt,
 
  507                                      Kokkos::ALL(), Kokkos::ALL());
 
  509                                                        quadBasis, *cellBasis,
 
  515   template<
typename SpT>
 
  516   template<
typename BasisType>
 
  518   OrientationTools<SpT>::
 
  519   init_HDIV_HEX(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  520       BasisType 
const *cellBasis) {
 
  521     const ordinal_type order(cellBasis->getDegree());
 
  522     Basis_HGRAD_QUAD_Cn_FEM<typename BasisType::ExecutionSpace> quadBasis(order-1, POINTTYPE_GAUSS);
 
  524     const ordinal_type numFace = 6;    
 
  526       const ordinal_type numOrt = 8;
 
  527       for (ordinal_type faceId=0;faceId<numFace;++faceId)
 
  528         for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
 
  529           auto mat = Kokkos::subview(matData, 
 
  531                                      Kokkos::ALL(), Kokkos::ALL());
 
  533                                                       quadBasis, *cellBasis,
 
  543   template<
typename SpT>
 
  544   template<
typename BasisType>
 
  546   OrientationTools<SpT>::
 
  547   init_HGRAD_TRI(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  548       BasisType 
const *cellBasis) {
 
  549       const ordinal_type order(cellBasis->getDegree());
 
  550       Basis_HGRAD_LINE_Cn_FEM<typename BasisType::ExecutionSpace> lineBasis(order);
 
  552       const ordinal_type numEdge = 3, numOrt = 2;
 
  553       for (ordinal_type edgeId=0;edgeId<numEdge;++edgeId)
 
  554         for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
 
  555           auto mat = Kokkos::subview(matData, 
 
  557                                      Kokkos::ALL(), Kokkos::ALL());
 
  559                                                        lineBasis, *cellBasis,
 
  565   template<
typename SpT>
 
  566   template<
typename BasisType>
 
  568   OrientationTools<SpT>::
 
  569   init_HCURL_TRI(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  570       BasisType 
const *cellBasis) {
 
  571     const ordinal_type order(cellBasis->getDegree());
 
  572     Basis_HVOL_LINE_Cn_FEM<typename BasisType::ExecutionSpace> bubbleBasis(order-1);
 
  574     const ordinal_type numEdge = 3, numOrt = 2;
 
  575     for (ordinal_type edgeId=0;edgeId<numEdge;++edgeId)
 
  576       for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
 
  577         auto mat = Kokkos::subview(matData, 
 
  579                                    Kokkos::ALL(), Kokkos::ALL());
 
  581                                                      bubbleBasis, *cellBasis,
 
  586   template<
typename SpT>
 
  587   template<
typename BasisType>
 
  589   OrientationTools<SpT>::
 
  590   init_HDIV_TRI(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  591       BasisType 
const *cellBasis) {
 
  592     const ordinal_type order(cellBasis->getDegree());
 
  593     Basis_HVOL_LINE_Cn_FEM<typename BasisType::ExecutionSpace> bubbleBasis(order-1);
 
  595     const ordinal_type numEdge = 3, numOrt = 2;
 
  596     for (ordinal_type edgeId=0;edgeId<numEdge;++edgeId)
 
  597       for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
 
  598         auto mat = Kokkos::subview(matData, 
 
  600                                    Kokkos::ALL(), Kokkos::ALL());
 
  602                                                     bubbleBasis, *cellBasis,
 
  611   template<
typename SpT>
 
  612   template<
typename BasisType>
 
  614   OrientationTools<SpT>::
 
  615   init_HGRAD_TET(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  616       BasisType 
const *cellBasis) {
 
  617     const ordinal_type order(cellBasis->getDegree());
 
  618       Basis_HGRAD_LINE_Cn_FEM<typename BasisType::ExecutionSpace> lineBasis(order);
 
  619       Basis_HGRAD_TRI_Cn_FEM<typename BasisType::ExecutionSpace>  triBasis(order);
 
  621       const ordinal_type numEdge = 6, numFace = 4;    
 
  623         const ordinal_type numOrt = 2;
 
  624         for (ordinal_type edgeId=0;edgeId<numEdge;++edgeId)
 
  625           for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
 
  626             auto mat = Kokkos::subview(matData, 
 
  628                                        Kokkos::ALL(), Kokkos::ALL());
 
  630                                                          lineBasis, *cellBasis,
 
  635         const ordinal_type numOrt = 6;
 
  636         for (ordinal_type faceId=0;faceId<numFace;++faceId)
 
  637           for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
 
  638             auto mat = Kokkos::subview(matData, 
 
  639                                        numEdge+faceId, faceOrt,
 
  640                                        Kokkos::ALL(), Kokkos::ALL());
 
  642                                                          triBasis, *cellBasis,
 
  648   template<
typename SpT>
 
  649   template<
typename BasisType>
 
  651   OrientationTools<SpT>::
 
  652   init_HCURL_TET(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  653       BasisType 
const *cellBasis) {
 
  654     const ordinal_type order(cellBasis->getDegree());
 
  655     Basis_HVOL_LINE_Cn_FEM<typename BasisType::ExecutionSpace> bubbleBasis(order-1);
 
  656     Basis_HCURL_TRI_In_FEM<typename BasisType::ExecutionSpace> triBasis(order);
 
  658     const ordinal_type numEdge = 6, numFace = 4;    
 
  660       const ordinal_type numOrt = 2;
 
  661       for (ordinal_type edgeId=0;edgeId<numEdge;++edgeId)
 
  662         for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
 
  663           auto mat = Kokkos::subview(matData, 
 
  665                                      Kokkos::ALL(), Kokkos::ALL());
 
  667                                                        bubbleBasis, *cellBasis,
 
  672       const ordinal_type numOrt = 6;
 
  673       for (ordinal_type faceId=0;faceId<numFace;++faceId)
 
  674         for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
 
  675           auto mat = Kokkos::subview(matData, 
 
  676                                      numEdge+faceId, faceOrt,
 
  677                                      Kokkos::ALL(), Kokkos::ALL());
 
  679                                                        triBasis, *cellBasis,
 
  685   template<
typename SpT>
 
  686   template<
typename BasisType>
 
  688   OrientationTools<SpT>::
 
  689   init_HDIV_TET(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  690       BasisType 
const *cellBasis) {
 
  691     const ordinal_type order(cellBasis->getDegree());
 
  692     Basis_HVOL_TRI_Cn_FEM<typename BasisType::ExecutionSpace> triBasis(order-1);
 
  694     const ordinal_type numFace = 4, numOrt = 6;
 
  695     for (ordinal_type faceId=0;faceId<numFace;++faceId)
 
  696       for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
 
  697         auto mat = Kokkos::subview(matData, 
 
  699                                    Kokkos::ALL(), Kokkos::ALL());
 
  701                                                     triBasis, *cellBasis,
 
  710   template<
typename SpT>
 
  712   OrientationTools<SpT>::
 
  713   init_EDGE_ELEMENT_I1_FEM(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  714                            const ordinal_type edgeId) {
 
  715     const ordinal_type numOrt = 2;
 
  716     const double edgeOrtCoeff[2] = { 1.0, -1.0 };
 
  717     for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
 
  718       auto mat = Kokkos::subview(matData, 
 
  720                                  Kokkos::ALL(), Kokkos::ALL());
 
  721       mat(0,0) = edgeOrtCoeff[edgeOrt];
 
  725   template<
typename SpT>
 
  727   OrientationTools<SpT>::
 
  728   init_TRI_FACE_ELEMENT_I1_FEM(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  729                                const ordinal_type faceId) {
 
  730     const ordinal_type numOrt = 6;
 
  731     const double faceOrtCoeff[6] = {   1.0,  1.0,  1.0, 
 
  734     for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
 
  735       auto mat = Kokkos::subview(matData, 
 
  737                                  Kokkos::ALL(), Kokkos::ALL());
 
  738       mat(0,0) = faceOrtCoeff[faceOrt];
 
  742   template<
typename SpT>
 
  744   OrientationTools<SpT>::
 
  745   init_QUAD_FACE_ELEMENT_I1_FEM(
typename OrientationTools<SpT>::CoeffMatrixDataViewType matData,
 
  746                                 const ordinal_type faceId) {
 
  747     const ordinal_type numOrt = 8;
 
  748     const double faceOrtCoeff[8] = {   1.0,  1.0,  1.0,  1.0, 
 
  749                                       -1.0, -1.0, -1.0, -1.0 };
 
  751     for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
 
  752       auto mat = Kokkos::subview(matData, 
 
  754                                  Kokkos::ALL(), Kokkos::ALL());
 
  755       mat(0,0) = faceOrtCoeff[faceOrt];
 
  759   template<
typename SpT>
 
  760   template<
typename BasisType>
 
  761   typename OrientationTools<SpT>::CoeffMatrixDataViewType
 
  763 #ifdef HAVE_INTREPID2_DEBUG 
  764     INTREPID2_TEST_FOR_EXCEPTION( !basis->requireOrientation(), std::invalid_argument,
 
  765                                   ">>> ERROR (OrientationTools::createCoeffMatrix): basis does not require orientations." );
 
  767     Kokkos::push_finalize_hook( [=] {
 
  768       ortCoeffData=std::map<std::pair<std::string,ordinal_type>, 
typename OrientationTools<SpT>::CoeffMatrixDataViewType>();
 
  771     const std::pair<std::string,ordinal_type> key(basis->getName(), basis->getDegree());
 
  772     const auto found = ortCoeffData.find(key);
 
  774     CoeffMatrixDataViewType matData;
 
  775     if (found == ortCoeffData.end()) {
 
  776       matData = createCoeffMatrixInternal(basis);
 
  777       ortCoeffData.insert(std::make_pair(key, matData));
 
  779       matData = found->second;
 
  785   template<
typename SpT>
 
  787     ortCoeffData.clear();