49 #ifndef __INTREPID2_PROJECTIONTOOLSDEFL2_HPP__
50 #define __INTREPID2_PROJECTIONTOOLSDEFL2_HPP__
59 namespace FunctorsProjectionTools {
61 template<
typename ViewType1,
typename ViewType2,
typename ViewType3,
64 ViewType1 basisCoeffs_;
65 const ViewType2 tagToOrdinal_;
66 const ViewType3 targetEPointsRange_;
67 const ViewType4 targetAtTargetEPoints_;
68 const ViewType1 basisAtTargetEPoints_;
69 ordinal_type numVertices_;
73 ViewType4 targetAtTargetEPoints, ViewType1 basisAtTargetEPoints, ordinal_type numVertices) :
74 basisCoeffs_(basisCoeffs), tagToOrdinal_(tagToOrdinal), targetEPointsRange_(targetEPointsRange),
75 targetAtTargetEPoints_(targetAtTargetEPoints), basisAtTargetEPoints_(basisAtTargetEPoints), numVertices_(numVertices) {}
78 KOKKOS_INLINE_FUNCTION
79 operator()(
const ordinal_type ic)
const {
80 for(ordinal_type iv=0; iv<numVertices_; ++iv) {
81 ordinal_type idof = tagToOrdinal_(0, iv, 0);
82 ordinal_type pt = targetEPointsRange_(0,iv).first;
84 basisCoeffs_(ic,idof) = targetAtTargetEPoints_(ic,pt)/basisAtTargetEPoints_(idof,pt,0);
90 template<
typename ViewType1,
typename ViewType2,
typename ViewType3,
91 typename ViewType4,
typename ViewType5>
93 const ViewType1 basisCoeffs_;
94 const ViewType1 negPartialProj_;
95 const ViewType1 basisDofDofAtBasisEPoints_;
96 const ViewType1 basisAtBasisEPoints_;
97 const ViewType2 basisEWeights_;
98 const ViewType1 wBasisDofAtBasisEPoints_;
99 const ViewType2 targetEWeights_;
100 const ViewType1 basisAtTargetEPoints_;
101 const ViewType1 wBasisDofAtTargetEPoints_;
102 const ViewType3 computedDofs_;
103 const ViewType4 tagToOrdinal_;
104 const ViewType5 targetAtTargetEPoints_;
105 const ViewType1 targetTanAtTargetEPoints_;
106 const ViewType1 refEdgesVec_;
107 ordinal_type fieldDim_;
108 ordinal_type edgeCardinality_;
109 ordinal_type offsetBasis_;
110 ordinal_type offsetTarget_;
111 ordinal_type numVertexDofs_;
112 ordinal_type edgeDim_;
116 const ViewType1 basisAtBasisEPoints,
const ViewType2 basisEWeights,
const ViewType1 wBasisDofAtBasisEPoints,
const ViewType2 targetEWeights,
117 const ViewType1 basisAtTargetEPoints,
const ViewType1 wBasisDofAtTargetEPoints,
const ViewType3 computedDofs,
const ViewType4 tagToOrdinal,
118 const ViewType5 targetAtTargetEPoints,
const ViewType1 targetTanAtTargetEPoints,
const ViewType1 refEdgesVec,
119 ordinal_type fieldDim, ordinal_type edgeCardinality, ordinal_type offsetBasis,
120 ordinal_type offsetTarget, ordinal_type numVertexDofs, ordinal_type edgeDim, ordinal_type iedge) :
121 basisCoeffs_(basisCoeffs), negPartialProj_(negPartialProj), basisDofDofAtBasisEPoints_(basisDofDofAtBasisEPoints),
122 basisAtBasisEPoints_(basisAtBasisEPoints), basisEWeights_(basisEWeights), wBasisDofAtBasisEPoints_(wBasisDofAtBasisEPoints), targetEWeights_(targetEWeights),
123 basisAtTargetEPoints_(basisAtTargetEPoints), wBasisDofAtTargetEPoints_(wBasisDofAtTargetEPoints),
124 computedDofs_(computedDofs), tagToOrdinal_(tagToOrdinal), targetAtTargetEPoints_(targetAtTargetEPoints),
125 targetTanAtTargetEPoints_(targetTanAtTargetEPoints), refEdgesVec_(refEdgesVec),
126 fieldDim_(fieldDim), edgeCardinality_(edgeCardinality), offsetBasis_(offsetBasis),
127 offsetTarget_(offsetTarget), numVertexDofs_(numVertexDofs), edgeDim_(edgeDim), iedge_(iedge)
131 KOKKOS_INLINE_FUNCTION
132 operator()(
const ordinal_type ic)
const {
133 for(ordinal_type j=0; j <edgeCardinality_; ++j) {
134 ordinal_type jdof =tagToOrdinal_(edgeDim_, iedge_, j);
135 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq) {
136 typename ViewType1::value_type tmp =0;
137 for(ordinal_type d=0; d <fieldDim_; ++d)
138 tmp += basisAtBasisEPoints_(jdof,offsetBasis_+iq,d)*refEdgesVec_(iedge_,d);
139 basisDofDofAtBasisEPoints_(0,j,iq) = tmp;
140 wBasisDofAtBasisEPoints_(ic,j,iq) = tmp*basisEWeights_(iq);
142 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
143 for(ordinal_type d=0; d <fieldDim_; ++d)
144 wBasisDofAtTargetEPoints_(ic,j,iq) += basisAtTargetEPoints_(jdof,offsetTarget_+iq,d)*refEdgesVec_(iedge_,d)*targetEWeights_(iq);
148 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq)
149 for(ordinal_type d=0; d <fieldDim_; ++d)
150 targetTanAtTargetEPoints_(ic,iq) += targetAtTargetEPoints_(ic,offsetTarget_+iq,d)*refEdgesVec_(iedge_,d);
152 for(ordinal_type j=0; j <numVertexDofs_; ++j) {
153 ordinal_type jdof = computedDofs_(j);
154 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq)
155 for(ordinal_type d=0; d <fieldDim_; ++d)
156 negPartialProj_(ic,iq) -= basisCoeffs_(ic,jdof)*basisAtBasisEPoints_(jdof,offsetBasis_+iq,d)*refEdgesVec_(iedge_,d);
161 template<
typename ViewType1,
typename ViewType2,
typename ViewType3,
162 typename ViewType4,
typename ViewType5>
164 const ViewType1 basisCoeffs_;
165 const ViewType1 negPartialProj_;
166 const ViewType1 faceBasisDofAtBasisEPoints_;
167 const ViewType1 basisAtBasisEPoints_;
168 const ViewType2 basisEWeights_;
169 const ViewType1 wBasisDofAtBasisEPoints_;
170 const ViewType2 targetEWeights_;
171 const ViewType1 basisAtTargetEPoints_;
172 const ViewType1 wBasisDofAtTargetEPoints_;
173 const ViewType3 computedDofs_;
174 const ViewType4 tagToOrdinal_;
175 const ViewType5 targetAtTargetEPoints_;
176 const ViewType1 targetDofAtTargetEPoints_;
177 const ViewType1 refSideNormal_;
178 ordinal_type fieldDim_;
179 ordinal_type faceCardinality_;
180 ordinal_type offsetBasis_;
181 ordinal_type offsetTarget_;
182 ordinal_type numVertexEdgeDofs_;
183 ordinal_type numFaces_;
184 ordinal_type faceDim_;
187 bool isHCurlBasis_, isHDivBasis_;
190 const ViewType1 basisAtBasisEPoints,
const ViewType2 basisEWeights,
const ViewType1 wBasisDofAtBasisEPoints,
const ViewType2 targetEWeights,
191 const ViewType1 basisAtTargetEPoints,
const ViewType1 wBasisDofAtTargetEPoints,
const ViewType3 computedDofs,
const ViewType4 tagToOrdinal,
192 const ViewType5 targetAtTargetEPoints,
const ViewType1 targetDofAtTargetEPoints,
193 const ViewType1 refSideNormal, ordinal_type fieldDim, ordinal_type faceCardinality, ordinal_type offsetBasis,
194 ordinal_type offsetTarget, ordinal_type numVertexEdgeDofs, ordinal_type numFaces, ordinal_type faceDim,
195 ordinal_type dim, ordinal_type iface,
bool isHCurlBasis,
bool isHDivBasis) :
196 basisCoeffs_(basisCoeffs), negPartialProj_(negPartialProj), faceBasisDofAtBasisEPoints_(faceBasisDofAtBasisEPoints),
197 basisAtBasisEPoints_(basisAtBasisEPoints), basisEWeights_(basisEWeights), wBasisDofAtBasisEPoints_(wBasisDofAtBasisEPoints), targetEWeights_(targetEWeights),
198 basisAtTargetEPoints_(basisAtTargetEPoints), wBasisDofAtTargetEPoints_(wBasisDofAtTargetEPoints),
199 computedDofs_(computedDofs), tagToOrdinal_(tagToOrdinal), targetAtTargetEPoints_(targetAtTargetEPoints),
200 targetDofAtTargetEPoints_(targetDofAtTargetEPoints), refSideNormal_(refSideNormal),
201 fieldDim_(fieldDim), faceCardinality_(faceCardinality), offsetBasis_(offsetBasis),
202 offsetTarget_(offsetTarget), numVertexEdgeDofs_(numVertexEdgeDofs), numFaces_(numFaces),
203 faceDim_(faceDim), dim_(dim), iface_(iface),
204 isHCurlBasis_(isHCurlBasis), isHDivBasis_(isHDivBasis)
208 KOKKOS_INLINE_FUNCTION
209 operator()(
const ordinal_type ic)
const {
213 typename ViewType1::value_type n[3] = {refSideNormal_(0), refSideNormal_(1), refSideNormal_(2)};
215 for(ordinal_type j=0; j <faceCardinality_; ++j) {
216 ordinal_type jdof = tagToOrdinal_(faceDim_, iface_, j);
217 for(ordinal_type d=0; d <fieldDim_; ++d) {
218 ordinal_type dp1 = (d+1) % dim_;
219 ordinal_type dp2 = (d+2) % dim_;
220 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq) {
222 faceBasisDofAtBasisEPoints_(0,j,iq,d) = basisAtBasisEPoints_(jdof,offsetBasis_+iq,dp1)*n[dp2] - basisAtBasisEPoints_(jdof,offsetBasis_+iq,dp2)*n[dp1];
224 wBasisDofAtBasisEPoints_(ic,j,iq,d) = faceBasisDofAtBasisEPoints_(0,j,iq,d) * basisEWeights_(iq);
226 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
228 wBasisDofAtTargetEPoints_(ic,j,iq,d) = (basisAtTargetEPoints_(jdof,offsetTarget_+iq,dp1)*n[dp2] - basisAtTargetEPoints_(jdof,offsetTarget_+iq,dp2)*n[dp1]) * targetEWeights_(iq);
233 for(ordinal_type d=0; d <fieldDim_; ++d) {
234 ordinal_type dp1 = (d+1) % dim_;
235 ordinal_type dp2 = (d+2) % dim_;
236 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
238 targetDofAtTargetEPoints_(ic,iq,d) = targetAtTargetEPoints_(ic,offsetTarget_+iq,dp1)*n[dp2] - targetAtTargetEPoints_(ic,offsetTarget_+iq,dp2)*n[dp1];
242 for(ordinal_type j=0; j <numVertexEdgeDofs_; ++j) {
243 ordinal_type jdof = computedDofs_(j);
244 for(ordinal_type d=0; d <fieldDim_; ++d) {
245 ordinal_type dp1 = (d+1) % dim_;
246 ordinal_type dp2 = (d+2) % dim_;
247 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq) {
249 negPartialProj_(ic,iq,d) -= (basisAtBasisEPoints_(jdof,offsetBasis_+iq,dp1)*n[dp2] - basisAtBasisEPoints_(jdof,offsetBasis_+iq,dp2)*n[dp1])*basisCoeffs_(ic,jdof);
254 typename ViewType1::value_type coeff[3] = {1,0,0};
256 for (ordinal_type d=0; d<3; d++)
257 coeff[d] = refSideNormal_(d);
260 for(ordinal_type j=0; j <faceCardinality_; ++j) {
261 ordinal_type jdof = tagToOrdinal_(faceDim_, iface_, j);
262 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq) {
263 typename ViewType1::value_type tmp =0;
264 for(ordinal_type d=0; d <fieldDim_; ++d)
265 tmp += coeff[d]*basisAtBasisEPoints_(jdof,offsetBasis_+iq,d);
266 faceBasisDofAtBasisEPoints_(0,j,iq,0) = tmp;
267 wBasisDofAtBasisEPoints_(ic,j,iq,0) = tmp * basisEWeights_(iq);
269 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
270 typename ViewType2::value_type sum=0;
271 for(ordinal_type d=0; d <fieldDim_; ++d)
272 sum += coeff[d]*basisAtTargetEPoints_(jdof,offsetTarget_+iq,d);
273 wBasisDofAtTargetEPoints_(ic,j,iq,0) = sum * targetEWeights_(iq);
277 for(ordinal_type d=0; d <fieldDim_; ++d)
278 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq)
279 targetDofAtTargetEPoints_(ic,iq,0) += coeff[d]*targetAtTargetEPoints_(ic,offsetTarget_+iq,d);
281 for(ordinal_type j=0; j <numVertexEdgeDofs_; ++j) {
282 ordinal_type jdof = computedDofs_(j);
283 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq)
284 for(ordinal_type d=0; d <fieldDim_; ++d)
285 negPartialProj_(ic,iq,0) -= basisCoeffs_(ic,jdof)*coeff[d]*basisAtBasisEPoints_(jdof,offsetBasis_+iq,d);
292 template<
typename ViewType1,
typename ViewType2,
typename ViewType3,
typename ViewType4>
294 const ViewType1 basisCoeffs_;
295 const ViewType1 negPartialProj_;
296 const ViewType1 internalBasisAtBasisEPoints_;
297 const ViewType1 basisAtBasisEPoints_;
298 const ViewType2 basisEWeights_;
299 const ViewType1 wBasisAtBasisEPoints_;
300 const ViewType2 targetEWeights_;
301 const ViewType1 basisAtTargetEPoints_;
302 const ViewType1 wBasisDofAtTargetEPoints_;
303 const ViewType3 computedDofs_;
304 const ViewType4 elemDof_;
305 ordinal_type fieldDim_;
306 ordinal_type numElemDofs_;
307 ordinal_type offsetBasis_;
308 ordinal_type offsetTarget_;
309 ordinal_type numVertexEdgeFaceDofs_;
312 const ViewType1 basisAtBasisEPoints,
const ViewType2 basisEWeights,
const ViewType1 wBasisAtBasisEPoints,
const ViewType2 targetEWeights,
313 const ViewType1 basisAtTargetEPoints,
const ViewType1 wBasisDofAtTargetEPoints,
const ViewType3 computedDofs,
const ViewType4 elemDof,
314 ordinal_type fieldDim, ordinal_type numElemDofs, ordinal_type offsetBasis, ordinal_type offsetTarget, ordinal_type numVertexEdgeFaceDofs) :
315 basisCoeffs_(basisCoeffs), negPartialProj_(negPartialProj), internalBasisAtBasisEPoints_(internalBasisAtBasisEPoints),
316 basisAtBasisEPoints_(basisAtBasisEPoints), basisEWeights_(basisEWeights), wBasisAtBasisEPoints_(wBasisAtBasisEPoints), targetEWeights_(targetEWeights),
317 basisAtTargetEPoints_(basisAtTargetEPoints), wBasisDofAtTargetEPoints_(wBasisDofAtTargetEPoints),
318 computedDofs_(computedDofs), elemDof_(elemDof), fieldDim_(fieldDim), numElemDofs_(numElemDofs), offsetBasis_(offsetBasis),
319 offsetTarget_(offsetTarget), numVertexEdgeFaceDofs_(numVertexEdgeFaceDofs) {}
322 KOKKOS_INLINE_FUNCTION
323 operator()(
const ordinal_type ic)
const {
325 for(ordinal_type j=0; j <numElemDofs_; ++j) {
326 ordinal_type idof = elemDof_(j);
327 for(ordinal_type d=0; d <fieldDim_; ++d) {
328 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq) {
329 internalBasisAtBasisEPoints_(0,j,iq,d) = basisAtBasisEPoints_(idof,offsetBasis_+iq,d);
330 wBasisAtBasisEPoints_(ic,j,iq,d) = internalBasisAtBasisEPoints_(0,j,iq,d) * basisEWeights_(iq);
332 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
333 wBasisDofAtTargetEPoints_(ic,j,iq,d) = basisAtTargetEPoints_(idof,offsetTarget_+iq,d)* targetEWeights_(iq);
337 for(ordinal_type j=0; j < numVertexEdgeFaceDofs_; ++j) {
338 ordinal_type jdof = computedDofs_(j);
339 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq)
340 for(ordinal_type d=0; d <fieldDim_; ++d) {
341 negPartialProj_(ic,iq,d) -= basisCoeffs_(ic,jdof)*basisAtBasisEPoints_(jdof,offsetBasis_+iq,d);
347 template<
typename ViewType1,
typename ViewType2>
349 const ViewType1 basisAtBasisEPoints_;
350 const ViewType2 basisEWeights_;
351 const ViewType1 wBasisAtBasisEPoints_;
352 const ViewType2 targetEWeights_;
353 const ViewType1 basisAtTargetEPoints_;
354 const ViewType1 wBasisDofAtTargetEPoints_;
355 ordinal_type fieldDim_;
356 ordinal_type numElemDofs_;
358 MultiplyBasisByWeights(
const ViewType1 basisAtBasisEPoints,
const ViewType2 basisEWeights,
const ViewType1 wBasisAtBasisEPoints,
const ViewType2 targetEWeights,
359 const ViewType1 basisAtTargetEPoints,
const ViewType1 wBasisDofAtTargetEPoints,
360 ordinal_type fieldDim, ordinal_type numElemDofs) :
361 basisAtBasisEPoints_(basisAtBasisEPoints), basisEWeights_(basisEWeights), wBasisAtBasisEPoints_(wBasisAtBasisEPoints), targetEWeights_(targetEWeights),
362 basisAtTargetEPoints_(basisAtTargetEPoints), wBasisDofAtTargetEPoints_(wBasisDofAtTargetEPoints),
363 fieldDim_(fieldDim), numElemDofs_(numElemDofs) {}
366 KOKKOS_INLINE_FUNCTION
367 operator()(
const ordinal_type ic)
const {
369 for(ordinal_type j=0; j <numElemDofs_; ++j) {
370 for(ordinal_type d=0; d <fieldDim_; ++d) {
371 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq) {
372 wBasisAtBasisEPoints_(ic,j,iq,d) = basisAtBasisEPoints_(j,iq,d) * basisEWeights_(iq);
374 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
375 wBasisDofAtTargetEPoints_(ic,j,iq,d) = basisAtTargetEPoints_(j,iq,d)* targetEWeights_(iq);
385 template<
typename DeviceType>
386 template<
typename basisCoeffsValueType,
class ...basisCoeffsProperties,
387 typename funValsValueType,
class ...funValsProperties,
389 typename ortValueType,
class ...ortProperties>
392 const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetAtTargetEPoints,
393 const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
394 const BasisType* cellBasis,
397 typedef typename BasisType::scalarType scalarType;
398 typedef Kokkos::DynRankView<scalarType,DeviceType> ScalarViewType;
399 typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
400 const auto cellTopo = cellBasis->getBaseCellTopology();
401 ordinal_type dim = cellTopo.getDimension();
402 ordinal_type basisCardinality = cellBasis->getCardinality();
403 ordinal_type numCells = targetAtTargetEPoints.extent(0);
404 const ordinal_type edgeDim = 1;
405 const ordinal_type faceDim = 2;
406 const ordinal_type fieldDim = (targetAtTargetEPoints.rank()==2) ? 1 : targetAtTargetEPoints.extent(2);
408 ordinal_type numVertices = (cellBasis->getDofCount(0, 0) > 0) ? cellTopo.getVertexCount() : 0;
409 ordinal_type numEdges = (cellBasis->getDofCount(1, 0) > 0) ? cellTopo.getEdgeCount() : 0;
410 ordinal_type numFaces = (cellBasis->getDofCount(2, 0) > 0) ? cellTopo.getFaceCount() : 0;
412 ScalarViewType refEdgesVec(
"refEdgesVec", numEdges, dim);
413 ScalarViewType refFacesTangents(
"refFaceTangents", numFaces, dim, 2);
414 ScalarViewType refFacesNormal(
"refFaceNormal", numFaces, dim);
416 ordinal_type numVertexDofs = numVertices;
418 ordinal_type numEdgeDofs(0);
419 for(ordinal_type ie=0; ie<numEdges; ++ie)
420 numEdgeDofs += cellBasis->getDofCount(edgeDim,ie);
422 ordinal_type numFaceDofs(0);
423 for(ordinal_type iface=0; iface<numFaces; ++iface)
424 numFaceDofs += cellBasis->getDofCount(faceDim,iface);
426 Kokkos::View<ordinal_type*, DeviceType> computedDofs(
"computedDofs", numVertexDofs+numEdgeDofs+numFaceDofs);
436 auto tagToOrdinal = Kokkos::create_mirror_view_and_copy(MemSpaceType(), cellBasis->getAllDofOrdinal());
438 ScalarViewType basisAtBasisEPoints(
"basisAtBasisEPoints",basisCardinality, numTotalBasisEPoints, fieldDim);
439 ScalarViewType basisAtTargetEPoints(
"basisAtTargetEPoints",basisCardinality, numTotalTargetEPoints, fieldDim);
442 cellBasis->getValues(Kokkos::subview(basisAtTargetEPoints, Kokkos::ALL(), Kokkos::ALL(), 0), targetEPoints);
443 cellBasis->getValues(Kokkos::subview(basisAtBasisEPoints, Kokkos::ALL(), Kokkos::ALL(), 0), basisEPoints);
446 cellBasis->getValues(basisAtTargetEPoints, targetEPoints);
447 cellBasis->getValues(basisAtBasisEPoints, basisEPoints);
452 auto hostComputedDofs = Kokkos::create_mirror_view(computedDofs);
453 ordinal_type computedDofsCount = 0;
454 for(ordinal_type iv=0; iv<numVertices; ++iv)
455 hostComputedDofs(computedDofsCount++) = cellBasis->getDofOrdinal(0, iv, 0);
457 for(ordinal_type ie=0; ie<numEdges; ++ie) {
458 ordinal_type edgeCardinality = cellBasis->getDofCount(edgeDim,ie);
459 for(ordinal_type i=0; i<edgeCardinality; ++i)
460 hostComputedDofs(computedDofsCount++) = cellBasis->getDofOrdinal(edgeDim, ie, i);
463 for(ordinal_type iface=0; iface<numFaces; ++iface) {
464 ordinal_type faceCardinality = cellBasis->getDofCount(faceDim,iface);
465 for(ordinal_type i=0; i<faceCardinality; ++i)
466 hostComputedDofs(computedDofsCount++) = cellBasis->getDofOrdinal(faceDim, iface, i);
468 Kokkos::deep_copy(computedDofs,hostComputedDofs);
471 bool isHGradBasis = (cellBasis->getFunctionSpace() == FUNCTION_SPACE_HGRAD);
472 bool isHCurlBasis = (cellBasis->getFunctionSpace() == FUNCTION_SPACE_HCURL);
473 bool isHDivBasis = (cellBasis->getFunctionSpace() == FUNCTION_SPACE_HDIV);
474 ordinal_type faceDofDim = isHCurlBasis ? 3 : 1;
475 ScalarViewType edgeCoeff(
"edgeCoeff", fieldDim);
478 const Kokkos::RangePolicy<ExecSpaceType> policy(0, numCells);
479 ScalarViewType refBasisCoeffs(
"refBasisCoeffs", basisCoeffs.extent(0), basisCoeffs.extent(1));
483 auto targetEPointsRange = Kokkos::create_mirror_view_and_copy(MemSpaceType(), projStruct->
getTargetPointsRange());
485 decltype(targetAtTargetEPoints)>;
486 Kokkos::parallel_for(policy, functorType(refBasisCoeffs, tagToOrdinal, targetEPointsRange,
487 targetAtTargetEPoints, basisAtTargetEPoints, numVertices));
491 for(ordinal_type ie=0; ie<numEdges; ++ie) {
492 auto edgeVec = Kokkos::subview(refEdgesVec, ie, Kokkos::ALL());
497 }
else if(isHDivBasis) {
500 deep_copy(edgeVec, 1.0);
503 ordinal_type edgeCardinality = cellBasis->getDofCount(edgeDim,ie);
504 ordinal_type numBasisEPoints = range_size(basisEPointsRange(edgeDim, ie));
505 ordinal_type numTargetEPoints = range_size(targetEPointsRange(edgeDim, ie));
507 ScalarViewType basisDofAtBasisEPoints(
"BasisDofAtBasisEPoints",1,edgeCardinality, numBasisEPoints);
508 ScalarViewType tragetDofAtTargetEPoints(
"TargetDofAtTargetEPoints",numCells, numTargetEPoints);
509 ScalarViewType weightedBasisAtBasisEPoints(
"weightedTanBasisAtBasisEPoints",numCells,edgeCardinality, numBasisEPoints);
510 ScalarViewType weightedBasisAtTargetEPoints(
"weightedTanBasisAtTargetEPoints",numCells,edgeCardinality, numTargetEPoints);
511 ScalarViewType negPartialProj(
"negPartialProj", numCells, numBasisEPoints);
513 auto targetEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getTargetEvalWeights(edgeDim,ie));
514 auto basisEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getBasisEvalWeights(edgeDim,ie));
517 ordinal_type offsetBasis = basisEPointsRange(edgeDim, ie).first;
518 ordinal_type offsetTarget = targetEPointsRange(edgeDim, ie).first;
522 decltype(computedDofs), decltype(tagToOrdinal), decltype(targetAtTargetEPoints)>;
524 Kokkos::parallel_for(policy, functorTypeEdge(refBasisCoeffs, negPartialProj, basisDofAtBasisEPoints,
525 basisAtBasisEPoints, basisEWeights, weightedBasisAtBasisEPoints, targetEWeights,
526 basisAtTargetEPoints, weightedBasisAtTargetEPoints, computedDofs, tagToOrdinal,
527 targetAtTargetEPoints,tragetDofAtTargetEPoints, refEdgesVec, fieldDim,
528 edgeCardinality, offsetBasis, offsetTarget, numVertexDofs, edgeDim, ie));
531 ScalarViewType edgeMassMat_(
"edgeMassMat_", 1, edgeCardinality, edgeCardinality),
532 edgeRhsMat_(
"rhsMat_", numCells, edgeCardinality);
539 typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
540 ScalarViewType t_(
"t",numCells, edgeCardinality);
541 WorkArrayViewType w_(
"w",numCells, edgeCardinality);
543 auto edgeDof = Kokkos::subview(tagToOrdinal, edgeDim, ie, Kokkos::ALL());
546 edgeSystem.
solve(refBasisCoeffs, edgeMassMat_, edgeRhsMat_, t_, w_, edgeDof, edgeCardinality);
549 for(ordinal_type iface=0; iface<numFaces; ++iface) {
550 ordinal_type faceCardinality = cellBasis->getDofCount(faceDim,iface);
552 ordinal_type numTargetEPoints = range_size(targetEPointsRange(faceDim, iface));
553 ordinal_type numBasisEPoints = range_size(basisEPointsRange(faceDim, iface));
555 ScalarViewType faceBasisDofAtBasisEPoints(
"faceBasisDofAtBasisEPoints",1,faceCardinality, numBasisEPoints,faceDofDim);
556 ScalarViewType wBasisDofAtBasisEPoints(
"weightedBasisDofAtBasisEPoints",numCells,faceCardinality, numBasisEPoints,faceDofDim);
558 ScalarViewType faceBasisAtTargetEPoints(
"faceBasisDofAtTargetEPoints",numCells,faceCardinality, numTargetEPoints,faceDofDim);
559 ScalarViewType wBasisDofAtTargetEPoints(
"weightedBasisDofAtTargetEPoints",numCells,faceCardinality, numTargetEPoints,faceDofDim);
561 ScalarViewType targetDofAtTargetEPoints(
"targetDofAtTargetEPoints",numCells, numTargetEPoints,faceDofDim);
562 ScalarViewType negPartialProj(
"negComputedProjection", numCells,numBasisEPoints,faceDofDim);
564 ordinal_type offsetBasis = basisEPointsRange(faceDim, iface).first;
565 ordinal_type offsetTarget = targetEPointsRange(faceDim, iface).first;
566 auto targetEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getTargetEvalWeights(faceDim,iface));
567 auto basisEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getBasisEvalWeights(faceDim,iface));
569 ScalarViewType refSideNormal(
"refSideNormal", dim);
573 decltype(computedDofs), decltype(tagToOrdinal), decltype(targetAtTargetEPoints)>;
575 Kokkos::parallel_for(policy, functorTypeFace(refBasisCoeffs, negPartialProj,faceBasisDofAtBasisEPoints,
576 basisAtBasisEPoints, basisEWeights, wBasisDofAtBasisEPoints, targetEWeights,
577 basisAtTargetEPoints, wBasisDofAtTargetEPoints, computedDofs, tagToOrdinal,
578 targetAtTargetEPoints,targetDofAtTargetEPoints,
579 refSideNormal, fieldDim, faceCardinality, offsetBasis,
580 offsetTarget, numVertexDofs+numEdgeDofs, numFaces, faceDim,
581 dim, iface, isHCurlBasis, isHDivBasis));
583 typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
584 ScalarViewType faceMassMat_(
"faceMassMat_", 1, faceCardinality, faceCardinality),
585 faceRhsMat_(
"rhsMat_", numCells, faceCardinality);
591 ScalarViewType t_(
"t",numCells, faceCardinality);
592 WorkArrayViewType w_(
"w",numCells,faceCardinality);
594 auto faceDof = Kokkos::subview(tagToOrdinal, faceDim, iface, Kokkos::ALL());
597 faceSystem.
solve(refBasisCoeffs, faceMassMat_, faceRhsMat_, t_, w_, faceDof, faceCardinality);
600 ordinal_type numElemDofs = cellBasis->getDofCount(dim,0);
605 auto cellDofs = Kokkos::subview(tagToOrdinal, dim, 0, Kokkos::ALL());
607 range_type cellPointsRange = targetEPointsRange(dim, 0);
609 ordinal_type numTargetEPoints = range_size(targetEPointsRange(dim,0));
610 ordinal_type numBasisEPoints = range_size(basisEPointsRange(dim,0));
612 ScalarViewType internalBasisAtBasisEPoints(
"internalBasisAtBasisEPoints",1,numElemDofs, numBasisEPoints, fieldDim);
613 ScalarViewType negPartialProj(
"negPartialProj", numCells, numBasisEPoints, fieldDim);
615 auto targetEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getTargetEvalWeights(dim,0));
616 auto basisEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getBasisEvalWeights(dim,0));
617 ordinal_type offsetBasis = basisEPointsRange(dim, 0).first;
618 ordinal_type offsetTarget = targetEPointsRange(dim, 0).first;
620 ScalarViewType wBasisAtBasisEPoints(
"weightedBasisAtBasisEPoints",numCells,numElemDofs, numBasisEPoints,fieldDim);
621 ScalarViewType wBasisDofAtTargetEPoints(
"weightedBasisAtTargetEPoints",numCells,numElemDofs, numTargetEPoints,fieldDim);
624 Kokkos::parallel_for(policy, functorType( refBasisCoeffs, negPartialProj, internalBasisAtBasisEPoints,
625 basisAtBasisEPoints, basisEWeights, wBasisAtBasisEPoints, targetEWeights, basisAtTargetEPoints, wBasisDofAtTargetEPoints,
626 computedDofs, cellDofs, fieldDim, numElemDofs, offsetBasis, offsetTarget, numVertexDofs+numEdgeDofs+numFaceDofs));
628 typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
629 ScalarViewType cellMassMat_(
"cellMassMat_", 1, numElemDofs, numElemDofs),
630 cellRhsMat_(
"rhsMat_", numCells, numElemDofs);
635 Kokkos::subview(wBasisDofAtTargetEPoints,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL(),0));
640 ScalarViewType t_(
"t",numCells, numElemDofs);
641 WorkArrayViewType w_(
"w",numCells,numElemDofs);
643 cellSystem.
solve(refBasisCoeffs, cellMassMat_, cellRhsMat_, t_, w_, cellDofs, numElemDofs);
650 template<
typename DeviceType>
651 template<
typename basisCoeffsValueType,
class ...basisCoeffsProperties,
652 typename funValsValueType,
class ...funValsProperties,
654 typename ortValueType,
class ...ortProperties>
657 const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetAtTargetEPoints,
658 const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
659 const BasisType* cellBasis,
662 Kokkos::DynRankView<typename BasisType::scalarType,DeviceType> refBasisCoeffs(
"refBasisCoeffs", basisCoeffs.extent(0), basisCoeffs.extent(1));
663 getL2DGBasisCoeffs(refBasisCoeffs, targetAtTargetEPoints, cellBasis, projStruct);
669 template<
typename DeviceType>
670 template<
typename basisViewType,
typename targetViewType,
typename BasisType>
673 const targetViewType targetAtTargetEPoints,
674 const BasisType* cellBasis,
677 typedef typename BasisType::scalarType scalarType;
678 typedef Kokkos::DynRankView<scalarType,DeviceType> ScalarViewType;
679 const auto cellTopo = cellBasis->getBaseCellTopology();
681 ordinal_type dim = cellTopo.getDimension();
683 auto basisEPoints = Kokkos::create_mirror_view_and_copy(MemSpaceType(),
685 auto targetEPoints = Kokkos::create_mirror_view_and_copy(MemSpaceType(),
688 ordinal_type numTotalTargetEPoints(targetAtTargetEPoints.extent(1));
689 ordinal_type basisCardinality = cellBasis->getCardinality();
690 ordinal_type numCells = targetAtTargetEPoints.extent(0);
691 const ordinal_type fieldDim = (targetAtTargetEPoints.rank()==2) ? 1 : targetAtTargetEPoints.extent(2);
694 ScalarViewType basisAtBasisEPoints(
"basisAtBasisEPoints",1,basisCardinality, numTotalBasisEPoints, fieldDim);
695 ScalarViewType basisAtTargetEPoints(
"basisAtTargetEPoints",basisCardinality, numTotalTargetEPoints, fieldDim);
698 cellBasis->getValues(Kokkos::subview(basisAtTargetEPoints,Kokkos::ALL(),Kokkos::ALL(),0), targetEPoints);
699 cellBasis->getValues(Kokkos::subview(basisAtBasisEPoints,0,Kokkos::ALL(),Kokkos::ALL(),0), basisEPoints);
702 cellBasis->getValues(basisAtTargetEPoints, targetEPoints);
703 cellBasis->getValues(Kokkos::subview(basisAtBasisEPoints,0,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL()), basisEPoints);
707 const Kokkos::RangePolicy<ExecSpaceType> policy(0, numCells);
708 ordinal_type numElemDofs = cellBasis->getCardinality();
710 auto targetEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getTargetEvalWeights(dim,0));
711 auto basisEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getBasisEvalWeights(dim,0));
713 ScalarViewType wBasisAtBasisEPoints(
"weightedBasisAtBasisEPoints",1,numElemDofs, numTotalBasisEPoints,fieldDim);
714 ScalarViewType wBasisDofAtTargetEPoints(
"weightedBasisAtTargetEPoints",numCells,numElemDofs, numTotalTargetEPoints,fieldDim);
715 Kokkos::DynRankView<ordinal_type, DeviceType> cellDofs(
"cellDoFs", numElemDofs);
717 Kokkos::parallel_for(Kokkos::RangePolicy<ExecSpaceType>(0,numElemDofs),
718 KOKKOS_LAMBDA (
const int &j) {
719 for(ordinal_type d=0; d <fieldDim; ++d) {
720 for(ordinal_type iq=0; iq < numTotalBasisEPoints; ++iq)
721 wBasisAtBasisEPoints(0,j,iq,d) = basisAtBasisEPoints(0,j,iq,d) * basisEWeights(iq);
722 for(ordinal_type iq=0; iq <numTotalTargetEPoints; ++iq) {
723 wBasisDofAtTargetEPoints(0,j,iq,d) = basisAtTargetEPoints(j,iq,d)* targetEWeights(iq);
730 typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
731 ScalarViewType cellMassMat_(
"cellMassMat_", 1, numElemDofs, numElemDofs),
732 cellRhsMat_(
"rhsMat_", numCells, numElemDofs);
737 Kokkos::subview(wBasisDofAtTargetEPoints,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL(),0));
741 ScalarViewType t_(
"t",1, numElemDofs);
742 WorkArrayViewType w_(
"w",numCells,numElemDofs);
744 cellSystem.
solve(basisCoeffs, cellMassMat_, cellRhsMat_, t_, w_, cellDofs, numElemDofs);
Header file for the abstract base class Intrepid2::DefaultCubatureFactory.
const range_tag getBasisPointsRange() const
Returns the range tag of the basis evaluation points subcells.
host_view_type getEvalPoints(const ordinal_type subCellDim, const ordinal_type subCellId, EvalPointsType type) const
Returns the basis/target evaluation points on a subcell.
ordinal_type getNumBasisEvalPoints()
Returns number of basis evaluation points.
view_type getAllEvalPoints(EvalPointsType type=TARGET) const
Returns the basis/target evaluation points in the cell.
host_view_type getBasisEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the basis evaluation weights on a subcell.
ordinal_type getNumTargetEvalPoints()
Returns number of points where to evaluate the target function.
const range_tag getTargetPointsRange() const
Returns the range of the target function evaluation points on subcells.
host_view_type getTargetEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the function evaluation weights on a subcell.
An helper class to compute the evaluation points and weights needed for performing projections...