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
59 template<
typename BasisHostType>
60 typename OrientationTools<DT>::CoeffMatrixDataViewType
61 OrientationTools<DT>::createCoeffMatrixInternal(
const BasisHostType* basis,
const bool inverse) {
62 const std::string name(basis->getName());
63 CoeffMatrixDataViewType matData;
65 const auto cellTopo = basis->getBaseCellTopology();
66 const ordinal_type numEdges = cellTopo.getSubcellCount(1);
67 const ordinal_type numFaces = cellTopo.getSubcellCount(2);
68 ordinal_type matDim = 0, matDim1 = 0, matDim2 = 0, numOrts = 0, numSubCells;
69 for(ordinal_type i=0; i<numEdges; ++i) {
70 matDim1 = std::max(matDim1, basis->getDofCount(1,i));
71 numOrts = std::max(numOrts,2);
73 for(ordinal_type i=0; i<numFaces; ++i) {
74 matDim2 = std::max(matDim2, basis->getDofCount(2,i));
75 numOrts = std::max(numOrts,2*ordinal_type(cellTopo.getSideCount(2,i)));
77 matDim = std::max(matDim1,matDim2);
78 numSubCells = (matDim1>0)*numEdges + (matDim2>0)*numFaces;
81 matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::"+name,
87 if(basis->getFunctionSpace() == FUNCTION_SPACE_HGRAD) {
88 init_HGRAD(matData, basis, inverse);
89 }
else if (basis->getFunctionSpace() == FUNCTION_SPACE_HCURL) {
90 init_HCURL(matData, basis, inverse);
91 }
else if (basis->getFunctionSpace() == FUNCTION_SPACE_HDIV) {
92 init_HDIV(matData, basis, inverse);
93 }
else if (basis->getFunctionSpace() == FUNCTION_SPACE_HVOL) {
94 init_HVOL(matData, basis, inverse);
102 template<
typename DT>
103 template<
typename BasisHostType>
106 init_HGRAD(
typename OrientationTools<DT>::CoeffMatrixDataViewType matData,
107 BasisHostType
const *cellBasis,
108 const bool inverse) {
110 const auto cellTopo = cellBasis->getBaseCellTopology();
111 const ordinal_type numEdges = cellTopo.getSubcellCount(1);
112 const ordinal_type numFaces = cellTopo.getSubcellCount(2);
113 Intrepid2::BasisPtr<
typename BasisHostType::DeviceType,
114 typename BasisHostType::OutputValueType,
115 typename BasisHostType::PointValueType>
117 BasisHostType
const *subcellBasis;
120 subcellBasis = cellBasis;
121 const ordinal_type numOrt = 2;
122 for (ordinal_type edgeId=0;edgeId<numEdges;++edgeId) {
123 if(cellBasis->getDofCount(1, edgeId) < 2)
continue;
124 if(cellTopo.getDimension()!=1) {
125 basisPtr = cellBasis->getSubCellRefBasis(1,edgeId);
126 subcellBasis = basisPtr.get();
129 for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
130 auto mat = Kokkos::subview(matData,
132 Kokkos::ALL(), Kokkos::ALL());
135 *subcellBasis, *cellBasis,
136 edgeId, edgeOrt, inverse);
141 subcellBasis = cellBasis;
142 for (ordinal_type faceId=0;faceId<numFaces;++faceId) {
144 const ordinal_type numOrt = 2*cellTopo.getSideCount(2,faceId);
145 if(cellBasis->getDofCount(2, faceId) < 1)
continue;
146 if(cellTopo.getDimension()!=2) {
147 basisPtr = cellBasis->getSubCellRefBasis(2,faceId);
148 subcellBasis = basisPtr.get();
150 for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
151 auto mat = Kokkos::subview(matData,
152 numEdges+faceId, faceOrt,
153 Kokkos::ALL(), Kokkos::ALL());
156 *subcellBasis, *cellBasis,
157 faceId, faceOrt, inverse);
166 template<
typename DT>
167 template<
typename BasisHostType>
170 init_HCURL(
typename OrientationTools<DT>::CoeffMatrixDataViewType matData,
171 BasisHostType
const *cellBasis,
const bool inverse) {
172 const auto cellTopo = cellBasis->getBaseCellTopology();
173 const ordinal_type numEdges = cellTopo.getSubcellCount(1);
174 const ordinal_type numFaces = cellTopo.getSubcellCount(2);
175 Intrepid2::BasisPtr<
typename BasisHostType::DeviceType,
176 typename BasisHostType::OutputValueType,
177 typename BasisHostType::PointValueType>
179 BasisHostType
const* subcellBasis;
182 subcellBasis = cellBasis;
183 const ordinal_type numOrt = 2;
184 for (ordinal_type edgeId=0;edgeId<numEdges;++edgeId) {
185 if(cellBasis->getDofCount(1, edgeId) < 1)
continue;
186 if(cellTopo.getDimension()!=1) {
187 basisPtr = cellBasis->getSubCellRefBasis(1,edgeId);
188 subcellBasis = basisPtr.get();
190 for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
191 auto mat = Kokkos::subview(matData,
193 Kokkos::ALL(), Kokkos::ALL());
195 *subcellBasis, *cellBasis,
196 edgeId, edgeOrt, inverse);
201 subcellBasis = cellBasis;
202 for (ordinal_type faceId=0;faceId<numFaces;++faceId) {
204 const ordinal_type numOrt = 2*cellTopo.getSideCount(2,faceId);
205 if(cellBasis->getDofCount(2, faceId) < 1)
continue;
206 if(cellTopo.getDimension()!=2) {
207 basisPtr = cellBasis->getSubCellRefBasis(2,faceId);
208 subcellBasis = basisPtr.get();
210 for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
211 auto mat = Kokkos::subview(matData,
212 numEdges+faceId, faceOrt,
213 Kokkos::ALL(), Kokkos::ALL());
216 *subcellBasis, *cellBasis,
217 faceId, faceOrt, inverse);
226 template<
typename DT>
227 template<
typename BasisHostType>
230 init_HDIV(
typename OrientationTools<DT>::CoeffMatrixDataViewType matData,
231 BasisHostType
const *cellBasis,
const bool inverse) {
232 const auto cellTopo = cellBasis->getBaseCellTopology();
233 const ordinal_type numSides = cellTopo.getSideCount();
234 const ordinal_type sideDim = cellTopo.getDimension()-1;
235 Intrepid2::BasisPtr<
typename BasisHostType::DeviceType,
236 typename BasisHostType::OutputValueType,
237 typename BasisHostType::PointValueType>
241 for (ordinal_type sideId=0;sideId<numSides;++sideId) {
242 if(cellBasis->getDofCount(sideDim, sideId) < 1)
continue;
243 const ordinal_type numOrt = (sideDim == 1) ? 2 : 2*cellTopo.getSideCount(sideDim,sideId);
244 subcellBasisPtr = cellBasis->getSubCellRefBasis(sideDim,sideId);
245 for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
246 auto mat = Kokkos::subview(matData,
248 Kokkos::ALL(), Kokkos::ALL());
250 *subcellBasisPtr, *cellBasis,
251 sideId, faceOrt, inverse);
260 template<
typename DT>
261 template<
typename BasisHostType>
264 init_HVOL(
typename OrientationTools<DT>::CoeffMatrixDataViewType matData,
265 BasisHostType
const *cellBasis,
const bool inverse) {
267 const auto cellTopo = cellBasis->getBaseCellTopology();
268 const ordinal_type numEdges = (cellTopo.getDimension()==1);
269 const ordinal_type numFaces = (cellTopo.getDimension()==2);
272 const ordinal_type numOrt = 2;
273 for (ordinal_type edgeId=0;edgeId<numEdges;++edgeId) {
274 if(cellBasis->getDofCount(1, edgeId) < 1)
continue;
275 for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
276 auto mat = Kokkos::subview(matData,
278 Kokkos::ALL(), Kokkos::ALL());
280 (mat, *cellBasis, edgeOrt, inverse);
285 for (ordinal_type faceId=0;faceId<numFaces;++faceId) {
287 const ordinal_type numOrt = 2*cellTopo.getSideCount(2,faceId);
288 if(cellBasis->getDofCount(2, faceId) < 1)
continue;
289 for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
290 auto mat = Kokkos::subview(matData,
291 numEdges+faceId, faceOrt,
292 Kokkos::ALL(), Kokkos::ALL());
294 (mat, *cellBasis, faceOrt, inverse);
300 template<
typename DT>
301 template<
typename BasisType>
302 typename OrientationTools<DT>::CoeffMatrixDataViewType
304 Kokkos::push_finalize_hook( [=] {
305 ortCoeffData=std::map<std::pair<std::string,ordinal_type>,
typename OrientationTools<DT>::CoeffMatrixDataViewType>();
308 const std::pair<std::string,ordinal_type> key(basis->getName(), basis->getDegree());
309 const auto found = ortCoeffData.find(key);
311 CoeffMatrixDataViewType matData;
312 if (found == ortCoeffData.end()) {
314 auto basis_host = basis->getHostBasis();
315 matData = createCoeffMatrixInternal(basis_host.getRawPtr());
316 ortCoeffData.insert(std::make_pair(key, matData));
319 matData = found->second;
325 template<
typename DT>
326 template<
typename BasisType>
327 typename OrientationTools<DT>::CoeffMatrixDataViewType
329 Kokkos::push_finalize_hook( [=] {
330 ortInvCoeffData=std::map<std::pair<std::string,ordinal_type>,
typename OrientationTools<DT>::CoeffMatrixDataViewType>();
333 const std::pair<std::string,ordinal_type> key(basis->getName(), basis->getDegree());
334 const auto found = ortInvCoeffData.find(key);
336 CoeffMatrixDataViewType matData;
337 if (found == ortInvCoeffData.end()) {
339 auto basis_host = basis->getHostBasis();
340 matData = createCoeffMatrixInternal(basis_host.getRawPtr(),
true);
341 ortInvCoeffData.insert(std::make_pair(key, matData));
344 matData = found->second;
350 template<
typename DT>
352 ortCoeffData.clear();
353 ortInvCoeffData.clear();