15 #ifndef Intrepid2_HierarchicalBasis_HDIV_TET_h
16 #define Intrepid2_HierarchicalBasis_HDIV_TET_h
18 #include <Kokkos_DynRankView.hpp>
20 #include <Intrepid2_config.h>
34 template<
class DeviceType,
class OutputScalar,
class PointScalar,
35 class OutputFieldType,
class InputPointsType>
38 using ExecutionSpace =
typename DeviceType::execution_space;
39 using ScratchSpace =
typename ExecutionSpace::scratch_memory_space;
40 using OutputScratchView = Kokkos::View<OutputScalar*,ScratchSpace,Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
41 using PointScratchView = Kokkos::View<PointScalar*, ScratchSpace,Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
43 using TeamPolicy = Kokkos::TeamPolicy<ExecutionSpace>;
44 using TeamMember =
typename TeamPolicy::member_type;
48 OutputFieldType output_;
49 InputPointsType inputPoints_;
51 ordinal_type polyOrder_;
52 ordinal_type numFields_, numPoints_;
54 size_t fad_size_output_;
56 static constexpr ordinal_type numVertices = 4;
57 static constexpr ordinal_type numFaces = 4;
58 static constexpr ordinal_type numVerticesPerFace = 3;
59 static constexpr ordinal_type numInteriorFamilies = 3;
62 const ordinal_type face_vertices[numFaces*numVerticesPerFace] = {0,1,2,
68 const ordinal_type numFaceFunctionsPerFace_;
69 const ordinal_type numFaceFunctions_;
70 const ordinal_type numInteriorFunctionsPerFamily_;
71 const ordinal_type numInteriorFunctions_;
74 const ordinal_type faceOrdinalForInterior_[numInteriorFamilies] = {0,2,3};
75 const ordinal_type faceFamilyForInterior_[numInteriorFamilies] = {0,0,1};
76 const ordinal_type interiorCoordinateOrdinal_[numInteriorFamilies] = {3,0,1};
79 const ordinal_type interior_face_family_start_ [numInteriorFamilies] = {0,0,1};
80 const ordinal_type interior_face_family_middle_[numInteriorFamilies] = {1,1,2};
81 const ordinal_type interior_face_family_end_ [numInteriorFamilies] = {2,2,0};
83 KOKKOS_INLINE_FUNCTION
84 ordinal_type dofOrdinalForFace(
const ordinal_type &faceOrdinal,
85 const ordinal_type &zeroBasedFaceFamily,
86 const ordinal_type &i,
87 const ordinal_type &j)
const
90 const ordinal_type faceDofOffset = faceOrdinal * numFaceFunctionsPerFace_;
96 const ordinal_type max_ij_sum = polyOrder_ - 1;
98 ordinal_type fieldOrdinal = faceDofOffset + zeroBasedFaceFamily;
100 for (ordinal_type ij_sum=1; ij_sum <= max_ij_sum; ij_sum++)
102 for (ordinal_type ii=0; ii<ij_sum; ii++)
105 const ordinal_type jj = ij_sum - ii;
106 if ( (ii == i) && (jj == j))
118 : opType_(opType), output_(output), inputPoints_(inputPoints),
119 polyOrder_(polyOrder),
120 fad_size_output_(getScalarDimensionForView(output)),
121 numFaceFunctionsPerFace_(polyOrder * (polyOrder+1)/2),
122 numFaceFunctions_(numFaceFunctionsPerFace_*numFaces),
123 numInteriorFunctionsPerFamily_((polyOrder-1)*polyOrder*(polyOrder+1)/6),
124 numInteriorFunctions_(numInteriorFunctionsPerFamily_ * numInteriorFamilies)
126 numFields_ = output.extent_int(0);
127 numPoints_ = output.extent_int(1);
129 const ordinal_type expectedCardinality = numFaceFunctions_ + numInteriorFunctions_;
135 INTREPID2_TEST_FOR_EXCEPTION(numPoints_ != inputPoints.extent_int(0), std::invalid_argument,
"point counts need to match!");
136 INTREPID2_TEST_FOR_EXCEPTION(numFields_ != expectedCardinality, std::invalid_argument,
"output field size does not match basis cardinality");
139 KOKKOS_INLINE_FUNCTION
140 void computeFaceJacobi(OutputScratchView &P_2ip1,
141 const ordinal_type &zeroBasedFaceOrdinal,
142 const ordinal_type &i,
143 const PointScalar* lambda)
const
146 const auto &s0_index = face_vertices[zeroBasedFaceOrdinal * numVerticesPerFace + 0];
147 const auto &s1_index = face_vertices[zeroBasedFaceOrdinal * numVerticesPerFace + 1];
148 const auto &s2_index = face_vertices[zeroBasedFaceOrdinal * numVerticesPerFace + 2];
150 const auto & s0 = lambda[s0_index];
151 const auto & s1 = lambda[s1_index];
152 const auto & s2 = lambda[s2_index];
153 const PointScalar jacobiScaling = s0 + s1 + s2;
155 const double alpha = i*2.0 + 1;
156 Polynomials::shiftedScaledJacobiValues(P_2ip1, alpha, polyOrder_-1, s2, jacobiScaling);
160 KOKKOS_INLINE_FUNCTION
162 const ordinal_type &zeroBasedInteriorFamilyOrdinal,
163 const ordinal_type &i,
164 const PointScalar* lambda)
const
166 const ordinal_type & relatedFaceOrdinal = faceOrdinalForInterior_[zeroBasedInteriorFamilyOrdinal];
167 const auto &s0_vertex_number = interior_face_family_start_ [zeroBasedInteriorFamilyOrdinal];
168 const auto &s1_vertex_number = interior_face_family_middle_[zeroBasedInteriorFamilyOrdinal];
169 const auto &s2_vertex_number = interior_face_family_end_ [zeroBasedInteriorFamilyOrdinal];
172 const auto &s0_index = face_vertices[relatedFaceOrdinal * numVerticesPerFace + s0_vertex_number];
173 const auto &s1_index = face_vertices[relatedFaceOrdinal * numVerticesPerFace + s1_vertex_number];
174 const auto &s2_index = face_vertices[relatedFaceOrdinal * numVerticesPerFace + s2_vertex_number];
176 const auto & s0 = lambda[s0_index];
177 const auto & s1 = lambda[s1_index];
178 const auto & s2 = lambda[s2_index];
179 const PointScalar jacobiScaling = s0 + s1 + s2;
181 const double alpha = i*2.0 + 1;
182 Polynomials::shiftedScaledJacobiValues(P_2ip1, alpha, polyOrder_-1, s2, jacobiScaling);
185 KOKKOS_INLINE_FUNCTION
186 void computeFaceLegendre(OutputScratchView &P,
187 const ordinal_type &zeroBasedFaceOrdinal,
188 const PointScalar* lambda)
const
191 const auto &s0_index = face_vertices[zeroBasedFaceOrdinal * numVerticesPerFace + 0];
192 const auto &s1_index = face_vertices[zeroBasedFaceOrdinal * numVerticesPerFace + 1];
194 const auto & s0 = lambda[s0_index];
195 const auto & s1 = lambda[s1_index];
196 const PointScalar legendreScaling = s0 + s1;
198 Polynomials::shiftedScaledLegendreValues(P, polyOrder_-1, s1, legendreScaling);
201 KOKKOS_INLINE_FUNCTION
202 void computeFaceLegendreForInterior(OutputScratchView &P,
203 const ordinal_type &zeroBasedInteriorFamilyOrdinal,
204 const PointScalar* lambda)
const
206 const ordinal_type & relatedFaceOrdinal = faceOrdinalForInterior_[zeroBasedInteriorFamilyOrdinal];
207 const auto &s0_vertex_number = interior_face_family_start_ [zeroBasedInteriorFamilyOrdinal];
208 const auto &s1_vertex_number = interior_face_family_middle_[zeroBasedInteriorFamilyOrdinal];
211 const auto &s0_index = face_vertices[relatedFaceOrdinal * numVerticesPerFace + s0_vertex_number];
212 const auto &s1_index = face_vertices[relatedFaceOrdinal * numVerticesPerFace + s1_vertex_number];
214 const auto & s0 = lambda[s0_index];
215 const auto & s1 = lambda[s1_index];
216 const PointScalar legendreScaling = s0 + s1;
218 Polynomials::shiftedScaledLegendreValues(P, polyOrder_-1, s1, legendreScaling);
221 KOKKOS_INLINE_FUNCTION
222 void computeFaceVectorWeight(OutputScalar &vectorWeight_x,
223 OutputScalar &vectorWeight_y,
224 OutputScalar &vectorWeight_z,
225 const ordinal_type &zeroBasedFaceOrdinal,
226 const PointScalar* lambda,
227 const PointScalar* lambda_dx,
228 const PointScalar* lambda_dy,
229 const PointScalar* lambda_dz)
const
233 const auto &s0_index = face_vertices[zeroBasedFaceOrdinal * numVerticesPerFace + 0];
234 const auto &s1_index = face_vertices[zeroBasedFaceOrdinal * numVerticesPerFace + 1];
235 const auto &s2_index = face_vertices[zeroBasedFaceOrdinal * numVerticesPerFace + 2];
237 const auto & s0 = lambda [s0_index];
238 const auto & s0_dx = lambda_dx[s0_index];
239 const auto & s0_dy = lambda_dy[s0_index];
240 const auto & s0_dz = lambda_dz[s0_index];
242 const auto & s1 = lambda [s1_index];
243 const auto & s1_dx = lambda_dx[s1_index];
244 const auto & s1_dy = lambda_dy[s1_index];
245 const auto & s1_dz = lambda_dz[s1_index];
247 const auto & s2 = lambda [s2_index];
248 const auto & s2_dx = lambda_dx[s2_index];
249 const auto & s2_dy = lambda_dy[s2_index];
250 const auto & s2_dz = lambda_dz[s2_index];
252 vectorWeight_x = s0 * (s1_dy * s2_dz - s1_dz * s2_dy)
253 + s1 * (s2_dy * s0_dz - s2_dz * s0_dy)
254 + s2 * (s0_dy * s1_dz - s0_dz * s1_dy);
256 vectorWeight_y = s0 * (s1_dz * s2_dx - s1_dx * s2_dz)
257 + s1 * (s2_dz * s0_dx - s2_dx * s0_dz)
258 + s2 * (s0_dz * s1_dx - s0_dx * s1_dz);
260 vectorWeight_z = s0 * (s1_dx * s2_dy - s1_dy * s2_dx)
261 + s1 * (s2_dx * s0_dy - s2_dy * s0_dx)
262 + s2 * (s0_dx * s1_dy - s0_dy * s1_dx);
266 KOKKOS_INLINE_FUNCTION
267 void faceFunctionValue(OutputScalar &value_x,
268 OutputScalar &value_y,
269 OutputScalar &value_z,
270 const ordinal_type &i,
271 const ordinal_type &j,
272 const OutputScratchView &P,
273 const OutputScratchView &P_2ip1,
274 const OutputScalar &vectorWeight_x,
275 const OutputScalar &vectorWeight_y,
276 const OutputScalar &vectorWeight_z,
277 const PointScalar* lambda)
const
279 const auto &P_i = P(i);
280 const auto &P_2ip1_j = P_2ip1(j);
282 value_x = P_i * P_2ip1_j * vectorWeight_x;
283 value_y = P_i * P_2ip1_j * vectorWeight_y;
284 value_z = P_i * P_2ip1_j * vectorWeight_z;
287 KOKKOS_INLINE_FUNCTION
288 void computeFaceDivWeight(OutputScalar &divWeight,
289 const ordinal_type &zeroBasedFaceOrdinal,
290 const PointScalar* lambda_dx,
291 const PointScalar* lambda_dy,
292 const PointScalar* lambda_dz)
const
296 const auto &s0_index = face_vertices[zeroBasedFaceOrdinal * numVerticesPerFace + 0];
297 const auto &s1_index = face_vertices[zeroBasedFaceOrdinal * numVerticesPerFace + 1];
298 const auto &s2_index = face_vertices[zeroBasedFaceOrdinal * numVerticesPerFace + 2];
300 const auto & s0_dx = lambda_dx[s0_index];
301 const auto & s0_dy = lambda_dy[s0_index];
302 const auto & s0_dz = lambda_dz[s0_index];
304 const auto & s1_dx = lambda_dx[s1_index];
305 const auto & s1_dy = lambda_dy[s1_index];
306 const auto & s1_dz = lambda_dz[s1_index];
308 const auto & s2_dx = lambda_dx[s2_index];
309 const auto & s2_dy = lambda_dy[s2_index];
310 const auto & s2_dz = lambda_dz[s2_index];
312 divWeight = s0_dx * (s1_dy * s2_dz - s1_dz * s2_dy)
313 + s0_dy * (s1_dz * s2_dx - s1_dx * s2_dz)
314 + s0_dz * (s1_dx * s2_dy - s1_dy * s2_dx);
317 KOKKOS_INLINE_FUNCTION
318 void computeInteriorIntegratedJacobi(OutputScratchView &L_2ipjp1,
319 const ordinal_type &i,
320 const ordinal_type &j,
321 const ordinal_type &zeroBasedFamilyOrdinal,
322 const PointScalar* lambda)
const
324 const auto &lambda_m = lambda[interiorCoordinateOrdinal_[zeroBasedFamilyOrdinal]];
326 const double alpha = 2 * (i + j + 1);
328 const PointScalar jacobiScaling = 1.0;
329 Polynomials::shiftedScaledIntegratedJacobiValues(L_2ipjp1, alpha, polyOrder_-1, lambda_m, jacobiScaling);
332 KOKKOS_INLINE_FUNCTION
333 void computeInteriorJacobi(OutputScratchView &P_2ipjp1,
334 const ordinal_type &i,
335 const ordinal_type &j,
336 const ordinal_type &zeroBasedFamilyOrdinal,
337 const PointScalar* lambda)
const
339 const auto &lambda_m = lambda[interiorCoordinateOrdinal_[zeroBasedFamilyOrdinal]];
341 const double alpha = 2 * (i + j + 1);
343 const PointScalar jacobiScaling = 1.0;
344 Polynomials::shiftedScaledJacobiValues(P_2ipjp1, alpha, polyOrder_-1, lambda_m, jacobiScaling);
348 KOKKOS_INLINE_FUNCTION
349 void faceFunctionDiv(OutputScalar &divValue,
350 const ordinal_type &i,
351 const ordinal_type &j,
352 const OutputScratchView &P,
353 const OutputScratchView &P_2ip1,
354 const OutputScalar &divWeight,
355 const PointScalar* lambda)
const
357 const auto &P_i = P(i);
358 const auto &P_2ip1_j = P_2ip1(j);
360 divValue = (i + j + 3.) * P_i * P_2ip1_j * divWeight;
364 KOKKOS_INLINE_FUNCTION
365 void gradInteriorIntegratedJacobi(OutputScalar &L_2ipjp1_dx,
366 OutputScalar &L_2ipjp1_dy,
367 OutputScalar &L_2ipjp1_dz,
368 const ordinal_type &zeroBasedFamilyOrdinal,
369 const ordinal_type &j,
370 const ordinal_type &k,
371 const OutputScratchView &P_2ipjp1,
372 const PointScalar* lambda,
373 const PointScalar* lambda_dx,
374 const PointScalar* lambda_dy,
375 const PointScalar* lambda_dz)
const
380 const ordinal_type &m = interiorCoordinateOrdinal_[zeroBasedFamilyOrdinal];
382 L_2ipjp1_dx = P_2ipjp1(k-1) * lambda_dx[m];
383 L_2ipjp1_dy = P_2ipjp1(k-1) * lambda_dy[m];
384 L_2ipjp1_dz = P_2ipjp1(k-1) * lambda_dz[m];
387 KOKKOS_INLINE_FUNCTION
388 void interiorFunctionDiv(OutputScalar &outputDiv,
389 OutputScalar &L_2ipjp1_k,
390 OutputScalar &faceDiv,
391 OutputScalar &L_2ipjp1_k_dx,
392 OutputScalar &L_2ipjp1_k_dy,
393 OutputScalar &L_2ipjp1_k_dz,
394 OutputScalar &faceValue_x,
395 OutputScalar &faceValue_y,
396 OutputScalar &faceValue_z)
const
398 outputDiv = L_2ipjp1_k * faceDiv + L_2ipjp1_k_dx * faceValue_x + L_2ipjp1_k_dy * faceValue_y + L_2ipjp1_k_dz * faceValue_z;
401 KOKKOS_INLINE_FUNCTION
402 void operator()(
const TeamMember &teamMember)
const {
403 auto pointOrdinal = teamMember.league_rank();
404 OutputScratchView scratch0, scratch1, scratch2, scratch3;
405 if (fad_size_output_ > 0) {
406 scratch0 = OutputScratchView(teamMember.team_shmem(), polyOrder_, fad_size_output_);
407 scratch1 = OutputScratchView(teamMember.team_shmem(), polyOrder_, fad_size_output_);
408 scratch2 = OutputScratchView(teamMember.team_shmem(), polyOrder_, fad_size_output_);
409 scratch3 = OutputScratchView(teamMember.team_shmem(), polyOrder_, fad_size_output_);
412 scratch0 = OutputScratchView(teamMember.team_shmem(), polyOrder_);
413 scratch1 = OutputScratchView(teamMember.team_shmem(), polyOrder_);
414 scratch2 = OutputScratchView(teamMember.team_shmem(), polyOrder_);
415 scratch3 = OutputScratchView(teamMember.team_shmem(), polyOrder_);
418 const auto & x = inputPoints_(pointOrdinal,0);
419 const auto & y = inputPoints_(pointOrdinal,1);
420 const auto & z = inputPoints_(pointOrdinal,2);
423 const PointScalar lambda[4] = {1. - x - y - z, x, y, z};
424 const PointScalar lambda_dx[4] = {-1., 1., 0., 0.};
425 const PointScalar lambda_dy[4] = {-1., 0., 1., 0.};
426 const PointScalar lambda_dz[4] = {-1., 0., 0., 1.};
435 auto &scratchP = scratch0;
436 auto &scratchP_2ip1 = scratch1;
438 const ordinal_type max_ij_sum = polyOrder_ - 1;
440 for (ordinal_type faceOrdinal=0; faceOrdinal<numFaces; faceOrdinal++)
442 OutputScalar divWeight;
443 computeFaceDivWeight(divWeight, faceOrdinal, lambda_dx, lambda_dy, lambda_dz);
445 OutputScalar vectorWeight_x, vectorWeight_y, vectorWeight_z;
446 computeFaceVectorWeight(vectorWeight_x, vectorWeight_y, vectorWeight_z, faceOrdinal, lambda, lambda_dx, lambda_dy, lambda_dz);
448 ordinal_type fieldOrdinal = faceOrdinal * numFaceFunctionsPerFace_;
449 computeFaceLegendre(scratchP, faceOrdinal, lambda);
451 for (
int ij_sum=0; ij_sum <= max_ij_sum; ij_sum++)
453 for (
int i=0; i<=ij_sum; i++)
455 computeFaceJacobi(scratchP_2ip1, faceOrdinal, i, lambda);
457 const int j = ij_sum - i;
459 auto & output_x = output_(fieldOrdinal,pointOrdinal,0);
460 auto & output_y = output_(fieldOrdinal,pointOrdinal,1);
461 auto & output_z = output_(fieldOrdinal,pointOrdinal,2);
463 faceFunctionValue(output_x, output_y, output_z, i, j,
464 scratchP, scratchP_2ip1, vectorWeight_x,
465 vectorWeight_y, vectorWeight_z, lambda);
476 auto &scratchP = scratch0;
477 auto &scratchP_2ip1 = scratch1;
478 auto &scratchL_2ipjp1 = scratch2;
480 const ordinal_type min_ijk_sum = 1;
481 const ordinal_type max_ijk_sum = polyOrder_-1;
482 const ordinal_type min_ij_sum = 0;
483 const ordinal_type min_k = 1;
484 const ordinal_type min_j = 0;
485 const ordinal_type min_i = 0;
487 OutputScalar vectorWeight_x, vectorWeight_y, vectorWeight_z;
489 for (
int interiorFamilyOrdinal=1; interiorFamilyOrdinal<=numInteriorFamilies; interiorFamilyOrdinal++)
493 ordinal_type interiorFamilyFieldOrdinal =
494 numFaceFunctions_ + interiorFamilyOrdinal - 1;
496 const ordinal_type relatedFaceOrdinal = faceOrdinalForInterior_[interiorFamilyOrdinal-1];
498 computeFaceLegendreForInterior(scratchP,
499 interiorFamilyOrdinal - 1, lambda);
500 computeFaceVectorWeight(vectorWeight_x, vectorWeight_y, vectorWeight_z, relatedFaceOrdinal, lambda, lambda_dx, lambda_dy, lambda_dz);
502 for (
int ijk_sum=min_ijk_sum; ijk_sum <= max_ijk_sum; ijk_sum++)
504 for (
int ij_sum=min_ij_sum; ij_sum<=ijk_sum-min_k; ij_sum++)
506 for (
int i=min_i; i<=ij_sum-min_j; i++)
508 const ordinal_type j = ij_sum-i;
509 const ordinal_type k = ijk_sum - ij_sum;
512 scratchP_2ip1, interiorFamilyOrdinal - 1, i, lambda);
513 computeInteriorIntegratedJacobi(scratchL_2ipjp1, i, j,
514 interiorFamilyOrdinal - 1,
517 OutputScalar V_x, V_y, V_z;
519 faceFunctionValue(V_x, V_y, V_z, i, j, scratchP,
520 scratchP_2ip1, vectorWeight_x,
521 vectorWeight_y, vectorWeight_z, lambda);
524 output_(interiorFamilyFieldOrdinal, pointOrdinal, 0);
526 output_(interiorFamilyFieldOrdinal, pointOrdinal, 1);
528 output_(interiorFamilyFieldOrdinal, pointOrdinal, 2);
530 output_x = V_x * scratchL_2ipjp1(k);
531 output_y = V_y * scratchL_2ipjp1(k);
532 output_z = V_z * scratchL_2ipjp1(k);
534 interiorFamilyFieldOrdinal +=
548 auto &scratchP = scratch0;
549 auto &scratchP_2ip1 = scratch1;
552 ordinal_type fieldOrdinal = 0;
553 for (
int faceOrdinal=0; faceOrdinal<numFaces; faceOrdinal++)
555 const int max_ij_sum = polyOrder_ - 1;
556 computeFaceLegendre(scratchP, faceOrdinal, lambda);
557 OutputScalar divWeight;
558 computeFaceDivWeight(divWeight, faceOrdinal, lambda_dx, lambda_dy, lambda_dz);
559 for (
int ij_sum=0; ij_sum <= max_ij_sum; ij_sum++)
561 for (
int i=0; i<=ij_sum; i++)
563 const int j = ij_sum - i;
565 computeFaceJacobi(scratchP_2ip1, faceOrdinal, i, lambda);
566 auto &outputValue = output_(fieldOrdinal,pointOrdinal);
567 faceFunctionDiv(outputValue, i, j, scratchP, scratchP_2ip1,
578 auto &scratchL_2ipjp1 = scratch2;
579 auto &scratchP_2ipjp1 = scratch3;
581 const int interiorFieldOrdinalOffset = numFaceFunctions_;
582 for (
int interiorFamilyOrdinal=1; interiorFamilyOrdinal<=numInteriorFamilies; interiorFamilyOrdinal++)
586 const ordinal_type relatedFaceOrdinal = faceOrdinalForInterior_[interiorFamilyOrdinal-1];
588 computeFaceLegendreForInterior(scratchP,
589 interiorFamilyOrdinal - 1, lambda);
590 OutputScalar divWeight;
591 computeFaceDivWeight(divWeight, relatedFaceOrdinal, lambda_dx, lambda_dy, lambda_dz);
593 OutputScalar vectorWeight_x, vectorWeight_y, vectorWeight_z;
594 computeFaceVectorWeight(vectorWeight_x, vectorWeight_y, vectorWeight_z, relatedFaceOrdinal, lambda, lambda_dx, lambda_dy, lambda_dz);
596 ordinal_type interiorFieldOrdinal = interiorFieldOrdinalOffset + interiorFamilyOrdinal - 1;
598 const ordinal_type min_ijk_sum = 1;
599 const ordinal_type max_ijk_sum = polyOrder_-1;
600 const ordinal_type min_ij_sum = 0;
601 const ordinal_type min_k = 1;
602 const ordinal_type min_j = 0;
603 const ordinal_type min_i = 0;
604 for (
int ijk_sum=min_ijk_sum; ijk_sum <= max_ijk_sum; ijk_sum++)
606 for (
int ij_sum=min_ij_sum; ij_sum<=ijk_sum-min_k; ij_sum++)
608 for (
int i=min_i; i<=ij_sum-min_j; i++)
610 const ordinal_type j = ij_sum-i;
611 const ordinal_type k = ijk_sum - ij_sum;
613 scratchP_2ip1, interiorFamilyOrdinal - 1, i, lambda);
615 OutputScalar faceDiv;
616 faceFunctionDiv(faceDiv, i, j, scratchP, scratchP_2ip1,
619 OutputScalar faceValue_x, faceValue_y, faceValue_z;
621 faceFunctionValue(faceValue_x, faceValue_y, faceValue_z, i,
622 j, scratchP, scratchP_2ip1,
623 vectorWeight_x, vectorWeight_y,
624 vectorWeight_z, lambda);
625 computeInteriorJacobi(scratchP_2ipjp1, i, j,
626 interiorFamilyOrdinal - 1, lambda);
628 computeInteriorIntegratedJacobi(scratchL_2ipjp1, i, j,
629 interiorFamilyOrdinal - 1,
632 OutputScalar L_2ipjp1_k_dx, L_2ipjp1_k_dy, L_2ipjp1_k_dz;
633 gradInteriorIntegratedJacobi(
634 L_2ipjp1_k_dx, L_2ipjp1_k_dy, L_2ipjp1_k_dz,
635 interiorFamilyOrdinal - 1, j, k, scratchP_2ipjp1,
636 lambda, lambda_dx, lambda_dy, lambda_dz);
638 auto &outputDiv = output_(interiorFieldOrdinal, pointOrdinal);
639 interiorFunctionDiv(outputDiv, scratchL_2ipjp1(k), faceDiv,
640 L_2ipjp1_k_dx, L_2ipjp1_k_dy,
641 L_2ipjp1_k_dz, faceValue_x, faceValue_y,
644 interiorFieldOrdinal += numInteriorFamilies;
663 INTREPID2_TEST_FOR_ABORT(
true,
664 ">>> ERROR: (Intrepid2::Hierarchical_HDIV_TET_Functor) Unsupported differential operator");
667 device_assert(
false);
674 size_t team_shmem_size (
int team_size)
const
677 size_t shmem_size = 0;
678 if (fad_size_output_ > 0)
679 shmem_size += 4 * OutputScratchView::shmem_size(polyOrder_ + 1, fad_size_output_);
681 shmem_size += 4 * OutputScratchView::shmem_size(polyOrder_ + 1);
695 template<
typename DeviceType,
696 typename OutputScalar = double,
697 typename PointScalar = double,
698 bool useCGBasis =
true>
700 :
public Basis<DeviceType,OutputScalar,PointScalar>
723 polyOrder_(polyOrder)
725 const shards::CellTopology cellTopo(shards::getCellTopologyData<shards::Tetrahedron<> >());
727 const int numFaces = cellTopo.getFaceCount();
729 const int numVertexFunctions = 0;
730 const int numEdgeFunctions = 0;
731 const int numFaceFunctions = numFaces * polyOrder * (polyOrder+1) / 2;
732 const int numInteriorFunctionsPerFamily = (polyOrder-1)*polyOrder*(polyOrder+1)/6;
733 const int numInteriorFunctions = numInteriorFunctionsPerFamily * 3;
734 this->
basisCardinality_ = numVertexFunctions + numEdgeFunctions + numFaceFunctions + numInteriorFunctions;
741 const int degreeLength = 1;
751 const int max_ij_sum = polyOrder-1;
752 ordinal_type fieldOrdinal = 0;
753 for (
int faceOrdinal=0; faceOrdinal<numFaces; faceOrdinal++)
755 for (
int ij_sum=0; ij_sum <= max_ij_sum; ij_sum++)
757 for (
int i=0; i<=ij_sum; i++)
764 INTREPID2_TEST_FOR_EXCEPTION(fieldOrdinal != numEdgeFunctions + numFaceFunctions, std::invalid_argument,
"Internal error: basis enumeration is incorrect");
766 const int numInteriorFamilies = 3;
767 const int interiorFieldOrdinalOffset = fieldOrdinal;
768 const ordinal_type min_ijk_sum = 1;
769 const ordinal_type max_ijk_sum = polyOrder_-1;
770 const ordinal_type min_ij_sum = 0;
771 const ordinal_type min_k = 1;
772 const ordinal_type min_j = 0;
773 const ordinal_type min_i = 0;
774 for (
int interiorFamilyOrdinal=1; interiorFamilyOrdinal<=numInteriorFamilies; interiorFamilyOrdinal++)
777 fieldOrdinal = interiorFieldOrdinalOffset + interiorFamilyOrdinal - 1;
778 for (
int ijk_sum=min_ijk_sum; ijk_sum <= max_ijk_sum; ijk_sum++)
780 for (
int ij_sum=min_ij_sum; ij_sum<=ijk_sum-min_k; ij_sum++)
782 for (
int i=min_i; i<=ij_sum-min_j; i++)
785 fieldOrdinal += numInteriorFamilies;
789 fieldOrdinal = fieldOrdinal - numInteriorFamilies + 1;
792 INTREPID2_TEST_FOR_EXCEPTION(fieldOrdinal != this->
basisCardinality_, std::invalid_argument,
"Internal error: basis enumeration is incorrect");
799 const int intrepid2FaceOrdinals[4] {3,0,1,2};
804 const ordinal_type tagSize = 4;
805 const ordinal_type posScDim = 0;
806 const ordinal_type posScOrd = 1;
807 const ordinal_type posDfOrd = 2;
810 const ordinal_type faceDim = 2, volumeDim = 3;
815 const int numFunctionsPerFace = numFaceFunctions / numFaces;
816 for (
int faceOrdinalESEAS=0; faceOrdinalESEAS<numFaces; faceOrdinalESEAS++)
818 int faceOrdinalIntrepid2 = intrepid2FaceOrdinals[faceOrdinalESEAS];
819 for (
int functionOrdinal=0; functionOrdinal<numFunctionsPerFace; functionOrdinal++)
821 tagView(tagNumber*tagSize+0) = faceDim;
822 tagView(tagNumber*tagSize+1) = faceOrdinalIntrepid2;
823 tagView(tagNumber*tagSize+2) = functionOrdinal;
824 tagView(tagNumber*tagSize+3) = numFunctionsPerFace;
830 for (
int functionOrdinal=0; functionOrdinal<numInteriorFunctions; functionOrdinal++)
832 tagView(tagNumber*tagSize+0) = volumeDim;
833 tagView(tagNumber*tagSize+1) = 0;
834 tagView(tagNumber*tagSize+2) = functionOrdinal;
835 tagView(tagNumber*tagSize+3) = numInteriorFunctions;
843 for (ordinal_type i=0;i<cardinality;++i) {
844 tagView(i*tagSize+0) = volumeDim;
845 tagView(i*tagSize+1) = 0;
846 tagView(i*tagSize+2) = i;
847 tagView(i*tagSize+3) = cardinality;
869 return "Intrepid2_HierarchicalBasis_HDIV_TET";
902 const EOperator operatorType = OPERATOR_VALUE )
const override
904 auto numPoints = inputPoints.extent_int(0);
908 FunctorType functor(operatorType, outputValues, inputPoints, polyOrder_);
910 const int outputVectorSize = getVectorSizeForHierarchicalParallelism<OutputScalar>();
911 const int pointVectorSize = getVectorSizeForHierarchicalParallelism<PointScalar>();
912 const int vectorSize = std::max(outputVectorSize,pointVectorSize);
913 const int teamSize = 1;
915 auto policy = Kokkos::TeamPolicy<ExecutionSpace>(numPoints,teamSize,vectorSize);
916 Kokkos::parallel_for(
"Hierarchical_HDIV_TET_Functor", policy , functor);
927 BasisPtr<DeviceType,OutputScalar,PointScalar>
933 return Teuchos::rcp(
new HVOL_Tri(this->
basisDegree_-1));
935 INTREPID2_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
"Input parameters out of bounds");
942 virtual BasisPtr<typename Kokkos::HostSpace::device_type, OutputScalar, PointScalar>
944 using HostDeviceType =
typename Kokkos::HostSpace::device_type;
946 return Teuchos::rcp(
new HostBasisType(polyOrder_) );
HierarchicalBasis_HDIV_TET(int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Constructor.
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
unsigned basisCellTopologyKey_
Identifier of the base topology of the cells for which the basis is defined. See the Shards package f...
EBasis basisType_
Type of the basis.
KOKKOS_INLINE_FUNCTION void computeFaceJacobiForInterior(OutputScratchView &P_2ip1, const ordinal_type &zeroBasedInteriorFamilyOrdinal, const ordinal_type &i, const PointScalar *lambda) const
The face functions we compute for interior blending can have a different orientation than the ones us...
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
Functor for computing values for the HierarchicalBasis_HDIV_TET class.
An abstract base class that defines interface for concrete basis implementations for Finite Element (...
virtual bool requireOrientation() const override
True if orientation is required.
Kokkos::DynRankView< scalarType, Kokkos::LayoutStride, DeviceType > ScalarViewType
View type for scalars.
Free functions, callable from device code, that implement various polynomials useful in basis definit...
EFunctionSpace functionSpace_
The function space in which the basis is defined.
ordinal_type basisDegree_
Degree of the largest complete polynomial space that can be represented by the basis.
virtual KOKKOS_INLINE_FUNCTION void getValues(OutputViewType, const PointViewType, const EOperator, const typename Kokkos::TeamPolicy< ExecutionSpace >::member_type &teamMember, const typename ExecutionSpace::scratch_memory_space &scratchStorage, const ordinal_type subcellDim=-1, const ordinal_type subcellOrdinal=-1) const
Team-level evaluation of basis functions on a reference cell.
Header function for Intrepid2::Util class and other utility functions.
Kokkos::View< ordinal_type **, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray2DHost
View type for 2d host array.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
BasisPtr< DeviceType, OutputScalar, PointScalar > getSubCellRefBasis(const ordinal_type subCellDim, const ordinal_type subCellOrd) const override
returns the basis associated to a subCell.
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, DeviceType > OutputViewType
View type for basis value output.
ordinal_type basisCardinality_
Cardinality of the basis, i.e., the number of basis functions/degrees-of-freedom. ...
virtual void getValues(OutputViewType outputValues, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const override
Evaluation of a FEM basis on a reference cell.
For mathematical details of the construction, see:
OrdinalTypeArray3DHost tagToOrdinal_
DoF tag to ordinal lookup table.
const char * getName() const override
Returns basis name.
OrdinalTypeArray2DHost ordinalToTag_
"true" if tagToOrdinal_ and ordinalToTag_ have been initialized
ordinal_type getDegree() const
Returns the degree of the basis.
ECoordinates basisCoordinates_
The coordinate system for which the basis is defined.
OrdinalTypeArray2DHost fieldOrdinalPolynomialDegree_
Polynomial degree for each degree of freedom. Only defined for hierarchical bases right now...
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, DeviceType > OutputViewType
View type for basis value output.
Basis defining Legendre basis on the line, a polynomial subspace of H(vol) on the line: extension to ...
void setOrdinalTagData(OrdinalTypeView3D &tagToOrdinal, OrdinalTypeView2D &ordinalToTag, const OrdinalTypeView1D tags, const ordinal_type basisCard, const ordinal_type tagSize, const ordinal_type posScDim, const ordinal_type posScOrd, const ordinal_type posDfOrd)
Fills ordinalToTag_ and tagToOrdinal_ by basis-specific tag data.
H(vol) basis on the triangle based on integrated Legendre polynomials.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
Header file for the abstract base class Intrepid2::Basis.
typename DeviceType::execution_space ExecutionSpace
(Kokkos) Execution space for basis.
virtual BasisPtr< typename Kokkos::HostSpace::device_type, OutputScalar, PointScalar > getHostBasis() const override
Creates and returns a Basis object whose DeviceType template argument is Kokkos::HostSpace::device_ty...