16 #ifndef __INTREPID2_PROJECTIONTOOLSDEFL2_HPP__
17 #define __INTREPID2_PROJECTIONTOOLSDEFL2_HPP__
26 namespace FunctorsProjectionTools {
28 template<
typename ViewType1,
typename ViewType2,
typename ViewType3,
31 ViewType1 basisCoeffs_;
32 const ViewType2 tagToOrdinal_;
33 const ViewType3 targetEPointsRange_;
34 const ViewType4 targetAtTargetEPoints_;
35 const ViewType1 basisAtTargetEPoints_;
36 ordinal_type numVertices_;
40 ViewType4 targetAtTargetEPoints, ViewType1 basisAtTargetEPoints, ordinal_type numVertices) :
41 basisCoeffs_(basisCoeffs), tagToOrdinal_(tagToOrdinal), targetEPointsRange_(targetEPointsRange),
42 targetAtTargetEPoints_(targetAtTargetEPoints), basisAtTargetEPoints_(basisAtTargetEPoints), numVertices_(numVertices) {}
45 KOKKOS_INLINE_FUNCTION
46 operator()(
const ordinal_type ic)
const {
47 for(ordinal_type iv=0; iv<numVertices_; ++iv) {
48 ordinal_type idof = tagToOrdinal_(0, iv, 0);
49 ordinal_type pt = targetEPointsRange_(0,iv).first;
51 basisCoeffs_(ic,idof) = targetAtTargetEPoints_(ic,pt)/basisAtTargetEPoints_(idof,pt,0);
57 template<
typename ViewType1,
typename ViewType2,
typename ViewType3,
58 typename ViewType4,
typename ViewType5>
60 const ViewType1 basisCoeffs_;
61 const ViewType1 negPartialProj_;
62 const ViewType1 basisDofDofAtBasisEPoints_;
63 const ViewType1 basisAtBasisEPoints_;
64 const ViewType2 basisEWeights_;
65 const ViewType1 wBasisDofAtBasisEPoints_;
66 const ViewType2 targetEWeights_;
67 const ViewType1 basisAtTargetEPoints_;
68 const ViewType1 wBasisDofAtTargetEPoints_;
69 const ViewType3 computedDofs_;
70 const ViewType4 tagToOrdinal_;
71 const ViewType5 targetAtTargetEPoints_;
72 const ViewType1 targetTanAtTargetEPoints_;
73 const ViewType1 refEdgesVec_;
74 ordinal_type fieldDim_;
75 ordinal_type edgeCardinality_;
76 ordinal_type offsetBasis_;
77 ordinal_type offsetTarget_;
78 ordinal_type numVertexDofs_;
79 ordinal_type edgeDim_;
83 const ViewType1 basisAtBasisEPoints,
const ViewType2 basisEWeights,
const ViewType1 wBasisDofAtBasisEPoints,
const ViewType2 targetEWeights,
84 const ViewType1 basisAtTargetEPoints,
const ViewType1 wBasisDofAtTargetEPoints,
const ViewType3 computedDofs,
const ViewType4 tagToOrdinal,
85 const ViewType5 targetAtTargetEPoints,
const ViewType1 targetTanAtTargetEPoints,
const ViewType1 refEdgesVec,
86 ordinal_type fieldDim, ordinal_type edgeCardinality, ordinal_type offsetBasis,
87 ordinal_type offsetTarget, ordinal_type numVertexDofs, ordinal_type edgeDim, ordinal_type iedge) :
88 basisCoeffs_(basisCoeffs), negPartialProj_(negPartialProj), basisDofDofAtBasisEPoints_(basisDofDofAtBasisEPoints),
89 basisAtBasisEPoints_(basisAtBasisEPoints), basisEWeights_(basisEWeights), wBasisDofAtBasisEPoints_(wBasisDofAtBasisEPoints), targetEWeights_(targetEWeights),
90 basisAtTargetEPoints_(basisAtTargetEPoints), wBasisDofAtTargetEPoints_(wBasisDofAtTargetEPoints),
91 computedDofs_(computedDofs), tagToOrdinal_(tagToOrdinal), targetAtTargetEPoints_(targetAtTargetEPoints),
92 targetTanAtTargetEPoints_(targetTanAtTargetEPoints), refEdgesVec_(refEdgesVec),
93 fieldDim_(fieldDim), edgeCardinality_(edgeCardinality), offsetBasis_(offsetBasis),
94 offsetTarget_(offsetTarget), numVertexDofs_(numVertexDofs), edgeDim_(edgeDim), iedge_(iedge)
98 KOKKOS_INLINE_FUNCTION
99 operator()(
const ordinal_type ic)
const {
100 for(ordinal_type j=0; j <edgeCardinality_; ++j) {
101 ordinal_type jdof =tagToOrdinal_(edgeDim_, iedge_, j);
102 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq) {
103 typename ViewType1::value_type tmp =0;
104 for(ordinal_type d=0; d <fieldDim_; ++d)
105 tmp += basisAtBasisEPoints_(jdof,offsetBasis_+iq,d)*refEdgesVec_(iedge_,d);
106 basisDofDofAtBasisEPoints_(0,j,iq) = tmp;
107 wBasisDofAtBasisEPoints_(ic,j,iq) = tmp*basisEWeights_(iq);
109 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
110 for(ordinal_type d=0; d <fieldDim_; ++d)
111 wBasisDofAtTargetEPoints_(ic,j,iq) += basisAtTargetEPoints_(jdof,offsetTarget_+iq,d)*refEdgesVec_(iedge_,d)*targetEWeights_(iq);
115 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq)
116 for(ordinal_type d=0; d <fieldDim_; ++d)
117 targetTanAtTargetEPoints_(ic,iq) += targetAtTargetEPoints_(ic,offsetTarget_+iq,d)*refEdgesVec_(iedge_,d);
119 for(ordinal_type j=0; j <numVertexDofs_; ++j) {
120 ordinal_type jdof = computedDofs_(j);
121 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq)
122 for(ordinal_type d=0; d <fieldDim_; ++d)
123 negPartialProj_(ic,iq) -= basisCoeffs_(ic,jdof)*basisAtBasisEPoints_(jdof,offsetBasis_+iq,d)*refEdgesVec_(iedge_,d);
128 template<
typename ViewType1,
typename ViewType2,
typename ViewType3,
129 typename ViewType4,
typename ViewType5>
131 const ViewType1 basisCoeffs_;
132 const ViewType1 negPartialProj_;
133 const ViewType1 faceBasisDofAtBasisEPoints_;
134 const ViewType1 basisAtBasisEPoints_;
135 const ViewType2 basisEWeights_;
136 const ViewType1 wBasisDofAtBasisEPoints_;
137 const ViewType2 targetEWeights_;
138 const ViewType1 basisAtTargetEPoints_;
139 const ViewType1 wBasisDofAtTargetEPoints_;
140 const ViewType3 computedDofs_;
141 const ViewType4 tagToOrdinal_;
142 const ViewType5 targetAtTargetEPoints_;
143 const ViewType1 targetDofAtTargetEPoints_;
144 const ViewType1 refSideNormal_;
145 ordinal_type fieldDim_;
146 ordinal_type faceCardinality_;
147 ordinal_type offsetBasis_;
148 ordinal_type offsetTarget_;
149 ordinal_type numVertexEdgeDofs_;
150 ordinal_type numFaces_;
151 ordinal_type faceDim_;
154 bool isHCurlBasis_, isHDivBasis_;
157 const ViewType1 basisAtBasisEPoints,
const ViewType2 basisEWeights,
const ViewType1 wBasisDofAtBasisEPoints,
const ViewType2 targetEWeights,
158 const ViewType1 basisAtTargetEPoints,
const ViewType1 wBasisDofAtTargetEPoints,
const ViewType3 computedDofs,
const ViewType4 tagToOrdinal,
159 const ViewType5 targetAtTargetEPoints,
const ViewType1 targetDofAtTargetEPoints,
160 const ViewType1 refSideNormal, ordinal_type fieldDim, ordinal_type faceCardinality, ordinal_type offsetBasis,
161 ordinal_type offsetTarget, ordinal_type numVertexEdgeDofs, ordinal_type numFaces, ordinal_type faceDim,
162 ordinal_type dim, ordinal_type iface,
bool isHCurlBasis,
bool isHDivBasis) :
163 basisCoeffs_(basisCoeffs), negPartialProj_(negPartialProj), faceBasisDofAtBasisEPoints_(faceBasisDofAtBasisEPoints),
164 basisAtBasisEPoints_(basisAtBasisEPoints), basisEWeights_(basisEWeights), wBasisDofAtBasisEPoints_(wBasisDofAtBasisEPoints), targetEWeights_(targetEWeights),
165 basisAtTargetEPoints_(basisAtTargetEPoints), wBasisDofAtTargetEPoints_(wBasisDofAtTargetEPoints),
166 computedDofs_(computedDofs), tagToOrdinal_(tagToOrdinal), targetAtTargetEPoints_(targetAtTargetEPoints),
167 targetDofAtTargetEPoints_(targetDofAtTargetEPoints), refSideNormal_(refSideNormal),
168 fieldDim_(fieldDim), faceCardinality_(faceCardinality), offsetBasis_(offsetBasis),
169 offsetTarget_(offsetTarget), numVertexEdgeDofs_(numVertexEdgeDofs), numFaces_(numFaces),
170 faceDim_(faceDim), dim_(dim), iface_(iface),
171 isHCurlBasis_(isHCurlBasis), isHDivBasis_(isHDivBasis)
175 KOKKOS_INLINE_FUNCTION
176 operator()(
const ordinal_type ic)
const {
180 typename ViewType1::value_type n[3] = {refSideNormal_(0), refSideNormal_(1), refSideNormal_(2)};
182 for(ordinal_type j=0; j <faceCardinality_; ++j) {
183 ordinal_type jdof = tagToOrdinal_(faceDim_, iface_, j);
184 for(ordinal_type d=0; d <fieldDim_; ++d) {
185 ordinal_type dp1 = (d+1) % dim_;
186 ordinal_type dp2 = (d+2) % dim_;
187 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq) {
189 faceBasisDofAtBasisEPoints_(0,j,iq,d) = basisAtBasisEPoints_(jdof,offsetBasis_+iq,dp1)*n[dp2] - basisAtBasisEPoints_(jdof,offsetBasis_+iq,dp2)*n[dp1];
191 wBasisDofAtBasisEPoints_(ic,j,iq,d) = faceBasisDofAtBasisEPoints_(0,j,iq,d) * basisEWeights_(iq);
193 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
195 wBasisDofAtTargetEPoints_(ic,j,iq,d) = (basisAtTargetEPoints_(jdof,offsetTarget_+iq,dp1)*n[dp2] - basisAtTargetEPoints_(jdof,offsetTarget_+iq,dp2)*n[dp1]) * targetEWeights_(iq);
200 for(ordinal_type d=0; d <fieldDim_; ++d) {
201 ordinal_type dp1 = (d+1) % dim_;
202 ordinal_type dp2 = (d+2) % dim_;
203 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
205 targetDofAtTargetEPoints_(ic,iq,d) = targetAtTargetEPoints_(ic,offsetTarget_+iq,dp1)*n[dp2] - targetAtTargetEPoints_(ic,offsetTarget_+iq,dp2)*n[dp1];
209 for(ordinal_type j=0; j <numVertexEdgeDofs_; ++j) {
210 ordinal_type jdof = computedDofs_(j);
211 for(ordinal_type d=0; d <fieldDim_; ++d) {
212 ordinal_type dp1 = (d+1) % dim_;
213 ordinal_type dp2 = (d+2) % dim_;
214 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq) {
216 negPartialProj_(ic,iq,d) -= (basisAtBasisEPoints_(jdof,offsetBasis_+iq,dp1)*n[dp2] - basisAtBasisEPoints_(jdof,offsetBasis_+iq,dp2)*n[dp1])*basisCoeffs_(ic,jdof);
221 typename ViewType1::value_type coeff[3] = {1,0,0};
223 for (ordinal_type d=0; d<3; d++)
224 coeff[d] = refSideNormal_(d);
227 for(ordinal_type j=0; j <faceCardinality_; ++j) {
228 ordinal_type jdof = tagToOrdinal_(faceDim_, iface_, j);
229 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq) {
230 typename ViewType1::value_type tmp =0;
231 for(ordinal_type d=0; d <fieldDim_; ++d)
232 tmp += coeff[d]*basisAtBasisEPoints_(jdof,offsetBasis_+iq,d);
233 faceBasisDofAtBasisEPoints_(0,j,iq,0) = tmp;
234 wBasisDofAtBasisEPoints_(ic,j,iq,0) = tmp * basisEWeights_(iq);
236 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
237 typename ViewType2::value_type sum=0;
238 for(ordinal_type d=0; d <fieldDim_; ++d)
239 sum += coeff[d]*basisAtTargetEPoints_(jdof,offsetTarget_+iq,d);
240 wBasisDofAtTargetEPoints_(ic,j,iq,0) = sum * targetEWeights_(iq);
244 for(ordinal_type d=0; d <fieldDim_; ++d)
245 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq)
246 targetDofAtTargetEPoints_(ic,iq,0) += coeff[d]*targetAtTargetEPoints_(ic,offsetTarget_+iq,d);
248 for(ordinal_type j=0; j <numVertexEdgeDofs_; ++j) {
249 ordinal_type jdof = computedDofs_(j);
250 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq)
251 for(ordinal_type d=0; d <fieldDim_; ++d)
252 negPartialProj_(ic,iq,0) -= basisCoeffs_(ic,jdof)*coeff[d]*basisAtBasisEPoints_(jdof,offsetBasis_+iq,d);
259 template<
typename ViewType1,
typename ViewType2,
typename ViewType3,
typename ViewType4>
261 const ViewType1 basisCoeffs_;
262 const ViewType1 negPartialProj_;
263 const ViewType1 internalBasisAtBasisEPoints_;
264 const ViewType1 basisAtBasisEPoints_;
265 const ViewType2 basisEWeights_;
266 const ViewType1 wBasisAtBasisEPoints_;
267 const ViewType2 targetEWeights_;
268 const ViewType1 basisAtTargetEPoints_;
269 const ViewType1 wBasisDofAtTargetEPoints_;
270 const ViewType3 computedDofs_;
271 const ViewType4 elemDof_;
272 ordinal_type fieldDim_;
273 ordinal_type numElemDofs_;
274 ordinal_type offsetBasis_;
275 ordinal_type offsetTarget_;
276 ordinal_type numVertexEdgeFaceDofs_;
279 const ViewType1 basisAtBasisEPoints,
const ViewType2 basisEWeights,
const ViewType1 wBasisAtBasisEPoints,
const ViewType2 targetEWeights,
280 const ViewType1 basisAtTargetEPoints,
const ViewType1 wBasisDofAtTargetEPoints,
const ViewType3 computedDofs,
const ViewType4 elemDof,
281 ordinal_type fieldDim, ordinal_type numElemDofs, ordinal_type offsetBasis, ordinal_type offsetTarget, ordinal_type numVertexEdgeFaceDofs) :
282 basisCoeffs_(basisCoeffs), negPartialProj_(negPartialProj), internalBasisAtBasisEPoints_(internalBasisAtBasisEPoints),
283 basisAtBasisEPoints_(basisAtBasisEPoints), basisEWeights_(basisEWeights), wBasisAtBasisEPoints_(wBasisAtBasisEPoints), targetEWeights_(targetEWeights),
284 basisAtTargetEPoints_(basisAtTargetEPoints), wBasisDofAtTargetEPoints_(wBasisDofAtTargetEPoints),
285 computedDofs_(computedDofs), elemDof_(elemDof), fieldDim_(fieldDim), numElemDofs_(numElemDofs), offsetBasis_(offsetBasis),
286 offsetTarget_(offsetTarget), numVertexEdgeFaceDofs_(numVertexEdgeFaceDofs) {}
289 KOKKOS_INLINE_FUNCTION
290 operator()(
const ordinal_type ic)
const {
292 for(ordinal_type j=0; j <numElemDofs_; ++j) {
293 ordinal_type idof = elemDof_(j);
294 for(ordinal_type d=0; d <fieldDim_; ++d) {
295 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq) {
296 internalBasisAtBasisEPoints_(0,j,iq,d) = basisAtBasisEPoints_(idof,offsetBasis_+iq,d);
297 wBasisAtBasisEPoints_(ic,j,iq,d) = internalBasisAtBasisEPoints_(0,j,iq,d) * basisEWeights_(iq);
299 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
300 wBasisDofAtTargetEPoints_(ic,j,iq,d) = basisAtTargetEPoints_(idof,offsetTarget_+iq,d)* targetEWeights_(iq);
304 for(ordinal_type j=0; j < numVertexEdgeFaceDofs_; ++j) {
305 ordinal_type jdof = computedDofs_(j);
306 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq)
307 for(ordinal_type d=0; d <fieldDim_; ++d) {
308 negPartialProj_(ic,iq,d) -= basisCoeffs_(ic,jdof)*basisAtBasisEPoints_(jdof,offsetBasis_+iq,d);
314 template<
typename ViewType1,
typename ViewType2>
316 const ViewType1 basisAtBasisEPoints_;
317 const ViewType2 basisEWeights_;
318 const ViewType1 wBasisAtBasisEPoints_;
319 const ViewType2 targetEWeights_;
320 const ViewType1 basisAtTargetEPoints_;
321 const ViewType1 wBasisDofAtTargetEPoints_;
322 ordinal_type fieldDim_;
323 ordinal_type numElemDofs_;
325 MultiplyBasisByWeights(
const ViewType1 basisAtBasisEPoints,
const ViewType2 basisEWeights,
const ViewType1 wBasisAtBasisEPoints,
const ViewType2 targetEWeights,
326 const ViewType1 basisAtTargetEPoints,
const ViewType1 wBasisDofAtTargetEPoints,
327 ordinal_type fieldDim, ordinal_type numElemDofs) :
328 basisAtBasisEPoints_(basisAtBasisEPoints), basisEWeights_(basisEWeights), wBasisAtBasisEPoints_(wBasisAtBasisEPoints), targetEWeights_(targetEWeights),
329 basisAtTargetEPoints_(basisAtTargetEPoints), wBasisDofAtTargetEPoints_(wBasisDofAtTargetEPoints),
330 fieldDim_(fieldDim), numElemDofs_(numElemDofs) {}
333 KOKKOS_INLINE_FUNCTION
334 operator()(
const ordinal_type ic)
const {
336 for(ordinal_type j=0; j <numElemDofs_; ++j) {
337 for(ordinal_type d=0; d <fieldDim_; ++d) {
338 for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq) {
339 wBasisAtBasisEPoints_(ic,j,iq,d) = basisAtBasisEPoints_(j,iq,d) * basisEWeights_(iq);
341 for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
342 wBasisDofAtTargetEPoints_(ic,j,iq,d) = basisAtTargetEPoints_(j,iq,d)* targetEWeights_(iq);
352 template<
typename DeviceType>
353 template<
typename basisCoeffsValueType,
class ...basisCoeffsProperties,
354 typename funValsValueType,
class ...funValsProperties,
356 typename ortValueType,
class ...ortProperties>
359 const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetAtTargetEPoints,
360 const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
361 const BasisType* cellBasis,
364 typedef typename BasisType::scalarType scalarType;
365 typedef Kokkos::DynRankView<scalarType,DeviceType> ScalarViewType;
366 typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
367 const auto cellTopo = cellBasis->getBaseCellTopology();
368 ordinal_type dim = cellTopo.getDimension();
369 ordinal_type basisCardinality = cellBasis->getCardinality();
370 ordinal_type numCells = targetAtTargetEPoints.extent(0);
371 const ordinal_type edgeDim = 1;
372 const ordinal_type faceDim = 2;
373 const ordinal_type fieldDim = (targetAtTargetEPoints.rank()==2) ? 1 : targetAtTargetEPoints.extent(2);
375 ordinal_type numVertices = (cellBasis->getDofCount(0, 0) > 0) ? cellTopo.getVertexCount() : 0;
376 ordinal_type numEdges = (cellBasis->getDofCount(1, 0) > 0) ? cellTopo.getEdgeCount() : 0;
377 ordinal_type numFaces = (cellBasis->getDofCount(2, 0) > 0) ? cellTopo.getFaceCount() : 0;
379 ScalarViewType refEdgesVec(
"refEdgesVec", numEdges, dim);
380 ScalarViewType refFacesTangents(
"refFaceTangents", numFaces, dim, 2);
381 ScalarViewType refFacesNormal(
"refFaceNormal", numFaces, dim);
383 ordinal_type numVertexDofs = numVertices;
385 ordinal_type numEdgeDofs(0);
386 for(ordinal_type ie=0; ie<numEdges; ++ie)
387 numEdgeDofs += cellBasis->getDofCount(edgeDim,ie);
389 ordinal_type numFaceDofs(0);
390 for(ordinal_type iface=0; iface<numFaces; ++iface)
391 numFaceDofs += cellBasis->getDofCount(faceDim,iface);
393 Kokkos::View<ordinal_type*, DeviceType> computedDofs(
"computedDofs", numVertexDofs+numEdgeDofs+numFaceDofs);
403 auto tagToOrdinal = Kokkos::create_mirror_view_and_copy(MemSpaceType(), cellBasis->getAllDofOrdinal());
405 ScalarViewType basisAtBasisEPoints(
"basisAtBasisEPoints",basisCardinality, numTotalBasisEPoints, fieldDim);
406 ScalarViewType basisAtTargetEPoints(
"basisAtTargetEPoints",basisCardinality, numTotalTargetEPoints, fieldDim);
409 cellBasis->getValues(Kokkos::subview(basisAtTargetEPoints, Kokkos::ALL(), Kokkos::ALL(), 0), targetEPoints);
410 cellBasis->getValues(Kokkos::subview(basisAtBasisEPoints, Kokkos::ALL(), Kokkos::ALL(), 0), basisEPoints);
413 cellBasis->getValues(basisAtTargetEPoints, targetEPoints);
414 cellBasis->getValues(basisAtBasisEPoints, basisEPoints);
419 auto hostComputedDofs = Kokkos::create_mirror_view(computedDofs);
420 ordinal_type computedDofsCount = 0;
421 for(ordinal_type iv=0; iv<numVertices; ++iv)
422 hostComputedDofs(computedDofsCount++) = cellBasis->getDofOrdinal(0, iv, 0);
424 for(ordinal_type ie=0; ie<numEdges; ++ie) {
425 ordinal_type edgeCardinality = cellBasis->getDofCount(edgeDim,ie);
426 for(ordinal_type i=0; i<edgeCardinality; ++i)
427 hostComputedDofs(computedDofsCount++) = cellBasis->getDofOrdinal(edgeDim, ie, i);
430 for(ordinal_type iface=0; iface<numFaces; ++iface) {
431 ordinal_type faceCardinality = cellBasis->getDofCount(faceDim,iface);
432 for(ordinal_type i=0; i<faceCardinality; ++i)
433 hostComputedDofs(computedDofsCount++) = cellBasis->getDofOrdinal(faceDim, iface, i);
435 Kokkos::deep_copy(computedDofs,hostComputedDofs);
438 bool isHGradBasis = (cellBasis->getFunctionSpace() == FUNCTION_SPACE_HGRAD);
439 bool isHCurlBasis = (cellBasis->getFunctionSpace() == FUNCTION_SPACE_HCURL);
440 bool isHDivBasis = (cellBasis->getFunctionSpace() == FUNCTION_SPACE_HDIV);
441 ordinal_type faceDofDim = isHCurlBasis ? 3 : 1;
442 ScalarViewType edgeCoeff(
"edgeCoeff", fieldDim);
445 const Kokkos::RangePolicy<ExecSpaceType> policy(0, numCells);
446 ScalarViewType refBasisCoeffs(
"refBasisCoeffs", basisCoeffs.extent(0), basisCoeffs.extent(1));
450 auto targetEPointsRange = Kokkos::create_mirror_view_and_copy(MemSpaceType(), projStruct->
getTargetPointsRange());
452 decltype(targetAtTargetEPoints)>;
453 Kokkos::parallel_for(policy, functorType(refBasisCoeffs, tagToOrdinal, targetEPointsRange,
454 targetAtTargetEPoints, basisAtTargetEPoints, numVertices));
458 for(ordinal_type ie=0; ie<numEdges; ++ie) {
459 auto edgeVec = Kokkos::subview(refEdgesVec, ie, Kokkos::ALL());
464 }
else if(isHDivBasis) {
467 deep_copy(edgeVec, 1.0);
470 ordinal_type edgeCardinality = cellBasis->getDofCount(edgeDim,ie);
471 ordinal_type numBasisEPoints = range_size(basisEPointsRange(edgeDim, ie));
472 ordinal_type numTargetEPoints = range_size(targetEPointsRange(edgeDim, ie));
474 ScalarViewType basisDofAtBasisEPoints(
"BasisDofAtBasisEPoints",1,edgeCardinality, numBasisEPoints);
475 ScalarViewType tragetDofAtTargetEPoints(
"TargetDofAtTargetEPoints",numCells, numTargetEPoints);
476 ScalarViewType weightedBasisAtBasisEPoints(
"weightedTanBasisAtBasisEPoints",numCells,edgeCardinality, numBasisEPoints);
477 ScalarViewType weightedBasisAtTargetEPoints(
"weightedTanBasisAtTargetEPoints",numCells,edgeCardinality, numTargetEPoints);
478 ScalarViewType negPartialProj(
"negPartialProj", numCells, numBasisEPoints);
480 auto targetEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getTargetEvalWeights(edgeDim,ie));
481 auto basisEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getBasisEvalWeights(edgeDim,ie));
484 ordinal_type offsetBasis = basisEPointsRange(edgeDim, ie).first;
485 ordinal_type offsetTarget = targetEPointsRange(edgeDim, ie).first;
489 decltype(computedDofs), decltype(tagToOrdinal), decltype(targetAtTargetEPoints)>;
491 Kokkos::parallel_for(policy, functorTypeEdge(refBasisCoeffs, negPartialProj, basisDofAtBasisEPoints,
492 basisAtBasisEPoints, basisEWeights, weightedBasisAtBasisEPoints, targetEWeights,
493 basisAtTargetEPoints, weightedBasisAtTargetEPoints, computedDofs, tagToOrdinal,
494 targetAtTargetEPoints,tragetDofAtTargetEPoints, refEdgesVec, fieldDim,
495 edgeCardinality, offsetBasis, offsetTarget, numVertexDofs, edgeDim, ie));
498 ScalarViewType edgeMassMat_(
"edgeMassMat_", 1, edgeCardinality, edgeCardinality),
499 edgeRhsMat_(
"rhsMat_", numCells, edgeCardinality);
506 typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
507 ScalarViewType t_(
"t",numCells, edgeCardinality);
508 WorkArrayViewType w_(
"w",numCells, edgeCardinality);
510 auto edgeDof = Kokkos::subview(tagToOrdinal, edgeDim, ie, Kokkos::ALL());
513 edgeSystem.
solve(refBasisCoeffs, edgeMassMat_, edgeRhsMat_, t_, w_, edgeDof, edgeCardinality);
516 for(ordinal_type iface=0; iface<numFaces; ++iface) {
517 ordinal_type faceCardinality = cellBasis->getDofCount(faceDim,iface);
519 ordinal_type numTargetEPoints = range_size(targetEPointsRange(faceDim, iface));
520 ordinal_type numBasisEPoints = range_size(basisEPointsRange(faceDim, iface));
522 ScalarViewType faceBasisDofAtBasisEPoints(
"faceBasisDofAtBasisEPoints",1,faceCardinality, numBasisEPoints,faceDofDim);
523 ScalarViewType wBasisDofAtBasisEPoints(
"weightedBasisDofAtBasisEPoints",numCells,faceCardinality, numBasisEPoints,faceDofDim);
525 ScalarViewType faceBasisAtTargetEPoints(
"faceBasisDofAtTargetEPoints",numCells,faceCardinality, numTargetEPoints,faceDofDim);
526 ScalarViewType wBasisDofAtTargetEPoints(
"weightedBasisDofAtTargetEPoints",numCells,faceCardinality, numTargetEPoints,faceDofDim);
528 ScalarViewType targetDofAtTargetEPoints(
"targetDofAtTargetEPoints",numCells, numTargetEPoints,faceDofDim);
529 ScalarViewType negPartialProj(
"negComputedProjection", numCells,numBasisEPoints,faceDofDim);
531 ordinal_type offsetBasis = basisEPointsRange(faceDim, iface).first;
532 ordinal_type offsetTarget = targetEPointsRange(faceDim, iface).first;
533 auto targetEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getTargetEvalWeights(faceDim,iface));
534 auto basisEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getBasisEvalWeights(faceDim,iface));
536 ScalarViewType refSideNormal(
"refSideNormal", dim);
540 decltype(computedDofs), decltype(tagToOrdinal), decltype(targetAtTargetEPoints)>;
542 Kokkos::parallel_for(policy, functorTypeFace(refBasisCoeffs, negPartialProj,faceBasisDofAtBasisEPoints,
543 basisAtBasisEPoints, basisEWeights, wBasisDofAtBasisEPoints, targetEWeights,
544 basisAtTargetEPoints, wBasisDofAtTargetEPoints, computedDofs, tagToOrdinal,
545 targetAtTargetEPoints,targetDofAtTargetEPoints,
546 refSideNormal, fieldDim, faceCardinality, offsetBasis,
547 offsetTarget, numVertexDofs+numEdgeDofs, numFaces, faceDim,
548 dim, iface, isHCurlBasis, isHDivBasis));
550 typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
551 ScalarViewType faceMassMat_(
"faceMassMat_", 1, faceCardinality, faceCardinality),
552 faceRhsMat_(
"rhsMat_", numCells, faceCardinality);
558 ScalarViewType t_(
"t",numCells, faceCardinality);
559 WorkArrayViewType w_(
"w",numCells,faceCardinality);
561 auto faceDof = Kokkos::subview(tagToOrdinal, faceDim, iface, Kokkos::ALL());
564 faceSystem.
solve(refBasisCoeffs, faceMassMat_, faceRhsMat_, t_, w_, faceDof, faceCardinality);
567 ordinal_type numElemDofs = cellBasis->getDofCount(dim,0);
572 auto cellDofs = Kokkos::subview(tagToOrdinal, dim, 0, Kokkos::ALL());
574 range_type cellPointsRange = targetEPointsRange(dim, 0);
576 ordinal_type numTargetEPoints = range_size(targetEPointsRange(dim,0));
577 ordinal_type numBasisEPoints = range_size(basisEPointsRange(dim,0));
579 ScalarViewType internalBasisAtBasisEPoints(
"internalBasisAtBasisEPoints",1,numElemDofs, numBasisEPoints, fieldDim);
580 ScalarViewType negPartialProj(
"negPartialProj", numCells, numBasisEPoints, fieldDim);
582 auto targetEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getTargetEvalWeights(dim,0));
583 auto basisEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getBasisEvalWeights(dim,0));
584 ordinal_type offsetBasis = basisEPointsRange(dim, 0).first;
585 ordinal_type offsetTarget = targetEPointsRange(dim, 0).first;
587 ScalarViewType wBasisAtBasisEPoints(
"weightedBasisAtBasisEPoints",numCells,numElemDofs, numBasisEPoints,fieldDim);
588 ScalarViewType wBasisDofAtTargetEPoints(
"weightedBasisAtTargetEPoints",numCells,numElemDofs, numTargetEPoints,fieldDim);
591 Kokkos::parallel_for(policy, functorType( refBasisCoeffs, negPartialProj, internalBasisAtBasisEPoints,
592 basisAtBasisEPoints, basisEWeights, wBasisAtBasisEPoints, targetEWeights, basisAtTargetEPoints, wBasisDofAtTargetEPoints,
593 computedDofs, cellDofs, fieldDim, numElemDofs, offsetBasis, offsetTarget, numVertexDofs+numEdgeDofs+numFaceDofs));
595 typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
596 ScalarViewType cellMassMat_(
"cellMassMat_", 1, numElemDofs, numElemDofs),
597 cellRhsMat_(
"rhsMat_", numCells, numElemDofs);
602 Kokkos::subview(wBasisDofAtTargetEPoints,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL(),0));
607 ScalarViewType t_(
"t",numCells, numElemDofs);
608 WorkArrayViewType w_(
"w",numCells,numElemDofs);
610 cellSystem.
solve(refBasisCoeffs, cellMassMat_, cellRhsMat_, t_, w_, cellDofs, numElemDofs);
617 template<
typename DeviceType>
618 template<
typename basisCoeffsValueType,
class ...basisCoeffsProperties,
619 typename funValsValueType,
class ...funValsProperties,
621 typename ortValueType,
class ...ortProperties>
624 const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetAtTargetEPoints,
625 const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
626 const BasisType* cellBasis,
629 Kokkos::DynRankView<typename BasisType::scalarType,DeviceType> refBasisCoeffs(
"refBasisCoeffs", basisCoeffs.extent(0), basisCoeffs.extent(1));
630 getL2DGBasisCoeffs(refBasisCoeffs, targetAtTargetEPoints, cellBasis, projStruct);
636 template<
typename DeviceType>
637 template<
typename basisViewType,
typename targetViewType,
typename BasisType>
640 const targetViewType targetAtTargetEPoints,
641 const BasisType* cellBasis,
644 typedef typename BasisType::scalarType scalarType;
645 typedef Kokkos::DynRankView<scalarType,DeviceType> ScalarViewType;
646 const auto cellTopo = cellBasis->getBaseCellTopology();
648 ordinal_type dim = cellTopo.getDimension();
650 auto basisEPoints = Kokkos::create_mirror_view_and_copy(MemSpaceType(),
652 auto targetEPoints = Kokkos::create_mirror_view_and_copy(MemSpaceType(),
655 ordinal_type numTotalTargetEPoints(targetAtTargetEPoints.extent(1));
656 ordinal_type basisCardinality = cellBasis->getCardinality();
657 ordinal_type numCells = targetAtTargetEPoints.extent(0);
658 const ordinal_type fieldDim = (targetAtTargetEPoints.rank()==2) ? 1 : targetAtTargetEPoints.extent(2);
661 ScalarViewType basisAtBasisEPoints(
"basisAtBasisEPoints",1,basisCardinality, numTotalBasisEPoints, fieldDim);
662 ScalarViewType basisAtTargetEPoints(
"basisAtTargetEPoints",basisCardinality, numTotalTargetEPoints, fieldDim);
665 cellBasis->getValues(Kokkos::subview(basisAtTargetEPoints,Kokkos::ALL(),Kokkos::ALL(),0), targetEPoints);
666 cellBasis->getValues(Kokkos::subview(basisAtBasisEPoints,0,Kokkos::ALL(),Kokkos::ALL(),0), basisEPoints);
669 cellBasis->getValues(basisAtTargetEPoints, targetEPoints);
670 cellBasis->getValues(Kokkos::subview(basisAtBasisEPoints,0,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL()), basisEPoints);
674 const Kokkos::RangePolicy<ExecSpaceType> policy(0, numCells);
675 ordinal_type numElemDofs = cellBasis->getCardinality();
677 auto targetEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getTargetEvalWeights(dim,0));
678 auto basisEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->
getBasisEvalWeights(dim,0));
680 ScalarViewType wBasisAtBasisEPoints(
"weightedBasisAtBasisEPoints",1,numElemDofs, numTotalBasisEPoints,fieldDim);
681 ScalarViewType wBasisDofAtTargetEPoints(
"weightedBasisAtTargetEPoints",numCells,numElemDofs, numTotalTargetEPoints,fieldDim);
682 Kokkos::DynRankView<ordinal_type, DeviceType> cellDofs(
"cellDoFs", numElemDofs);
684 Kokkos::parallel_for(Kokkos::RangePolicy<ExecSpaceType>(0,numElemDofs),
685 KOKKOS_LAMBDA (
const int &j) {
686 for(ordinal_type d=0; d <fieldDim; ++d) {
687 for(ordinal_type iq=0; iq < numTotalBasisEPoints; ++iq)
688 wBasisAtBasisEPoints(0,j,iq,d) = basisAtBasisEPoints(0,j,iq,d) * basisEWeights(iq);
689 for(ordinal_type iq=0; iq <numTotalTargetEPoints; ++iq) {
690 wBasisDofAtTargetEPoints(0,j,iq,d) = basisAtTargetEPoints(j,iq,d)* targetEWeights(iq);
697 typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
698 ScalarViewType cellMassMat_(
"cellMassMat_", 1, numElemDofs, numElemDofs),
699 cellRhsMat_(
"rhsMat_", numCells, numElemDofs);
704 Kokkos::subview(wBasisDofAtTargetEPoints,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL(),0));
708 ScalarViewType t_(
"t",1, numElemDofs);
709 WorkArrayViewType w_(
"w",numCells,numElemDofs);
711 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...