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>
61 OrientationTools<DT>::createCoeffMatrixInternal(
const BasisHostType* basis) {
62 const std::string name(basis->getName());
63 CoeffMatrixDataViewType matData;
68 const auto cellTopo = basis->getBaseCellTopology();
69 const ordinal_type numEdges = cellTopo.getSubcellCount(1);
70 const ordinal_type numFaces = cellTopo.getSubcellCount(2);
71 ordinal_type matDim = 0, matDim1 = 0, matDim2 = 0, numOrts = 0, numSubCells;
72 for(ordinal_type i=0; i<numEdges; ++i) {
73 matDim1 = std::max(matDim1, basis->getDofCount(1,i));
74 numOrts = std::max(numOrts,2);
76 for(ordinal_type i=0; i<numFaces; ++i) {
77 matDim2 = std::max(matDim2, basis->getDofCount(2,i));
78 numOrts = std::max(numOrts,2*ordinal_type(cellTopo.getSideCount(2,i)));
80 matDim = std::max(matDim1,matDim2);
81 numSubCells = (matDim1>0)*numEdges + (matDim2>0)*numFaces;
84 matData = CoeffMatrixDataViewType(
"Orientation::CoeffMatrix::"+name,
90 if(basis->getFunctionSpace() == FUNCTION_SPACE_HGRAD) {
91 init_HGRAD(matData, basis);
92 }
else if (basis->getFunctionSpace() == FUNCTION_SPACE_HCURL) {
93 init_HCURL(matData, basis);
94 }
else if (basis->getFunctionSpace() == FUNCTION_SPACE_HDIV) {
95 init_HDIV(matData, basis);
96 }
else if (basis->getFunctionSpace() == FUNCTION_SPACE_HVOL) {
97 init_HVOL(matData, basis);
105 template<
typename DT>
106 template<
typename BasisHostType>
110 BasisHostType
const *cellBasis) {
112 const auto cellTopo = cellBasis->getBaseCellTopology();
113 const ordinal_type numEdges = cellTopo.getSubcellCount(1);
114 const ordinal_type numFaces = cellTopo.getSubcellCount(2);
116 typename BasisHostType::OutputValueType,
117 typename BasisHostType::PointValueType>
119 BasisHostType
const *subcellBasis;
122 subcellBasis = cellBasis;
123 const ordinal_type numOrt = 2;
124 for (ordinal_type edgeId=0;edgeId<numEdges;++edgeId) {
125 if(cellBasis->getDofCount(1, edgeId) < 2)
continue;
126 if(cellTopo.getDimension()!=1) {
127 basisPtr = cellBasis->getSubCellRefBasis(1,edgeId);
128 subcellBasis = basisPtr.get();
131 for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
132 auto mat = Kokkos::subview(matData,
134 Kokkos::ALL(), Kokkos::ALL());
137 *subcellBasis, *cellBasis,
143 subcellBasis = cellBasis;
144 for (ordinal_type faceId=0;faceId<numFaces;++faceId) {
146 const ordinal_type numOrt = 2*cellTopo.getSideCount(2,faceId);
147 if(cellBasis->getDofCount(2, faceId) < 1)
continue;
148 if(cellTopo.getDimension()!=2) {
149 basisPtr = cellBasis->getSubCellRefBasis(2,faceId);
150 subcellBasis = basisPtr.get();
152 for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
153 auto mat = Kokkos::subview(matData,
154 numEdges+faceId, faceOrt,
155 Kokkos::ALL(), Kokkos::ALL());
158 *subcellBasis, *cellBasis,
168 template<
typename DT>
169 template<
typename BasisHostType>
173 BasisHostType
const *cellBasis) {
174 const auto cellTopo = cellBasis->getBaseCellTopology();
175 const ordinal_type numEdges = cellTopo.getSubcellCount(1);
176 const ordinal_type numFaces = cellTopo.getSubcellCount(2);
178 typename BasisHostType::OutputValueType,
179 typename BasisHostType::PointValueType>
181 BasisHostType
const* subcellBasis;
184 subcellBasis = cellBasis;
185 const ordinal_type numOrt = 2;
186 for (ordinal_type edgeId=0;edgeId<numEdges;++edgeId) {
187 if(cellBasis->getDofCount(1, edgeId) < 1)
continue;
188 if(cellTopo.getDimension()!=1) {
189 basisPtr = cellBasis->getSubCellRefBasis(1,edgeId);
190 subcellBasis = basisPtr.get();
192 for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
193 auto mat = Kokkos::subview(matData,
195 Kokkos::ALL(), Kokkos::ALL());
197 *subcellBasis, *cellBasis,
203 subcellBasis = cellBasis;
204 for (ordinal_type faceId=0;faceId<numFaces;++faceId) {
206 const ordinal_type numOrt = 2*cellTopo.getSideCount(2,faceId);
207 if(cellBasis->getDofCount(2, faceId) < 1)
continue;
208 if(cellTopo.getDimension()!=2) {
209 basisPtr = cellBasis->getSubCellRefBasis(2,faceId);
210 subcellBasis = basisPtr.get();
212 for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
213 auto mat = Kokkos::subview(matData,
214 numEdges+faceId, faceOrt,
215 Kokkos::ALL(), Kokkos::ALL());
218 *subcellBasis, *cellBasis,
228 template<
typename DT>
229 template<
typename BasisHostType>
233 BasisHostType
const *cellBasis) {
234 const auto cellTopo = cellBasis->getBaseCellTopology();
235 const ordinal_type numSides = cellTopo.getSideCount();
236 const ordinal_type sideDim = cellTopo.getDimension()-1;
238 typename BasisHostType::OutputValueType,
239 typename BasisHostType::PointValueType>
243 for (ordinal_type sideId=0;sideId<numSides;++sideId) {
244 if(cellBasis->getDofCount(sideDim, sideId) < 1)
continue;
245 const ordinal_type numOrt = (sideDim == 1) ? 2 : 2*cellTopo.getSideCount(sideDim,sideId);
246 subcellBasisPtr = cellBasis->getSubCellRefBasis(sideDim,sideId);
247 for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
248 auto mat = Kokkos::subview(matData,
250 Kokkos::ALL(), Kokkos::ALL());
252 *subcellBasisPtr, *cellBasis,
262 template<
typename DT>
263 template<
typename BasisHostType>
267 BasisHostType
const *cellBasis) {
269 const auto cellTopo = cellBasis->getBaseCellTopology();
270 const ordinal_type numEdges = (cellTopo.getDimension()==1);
271 const ordinal_type numFaces = (cellTopo.getDimension()==2);
274 const ordinal_type numOrt = 2;
275 for (ordinal_type edgeId=0;edgeId<numEdges;++edgeId) {
276 if(cellBasis->getDofCount(1, edgeId) < 1)
continue;
277 for (ordinal_type edgeOrt=0;edgeOrt<numOrt;++edgeOrt) {
278 auto mat = Kokkos::subview(matData,
280 Kokkos::ALL(), Kokkos::ALL());
282 (mat, *cellBasis, edgeOrt);
287 for (ordinal_type faceId=0;faceId<numFaces;++faceId) {
289 const ordinal_type numOrt = 2*cellTopo.getSideCount(2,faceId);
290 if(cellBasis->getDofCount(2, faceId) < 1)
continue;
291 for (ordinal_type faceOrt=0;faceOrt<numOrt;++faceOrt) {
292 auto mat = Kokkos::subview(matData,
293 numEdges+faceId, faceOrt,
294 Kokkos::ALL(), Kokkos::ALL());
296 (mat, *cellBasis, faceOrt);
302 template<
typename DT>
303 template<
typename BasisType>
306 Kokkos::push_finalize_hook( [=] {
310 const std::pair<std::string,ordinal_type> key(basis->getName(), basis->getDegree());
311 const auto found = ortCoeffData.find(key);
314 if (found == ortCoeffData.end()) {
316 auto basis_host = basis->getHostBasis();
317 matData = createCoeffMatrixInternal(basis_host.getRawPtr());
318 ortCoeffData.insert(std::make_pair(key, matData));
321 matData = found->second;
327 template<
typename DT>
329 ortCoeffData.clear();
Teuchos::RCP< Basis< DeviceType, OutputType, PointType > > BasisPtr
Basis Pointer.