16#ifndef __INTREPID2_HDIV_HEX_IN_FEM_DEF_HPP__
17#define __INTREPID2_HDIV_HEX_IN_FEM_DEF_HPP__
24 template<EOperator OpType>
25 template<
typename OutputViewType,
26 typename InputViewType,
27 typename WorkViewType,
28 typename VinvViewType>
29 KOKKOS_INLINE_FUNCTION
33 const InputViewType input,
35 const VinvViewType vinvLine,
36 const VinvViewType vinvBubble) {
37 const ordinal_type cardLine = vinvLine.extent(0);
38 const ordinal_type cardBubble = vinvBubble.extent(0);
40 const ordinal_type npts = input.extent(0);
42 typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
43 const auto input_x = Kokkos::subview(input, Kokkos::ALL(), range_type(0,1));
44 const auto input_y = Kokkos::subview(input, Kokkos::ALL(), range_type(1,2));
45 const auto input_z = Kokkos::subview(input, Kokkos::ALL(), range_type(2,3));
47 const ordinal_type dim_s = get_dimension_scalar(input);
48 auto ptr0 = work.data();
49 auto ptr1 = work.data()+cardLine*npts*dim_s;
50 auto ptr2 = work.data()+2*cardLine*npts*dim_s;
51 auto ptr3 = work.data()+(2*cardLine+cardBubble)*npts*dim_s;
53 typedef typename Kokkos::DynRankView<typename InputViewType::value_type, typename WorkViewType::memory_space> ViewType;
56 case OPERATOR_VALUE: {
65 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
66 getValues(outputLine, input_x, workLine, vinvLine);
68 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
69 getValues(outputBubble_A, input_y, workLine, vinvBubble);
71 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
72 getValues(outputBubble_B, input_z, workLine, vinvBubble);
76 const auto output_x = outputLine;
77 const auto output_y = outputBubble_A;
78 const auto output_z = outputBubble_B;
80 for (ordinal_type k=0;k<cardBubble;++k)
81 for (ordinal_type j=0;j<cardBubble;++j)
82 for (ordinal_type i=0;i<cardLine;++i,++idx)
83 for (ordinal_type l=0;l<npts;++l) {
84 output.access(idx,l,0) = output_x.access(i,l)*output_y.access(j,l)*output_z.access(k,l);
85 output.access(idx,l,1) = 0.0;
86 output.access(idx,l,2) = 0.0;
90 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
91 getValues(outputBubble_A, input_x, workLine, vinvBubble);
93 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
94 getValues(outputLine, input_y, workLine, vinvLine);
100 const auto output_x = outputBubble_A;
101 const auto output_y = outputLine;
102 const auto output_z = outputBubble_B;
104 for (ordinal_type k=0;k<cardBubble;++k)
105 for (ordinal_type j=0;j<cardLine;++j)
106 for (ordinal_type i=0;i<cardBubble;++i,++idx)
107 for (ordinal_type l=0;l<npts;++l) {
108 output.access(idx,l,0) = 0.0;
109 output.access(idx,l,1) = output_x.access(i,l)*output_y.access(j,l)*output_z.access(k,l);
110 output.access(idx,l,2) = 0.0;
117 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
118 getValues(outputBubble_B, input_y, workLine, vinvBubble);
120 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
121 getValues(outputLine, input_z, workLine, vinvLine);
124 const auto output_x = outputBubble_A;
125 const auto output_y = outputBubble_B;
126 const auto output_z = outputLine;
128 for (ordinal_type k=0;k<cardLine;++k)
129 for (ordinal_type j=0;j<cardBubble;++j)
130 for (ordinal_type i=0;i<cardBubble;++i,++idx)
131 for (ordinal_type l=0;l<npts;++l) {
132 output.access(idx,l,0) = 0.0;
133 output.access(idx,l,1) = 0.0;
134 output.access(idx,l,2) = output_x.access(i,l)*output_y.access(j,l)*output_z.access(k,l);
149 ordinal_type idx = 0;
152 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
153 getValues(outputLine, input_x, workLine, vinvLine, 1);
155 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
156 getValues(outputBubble_A, input_y, workLine, vinvBubble);
158 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
159 getValues(outputBubble_B, input_z, workLine, vinvBubble);
162 const auto output_dx = outputLine;
163 const auto output_y = outputBubble_A;
164 const auto output_z = outputBubble_B;
166 for (ordinal_type k=0;k<cardBubble;++k)
167 for (ordinal_type j=0;j<cardBubble;++j)
168 for (ordinal_type i=0;i<cardLine;++i,++idx)
169 for (ordinal_type l=0;l<npts;++l)
170 output.access(idx,l) = output_dx.access(i,l,0)*output_y.access (j,l) *output_z.access(k,l);
173 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
174 getValues(outputBubble_A, input_x, workLine, vinvBubble);
176 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
177 getValues(outputLine, input_y, workLine, vinvLine, 1);
183 const auto output_x = outputBubble_A;
184 const auto output_dy = outputLine;
185 const auto output_z = outputBubble_B;
187 for (ordinal_type k=0;k<cardBubble;++k)
188 for (ordinal_type j=0;j<cardLine;++j)
189 for (ordinal_type i=0;i<cardBubble;++i,++idx)
190 for (ordinal_type l=0;l<npts;++l)
191 output.access(idx,l) = output_x.access(i,l)*output_dy.access(j,l,0)*output_z.access(k,l);
197 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
198 getValues(outputBubble_B, input_y, workLine, vinvBubble);
200 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
201 getValues(outputLine, input_z, workLine, vinvLine, 1);
204 const auto output_x = outputBubble_A;
205 const auto output_y = outputBubble_B;
206 const auto output_dz = outputLine;
208 for (ordinal_type k=0;k<cardLine;++k)
209 for (ordinal_type j=0;j<cardBubble;++j)
210 for (ordinal_type i=0;i<cardBubble;++i,++idx)
211 for (ordinal_type l=0;l<npts;++l)
212 output.access(idx,l) = output_x.access(i,l)*output_y.access(j,l)*output_dz.access(k,l,0);
217 INTREPID2_TEST_FOR_ABORT(
true,
218 ">>> ERROR: (Intrepid2::Basis_HDIV_HEX_In_FEM::Serial::getValues) operator is not supported" );
223 template<
typename DT, ordinal_type numPtsPerEval,
224 typename outputValueValueType,
class ...outputValueProperties,
225 typename inputPointValueType,
class ...inputPointProperties,
226 typename vinvValueType,
class ...vinvProperties>
228 Basis_HDIV_HEX_In_FEM::
229 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
230 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
231 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvLine,
232 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvBubble,
233 const EOperator operatorType ) {
234 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
235 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
236 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
237 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
240 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
241 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
242 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
243 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
245 const ordinal_type cardinality = outputValues.extent(0);
247 ordinal_type order = 0;
248 ordinal_type cardBubble;
249 ordinal_type cardLine;
251 cardBubble = Intrepid2::getPnCardinality<1>(order);
252 cardLine = Intrepid2::getPnCardinality<1>(++order);
255 switch (operatorType) {
256 case OPERATOR_VALUE: {
257 auto workSize = Serial<OPERATOR_VALUE>::getWorkSizePerPoint(order);
258 auto work =
createMatchingDynRankView(inputPoints,
"Basis_HDIV_HEX_In_FEM::getValues::work", workSize, inputPoints.extent(0));
259 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,
decltype(work),
260 OPERATOR_VALUE,numPtsPerEval> FunctorType;
261 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinvLine, vinvBubble, work) );
265 auto workSize = Serial<OPERATOR_DIV>::getWorkSizePerPoint(order);
266 auto work =
createMatchingDynRankView(inputPoints,
"Basis_HDIV_HEX_In_FEM::getValues::work", workSize, inputPoints.extent(0));
267 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,
decltype(work),
268 OPERATOR_DIV,numPtsPerEval> FunctorType;
269 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinvLine, vinvBubble, work) );
273 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
274 ">>> ERROR (Basis_HDIV_HEX_In_FEM): Operator type not implemented" );
283 template<
typename DT,
typename OT,
typename PT>
286 const EPointType pointType ) {
288 INTREPID2_TEST_FOR_EXCEPTION( !(pointType == POINTTYPE_EQUISPACED ||
289 pointType == POINTTYPE_WARPBLEND), std::invalid_argument,
290 ">>> ERROR (Basis_HDIV_HEX_In_FEM): pointType must be either equispaced or warpblend.");
300 this->
vinvLine_ = Kokkos::DynRankView<typename ScalarViewType::value_type,DT>(
"Hcurl::Hex::In::vinvLine", cardLine, cardLine);
301 this->vinvBubble_ = Kokkos::DynRankView<typename ScalarViewType::value_type,DT>(
"Hcurl::Hex::In::vinvBubble", cardBubble, cardBubble);
303 lineBasis.getVandermondeInverse(this->
vinvLine_);
304 bubbleBasis.getVandermondeInverse(this->vinvBubble_);
306 const ordinal_type spaceDim = 3;
313 pointType_ = pointType;
318 const ordinal_type tagSize = 4;
319 const ordinal_type posScDim = 0;
320 const ordinal_type posScOrd = 1;
321 const ordinal_type posDfOrd = 2;
325 ordinal_type tags[3*maxCardLine*maxCardLine*maxCardLine][4];
327 const ordinal_type face_yz[2] = {3, 1};
328 const ordinal_type face_xz[2] = {0, 2};
329 const ordinal_type face_xy[2] = {4, 5};
332 ordinal_type idx = 0;
342 intr_ndofs_per_direction = (cardLine-2)*cardBubble*cardBubble,
343 intr_ndofs = 3*intr_ndofs_per_direction;
346 for (ordinal_type k=0;k<cardBubble;++k) {
347 const auto tag_z = bubbleBasis.
getDofTag(k);
348 for (ordinal_type j=0;j<cardBubble;++j) {
349 const auto tag_y = bubbleBasis.
getDofTag(j);
350 for (ordinal_type i=0;i<cardLine;++i,++idx) {
351 const auto tag_x = lineBasis.
getDofTag(i);
353 if (tag_x(0) == 0 && tag_y(0) == 1 && tag_z(0) == 1) {
356 tags[idx][1] = face_yz[tag_x(1)];
357 tags[idx][2] = tag_y(2) + tag_y(3)*tag_z(2);
358 tags[idx][3] = tag_y(3)*tag_z(3);
363 tags[idx][2] = tag_x(2) + tag_x(3)*tag_y(2) + tag_x(3)*tag_y(3)*tag_z(2);
364 tags[idx][3] = intr_ndofs;
371 for (ordinal_type k=0;k<cardBubble;++k) {
372 const auto tag_z = bubbleBasis.
getDofTag(k);
373 for (ordinal_type j=0;j<cardLine;++j) {
374 const auto tag_y = lineBasis.
getDofTag(j);
375 for (ordinal_type i=0;i<cardBubble;++i,++idx) {
376 const auto tag_x = bubbleBasis.
getDofTag(i);
378 if (tag_x(0) == 1 && tag_y(0) == 0 && tag_z(0) == 1) {
381 tags[idx][1] = face_xz[tag_y(1)];
382 tags[idx][2] = tag_x(2) + tag_x(3)*tag_z(2);
383 tags[idx][3] = tag_x(3)*tag_z(3);
388 tags[idx][2] = intr_ndofs_per_direction + tag_x(2) + tag_x(3)*tag_y(2) + tag_x(3)*tag_y(3)*tag_z(2);
389 tags[idx][3] = intr_ndofs;
396 for (ordinal_type k=0;k<cardLine;++k) {
397 const auto tag_z = lineBasis.
getDofTag(k);
398 for (ordinal_type j=0;j<cardBubble;++j) {
399 const auto tag_y = bubbleBasis.
getDofTag(j);
400 for (ordinal_type i=0;i<cardBubble;++i,++idx) {
401 const auto tag_x = bubbleBasis.
getDofTag(i);
403 if (tag_x(0) == 1 && tag_y(0) == 1 && tag_z(0) == 0) {
406 tags[idx][1] = face_xy[tag_z(1)];
407 tags[idx][2] = tag_x(2) + tag_x(3)*tag_y(2);
408 tags[idx][3] = tag_x(3)*tag_y(3);
413 tags[idx][2] = 2*intr_ndofs_per_direction + tag_x(2) + tag_x(3)*tag_y(2) + tag_x(3)*tag_y(3)*tag_z(2);
414 tags[idx][3] = intr_ndofs;
420 INTREPID2_TEST_FOR_EXCEPTION( idx != this->
basisCardinality_ , std::runtime_error,
421 ">>> ERROR (Basis_HDIV_HEX_In_FEM): " \
422 "counted tag index is not same as cardinality." );
440 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
444 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
447 Kokkos::DynRankView<typename ScalarViewType::value_type,DT>
448 dofCoordsLine(
"dofCoordsLine", cardLine, 1),
449 dofCoordsBubble(
"dofCoordsBubble", cardBubble, 1);
452 auto dofCoordsLineHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), dofCoordsLine);
453 Kokkos::deep_copy(dofCoordsLineHost, dofCoordsLine);
456 auto dofCoordsBubbleHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), dofCoordsBubble);
457 Kokkos::deep_copy(dofCoordsBubbleHost, dofCoordsBubble);
460 ordinal_type idx = 0;
463 for (ordinal_type k=0;k<cardBubble;++k) {
464 for (ordinal_type j=0;j<cardBubble;++j) {
465 for (ordinal_type i=0;i<cardLine;++i,++idx) {
466 dofCoordsHost(idx,0) = dofCoordsLineHost(i,0);
467 dofCoordsHost(idx,1) = dofCoordsBubbleHost(j,0);
468 dofCoordsHost(idx,2) = dofCoordsBubbleHost(k,0);
469 dofCoeffsHost(idx,0) = 1.0;
475 for (ordinal_type k=0;k<cardBubble;++k) {
476 for (ordinal_type j=0;j<cardLine;++j) {
477 for (ordinal_type i=0;i<cardBubble;++i,++idx) {
478 dofCoordsHost(idx,0) = dofCoordsBubbleHost(i,0);
479 dofCoordsHost(idx,1) = dofCoordsLineHost(j,0);
480 dofCoordsHost(idx,2) = dofCoordsBubbleHost(k,0);
481 dofCoeffsHost(idx,1) = 1.0;
487 for (ordinal_type k=0;k<cardLine;++k) {
488 for (ordinal_type j=0;j<cardBubble;++j) {
489 for (ordinal_type i=0;i<cardBubble;++i,++idx) {
490 dofCoordsHost(idx,0) = dofCoordsBubbleHost(i,0);
491 dofCoordsHost(idx,1) = dofCoordsBubbleHost(j,0);
492 dofCoordsHost(idx,2) = dofCoordsLineHost(k,0);
493 dofCoeffsHost(idx,2) = 1.0;
499 this->
dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoordsHost);
500 Kokkos::deep_copy(this->
dofCoords_, dofCoordsHost);
502 this->
dofCoeffs_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoeffsHost);
503 Kokkos::deep_copy(this->
dofCoeffs_, dofCoeffsHost);
506 template<
typename DT,
typename OT,
typename PT>
508 Basis_HDIV_HEX_In_FEM<DT,OT,PT>::getScratchSpaceSize(
509 ordinal_type& perTeamSpaceSize,
510 ordinal_type& perThreadSpaceSize,
512 const EOperator operatorType)
const {
513 perTeamSpaceSize = 0;
514 perThreadSpaceSize = (2*this->vinvLine_.extent(0)+2*this->vinvBubble_.extent(0))*get_dimension_scalar(inputPoints)*
sizeof(
typename BasisBase::scalarType);
517 template<
typename DT,
typename OT,
typename PT>
518 KOKKOS_INLINE_FUNCTION
520 Basis_HDIV_HEX_In_FEM<DT,OT,PT>::getValues(
521 OutputViewType outputValues,
522 const PointViewType inputPoints,
523 const EOperator operatorType,
524 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
525 const typename DT::execution_space::scratch_memory_space & scratchStorage,
526 const ordinal_type subcellDim,
527 const ordinal_type subcellOrdinal)
const {
529 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
530 ">>> ERROR: (Intrepid2::Basis_HDIV_HEX_In_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
532 const int numPoints = inputPoints.extent(0);
533 using ScalarType =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
534 using WorkViewType = Kokkos::DynRankView< ScalarType,typename DT::execution_space::scratch_memory_space,Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
535 ordinal_type sizePerPoint = (2*this->vinvLine_.extent(0)+2*this->vinvBubble_.extent(0))*get_dimension_scalar(inputPoints);
536 WorkViewType workView(scratchStorage, sizePerPoint*team_member.team_size());
537 using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
539 switch(operatorType) {
541 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinvLine_ = this->vinvLine_, &vinvBubble_ = this->vinvBubble_] (ordinal_type& pt) {
542 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type (pt,pt+1), Kokkos::ALL() );
543 const auto input = Kokkos::subview( inputPoints, range_type(pt, pt+1), Kokkos::ALL() );
544 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
545 Impl::Basis_HDIV_HEX_In_FEM::Serial<OPERATOR_VALUE>::getValues( output, input, work, vinvLine_, vinvBubble_ );
549 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinvLine_ = this->vinvLine_, &vinvBubble_ = this->vinvBubble_] (ordinal_type& pt) {
550 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type(pt,pt+1), Kokkos::ALL() );
551 const auto input = Kokkos::subview( inputPoints, range_type(pt,pt+1), Kokkos::ALL() );
552 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
553 Impl::Basis_HDIV_HEX_In_FEM::Serial<OPERATOR_DIV>::getValues( output, input, work, vinvLine_, vinvBubble_ );
557 INTREPID2_TEST_FOR_ABORT(
true,
558 ">>> ERROR (Basis_HDIV_HEX_In_FEM): getValues not implemented for this operator");
KOKKOS_INLINE_FUNCTION std::enable_if< std::is_pointer_v< CtorProp > &&!std::is_convertible_v< CtorProp, constchar * >, OutViewType >::type createMatchingUnmanagedView(const InViewType &view, const CtorProp &data, const Dims... dims)
Creates an unmanaged view that matches the value_type of the provided view The type of the output vie...
DeduceDynRankView< InViewType >::type createMatchingDynRankView(const InViewType &view, const CtorProp &prop, const Dims... dims)
Creates and returns a view that matches the value_type of the provided view The output view type is d...
Basis_HDIV_HEX_In_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
Kokkos::DynRankView< typename ScalarViewType::value_type, DeviceType > vinvLine_
inverse of Generalized Vandermonde matrix (isotropic order)
Implementation of the locally H(grad)-compatible FEM basis of variable order on the [-1,...
virtual void getDofCoords(ScalarViewType dofCoords) const override
Returns spatial locations (coordinates) of degrees of freedom on the reference cell.
Implementation of the locally HVOL-compatible FEM basis of variable order on the [-1,...
virtual void getDofCoords(ScalarViewType dofCoords) const override
Returns spatial locations (coordinates) of degrees of freedom on the reference cell.
ECoordinates basisCoordinates_
const OrdinalTypeArrayStride1DHost getDofTag(const ordinal_type dofOrd) const
DoF ordinal to DoF tag lookup.
ordinal_type basisDegree_
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)
ordinal_type getCardinality() const
Returns cardinality of the basis.
OrdinalTypeArray2DHost ordinalToTag_
Kokkos::DynRankView< scalarType, DeviceType > dofCoords_
Kokkos::DynRankView< scalarType, DeviceType > dofCoeffs_
ordinal_type basisCardinality_
OrdinalTypeArray3DHost tagToOrdinal_
unsigned basisCellTopologyKey_
EFunctionSpace functionSpace_
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.
See Intrepid2::Basis_HDIV_HEX_In_FEM.
See Intrepid2::Basis_HDIV_HEX_In_FEM.