23 #ifndef __INTREPID2_ORIENTATIONTOOLS_DEF_COEFF_MATRIX_HVOL_HPP__
24 #define __INTREPID2_ORIENTATIONTOOLS_DEF_COEFF_MATRIX_HVOL_HPP__
27 #if defined (__clang__) && !defined (__INTEL_COMPILER)
28 #pragma clang system_header
36 #ifdef HAVE_INTREPID2_DEBUG
37 template<
typename cellBasisType>
40 check_getCoeffMatrix_HVOL(
const cellBasisType& cellBasis,
41 const ordinal_type cellOrt) {
44 const shards::CellTopology cellTopo = cellBasis.getBaseCellTopology();
45 const ordinal_type cellDim = cellTopo.getDimension();
47 INTREPID2_TEST_FOR_EXCEPTION( cellDim > 2,
49 ">>> ERROR (Intrepid::OrientationTools::getCoeffMatrix_HVOL): " \
50 "HVOL orientation supported only for (side) cells with dimension less than 3.");
52 const auto cellBaseKey = cellTopo.getBaseKey();
54 INTREPID2_TEST_FOR_EXCEPTION( cellBaseKey != shards::Line<>::key &&
55 cellBaseKey != shards::Quadrilateral<>::key &&
56 cellBaseKey != shards::Triangle<>::key,
58 ">>> ERROR (Intrepid::OrientationTools::getCoeffMatrix_HVOL): " \
59 "cellBasis must have line, quad, or triangle topology.");
67 INTREPID2_TEST_FOR_EXCEPTION( cellBasis.getFunctionSpace() != FUNCTION_SPACE_HVOL,
69 ">>> ERROR (Intrepid::OrientationTools::getCoeffMatrix_HVOL): " \
70 "cellBasis function space is not HVOL.");
76 template<
typename OutputViewType,
77 typename cellBasisHostType>
82 const cellBasisHostType& cellBasis,
83 const ordinal_type cellOrt,
86 #ifdef HAVE_INTREPID2_DEBUG
87 Debug::check_getCoeffMatrix_HVOL(cellBasis,cellOrt);
90 using host_device_type =
typename Kokkos::HostSpace::device_type;
91 using value_type =
typename OutputViewType::non_const_value_type;
97 const shards::CellTopology cellTopo = cellBasis.getBaseCellTopology();
98 const ordinal_type cellDim = cellTopo.getDimension();
99 const auto cellBaseKey = cellTopo.getBaseKey();
100 const ordinal_type cardinality = cellBasis.getCardinality();
107 Kokkos::DynRankView<value_type,host_device_type> refPtsCell(
"refPtsCell", cardinality, cellDim),refPtsCellNotOriented(
"refPtsCellNotOriented", cardinality, cellDim);
109 ordinal_type latticeOffset(1);
112 ordinal_type latticeOrder = (cellTopo.getBaseKey() == shards::Triangle<>::key) ?
113 cellBasis.getDegree() + 3 * latticeOffset :
114 cellBasis.getDegree() + 2 * latticeOffset;
126 Kokkos::DynRankView<value_type,host_device_type> cellBasisValues(
"cellBasisValues", cardinality, cardinality);
129 Kokkos::DynRankView<value_type,host_device_type> nonOrientedBasisValues(
"subcellBasisValues", cardinality, cardinality);
131 cellBasis.getValues(cellBasisValues, refPtsCell, OPERATOR_VALUE);
132 cellBasis.getValues(nonOrientedBasisValues, refPtsCellNotOriented, OPERATOR_VALUE);
141 Kokkos::DynRankView<value_type,Kokkos::LayoutLeft,host_device_type>
142 PsiMat(
"PsiMat", cardinality, cardinality),
143 PhiMat(
"PhiMat", cardinality, cardinality),
147 auto cellTagToOrdinal = cellBasis.getAllDofOrdinal();
149 Kokkos::DynRankView<value_type,host_device_type> jac(
"jacobian",cellDim,cellDim);
151 value_type jacDet(0);
153 jacDet = jac(0,0)*jac(1,1)-jac(0,1)*jac(1,0);
158 for (ordinal_type i=0;i<cardinality;++i) {
159 const ordinal_type ic = cellTagToOrdinal(cellDim, 0, i);
160 for (ordinal_type j=0;j<cardinality;++j) {
161 PsiMat(j, i) = cellBasisValues(ic,j)*jacDet;
162 PhiMat(j, i) = nonOrientedBasisValues(ic,j);
166 RefMat = inverse ? PhiMat : PsiMat;
167 OrtMat = inverse ? PsiMat : PhiMat;
171 Teuchos::LAPACK<ordinal_type,value_type> lapack;
172 ordinal_type info = 0;
174 Kokkos::DynRankView<ordinal_type,Kokkos::LayoutLeft,host_device_type> pivVec(
"pivVec", cardinality);
175 lapack.GESV(cardinality, cardinality,
184 std::stringstream ss;
185 ss <<
">>> ERROR (Intrepid::OrientationTools::getCoeffMatrix_HVOL): "
186 <<
"LAPACK return with error code: "
188 INTREPID2_TEST_FOR_EXCEPTION(
true, std::runtime_error, ss.str().c_str() );
194 const double eps = tolerence();
195 for (ordinal_type i=0;i<cardinality;++i) {
196 auto intmatii = std::round(OrtMat(i,i));
197 OrtMat(i,i) = (std::abs(OrtMat(i,i) - intmatii) < eps) ? intmatii : OrtMat(i,i);
198 for (ordinal_type j=i+1;j<cardinality;++j) {
199 auto matij = OrtMat(i,j);
201 auto intmatji = std::round(OrtMat(j,i));
202 OrtMat(i,j) = (std::abs(OrtMat(j,i) - intmatji) < eps) ? intmatji : OrtMat(j,i);
204 auto intmatij = std::round(matij);
205 OrtMat(j,i) = (std::abs(matij - intmatij) < eps) ? intmatij : matij;
227 const Kokkos::pair<ordinal_type,ordinal_type> range(0, cardinality);
228 auto suboutput = Kokkos::subview(output, range, range);
229 auto tmp = Kokkos::create_mirror_view_and_copy(
typename OutputViewType::device_type::memory_space(), OrtMat);
230 Kokkos::deep_copy(suboutput, tmp);