23 #ifndef __INTREPID2_ORIENTATIONTOOLS_DEF_COEFF_MATRIX_HGRAD_HPP__
24 #define __INTREPID2_ORIENTATIONTOOLS_DEF_COEFF_MATRIX_HGRAD_HPP__
27 #if defined (__clang__) && !defined (__INTEL_COMPILER)
28 #pragma clang system_header
36 #ifdef HAVE_INTREPID2_DEBUG
37 template<
typename subcellBasisType,
38 typename cellBasisType>
41 check_getCoeffMatrix_HGRAD(
const subcellBasisType& subcellBasis,
42 const cellBasisType& cellBasis,
43 const ordinal_type subcellId,
44 const ordinal_type subcellOrt) {
47 const shards::CellTopology cellTopo = cellBasis.getBaseCellTopology();
48 const shards::CellTopology subcellTopo = subcellBasis.getBaseCellTopology();
50 const ordinal_type cellDim = cellTopo.getDimension();
51 const ordinal_type subcellDim = subcellTopo.getDimension();
53 INTREPID2_TEST_FOR_EXCEPTION( subcellDim > cellDim,
55 ">>> ERROR (Intrepid::OrientationTools::getCoeffMatrix_HGRAD): " \
56 "cellDim cannot be smaller than subcellDim.");
58 INTREPID2_TEST_FOR_EXCEPTION( subcellDim > 2,
60 ">>> ERROR (Intrepid::OrientationTools::getCoeffMatrix_HGRAD): " \
61 "subCellDim cannot be larger than 2.");
63 const auto subcellBaseKey = subcellTopo.getBaseKey();
65 INTREPID2_TEST_FOR_EXCEPTION( subcellBaseKey != shards::Line<>::key &&
66 subcellBaseKey != shards::Quadrilateral<>::key &&
67 subcellBaseKey != shards::Triangle<>::key,
69 ">>> ERROR (Intrepid::OrientationTools::getCoeffMatrix_HGRAD): " \
70 "subcellBasis must have line, quad, or triangle topology.");
78 const bool cellBasisIsHGRAD = cellBasis.getFunctionSpace() == FUNCTION_SPACE_HGRAD;
79 const bool subcellBasisIsHGRAD = subcellBasis.getFunctionSpace() == FUNCTION_SPACE_HGRAD;
80 if (cellBasisIsHGRAD) {
81 INTREPID2_TEST_FOR_EXCEPTION( !subcellBasisIsHGRAD,
83 ">>> ERROR (Intrepid::OrientationTools::getCoeffMatrix_HGRAD): " \
84 "subcellBasis function space is not consistent to cellBasis.");
87 INTREPID2_TEST_FOR_EXCEPTION( subcellBasis.getDegree() != cellBasis.getDegree(),
89 ">>> ERROR (Intrepid::OrientationTools::getCoeffMatrix_HGRAD): " \
90 "subcellBasis has a different polynomial degree from cellBasis' degree.");
96 template<
typename OutputViewType,
97 typename subcellBasisHostType,
98 typename cellBasisHostType>
103 const subcellBasisHostType& subcellBasis,
104 const cellBasisHostType& cellBasis,
105 const ordinal_type subcellId,
106 const ordinal_type subcellOrt,
107 const bool inverse) {
109 #ifdef HAVE_INTREPID2_DEBUG
110 Debug::check_getCoeffMatrix_HGRAD(subcellBasis,cellBasis,subcellId,subcellOrt);
113 using host_device_type =
typename Kokkos::HostSpace::device_type;
114 using value_type =
typename OutputViewType::non_const_value_type;
120 const shards::CellTopology cellTopo = cellBasis.getBaseCellTopology();
121 const shards::CellTopology subcellTopo = subcellBasis.getBaseCellTopology();
122 const ordinal_type cellDim = cellTopo.getDimension();
123 const ordinal_type subcellDim = subcellTopo.getDimension();
124 const auto subcellBaseKey = subcellTopo.getBaseKey();
125 const ordinal_type numCellBasis = cellBasis.getCardinality();
126 const ordinal_type numSubcellBasis = subcellBasis.getCardinality();
127 const ordinal_type ndofSubcell = cellBasis.getDofCount(subcellDim,subcellId);
134 Kokkos::DynRankView<value_type,host_device_type> refPtsSubcell(
"refPtsSubcell", ndofSubcell, subcellDim);
137 INTREPID2_TEST_FOR_EXCEPTION( latticeSize != ndofSubcell,
139 ">>> ERROR (Intrepid::OrientationTools::getCoeffMatrix_HGRAD): " \
140 "Lattice size should be equal to the number of subcell internal DoFs");
144 Kokkos::DynRankView<value_type,host_device_type> refPtsCell(
"refPtsCell", ndofSubcell, cellDim);
146 if(cellDim == subcellDim)
158 Kokkos::DynRankView<value_type,host_device_type> cellBasisValues(
"cellBasisValues", numCellBasis, ndofSubcell);
161 Kokkos::DynRankView<value_type,host_device_type> subcellBasisValues(
"subcellBasisValues", numSubcellBasis, ndofSubcell);
163 cellBasis.getValues(cellBasisValues, refPtsCell, OPERATOR_VALUE);
164 subcellBasis.getValues(subcellBasisValues, refPtsSubcell, OPERATOR_VALUE);
173 Kokkos::DynRankView<value_type,Kokkos::LayoutLeft,host_device_type>
174 PsiMat(
"PsiMat", ndofSubcell, ndofSubcell),
175 PhiMat(
"PhiMat", ndofSubcell, ndofSubcell),
179 auto cellTagToOrdinal = cellBasis.getAllDofOrdinal();
180 auto subcellTagToOrdinal = subcellBasis.getAllDofOrdinal();
182 for (ordinal_type i=0;i<ndofSubcell;++i) {
183 const ordinal_type ic = cellTagToOrdinal(subcellDim, subcellId, i);
184 const ordinal_type isc = subcellTagToOrdinal(subcellDim, 0, i);
185 for (ordinal_type j=0;j<ndofSubcell;++j) {
186 PsiMat(j, i) = cellBasisValues(ic,j);
187 PhiMat(j, i) = subcellBasisValues(isc,j);
191 RefMat = inverse ? PhiMat : PsiMat;
192 OrtMat = inverse ? PsiMat : PhiMat;
196 Teuchos::LAPACK<ordinal_type,value_type> lapack;
197 ordinal_type info = 0;
199 Kokkos::DynRankView<ordinal_type,Kokkos::LayoutLeft,host_device_type> pivVec(
"pivVec", ndofSubcell);
200 lapack.GESV(ndofSubcell, ndofSubcell,
209 std::stringstream ss;
210 ss <<
">>> ERROR (Intrepid::OrientationTools::getCoeffMatrix_HGRAD): "
211 <<
"LAPACK return with error code: "
213 INTREPID2_TEST_FOR_EXCEPTION(
true, std::runtime_error, ss.str().c_str() );
219 const double eps = tolerence();
220 for (ordinal_type i=0;i<ndofSubcell;++i) {
221 auto intmatii = std::round(OrtMat(i,i));
222 OrtMat(i,i) = (std::abs(OrtMat(i,i) - intmatii) < eps) ? intmatii : OrtMat(i,i);
223 for (ordinal_type j=i+1;j<ndofSubcell;++j) {
224 auto matij = OrtMat(i,j);
226 auto intmatji = std::round(OrtMat(j,i));
227 OrtMat(i,j) = (std::abs(OrtMat(j,i) - intmatji) < eps) ? intmatji : OrtMat(j,i);
229 auto intmatij = std::round(matij);
230 OrtMat(j,i) = (std::abs(matij - intmatij) < eps) ? intmatij : matij;
252 const Kokkos::pair<ordinal_type,ordinal_type> range(0, ndofSubcell);
253 auto suboutput = Kokkos::subview(output, range, range);
254 auto tmp = Kokkos::create_mirror_view_and_copy(
typename OutputViewType::device_type::memory_space(), OrtMat);
255 Kokkos::deep_copy(suboutput, tmp);
static ConstViewType get(const ordinal_type subcellDim, const unsigned parentCellKey)
Returns a Kokkos view with the coefficients of the parametrization maps for the edges or faces of a r...