15#ifndef __INTREPID2_HVOL_HEX_CN_FEMDEF_HPP__
16#define __INTREPID2_HVOL_HEX_CN_FEMDEF_HPP__
23 template<EOperator OpType>
24 template<
typename OutputViewType,
25 typename InputViewType,
26 typename WorkViewType,
27 typename VinvViewType>
28 KOKKOS_INLINE_FUNCTION
32 const InputViewType input,
34 const VinvViewType vinv,
35 const ordinal_type operatorDn ) {
36 ordinal_type opDn = operatorDn;
38 const ordinal_type cardLine = vinv.extent(0);
39 const ordinal_type npts = input.extent(0);
41 typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
42 const auto input_x = Kokkos::subview(input, Kokkos::ALL(), range_type(0,1));
43 const auto input_y = Kokkos::subview(input, Kokkos::ALL(), range_type(1,2));
44 const auto input_z = Kokkos::subview(input, Kokkos::ALL(), range_type(2,3));
46 const ordinal_type dim_s = get_dimension_scalar(input);
47 auto ptr0 = work.data();
48 auto ptr1 = work.data()+cardLine*npts*dim_s;
49 auto ptr2 = work.data()+2*cardLine*npts*dim_s;
50 auto ptr3 = work.data()+3*cardLine*npts*dim_s;
52 typedef typename Kokkos::DynRankView<typename InputViewType::value_type, typename WorkViewType::memory_space> ViewType;
55 case OPERATOR_VALUE: {
61 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
62 getValues(output_x, input_x, work_line, vinv);
64 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
65 getValues(output_y, input_y, work_line, vinv);
67 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
68 getValues(output_z, input_z, work_line, vinv);
72 for (ordinal_type k=0;k<cardLine;++k)
73 for (ordinal_type j=0;j<cardLine;++j)
74 for (ordinal_type i=0;i<cardLine;++i,++idx)
75 for (ordinal_type l=0;l<npts;++l)
76 output.access(idx,l) = output_x.access(i,l)*output_y.access(j,l)*output_z.access(k,l);
92 const ordinal_type dkcard = opDn + 1;
95 for (ordinal_type l1=0;l1<dkcard;++l1)
96 for (ordinal_type l0=0;l0<(l1+1);++l0) {
97 const ordinal_type mult_x = (opDn - l1);
98 const ordinal_type mult_y = l1 - l0;
99 const ordinal_type mult_z = l0;
108 decltype(work_line) output_x, output_y, output_z;
112 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
113 getValues(output_x, input_x, work_line, vinv, mult_x);
116 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
117 getValues(output_x, input_x, work_line, vinv);
122 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
123 getValues(output_y, input_y, work_line, vinv, mult_y);
126 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
127 getValues(output_y, input_y, work_line, vinv);
132 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
133 getValues(output_z, input_z, work_line, vinv, mult_z);
136 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
137 getValues(output_z, input_z, work_line, vinv);
141 ordinal_type idx = 0;
142 for (ordinal_type k=0;k<cardLine;++k)
143 for (ordinal_type j=0;j<cardLine;++j)
144 for (ordinal_type i=0;i<cardLine;++i,++idx)
145 for (ordinal_type l=0;l<npts;++l)
146 output.access(idx,l,d) = output_x.access(i,l,0)*output_y.access(j,l,0)*output_z.access(k,l,0);
153 INTREPID2_TEST_FOR_ABORT(
true ,
154 ">>> ERROR (Basis_HVOL_HEX_Cn_FEM): Operator type not implemented");
160 template<
typename DT, ordinal_type numPtsPerEval,
161 typename outputValueValueType,
class ...outputValueProperties,
162 typename inputPointValueType,
class ...inputPointProperties,
163 typename vinvValueType,
class ...vinvProperties>
165 Basis_HVOL_HEX_Cn_FEM::
166 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
167 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
168 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
169 const EOperator operatorType ) {
170 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
171 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
172 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
173 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
176 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
177 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
178 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
179 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
181 const ordinal_type cardinality = outputValues.extent(0);
182 const ordinal_type cardLine = std::cbrt(cardinality);
183 const ordinal_type workSize = 4*cardLine;
185 auto work =
createMatchingDynRankView(inputPoints,
"Basis_HVOL_HEX_Cn_FEM::getValues::work", workSize, inputPoints.extent(0));
187 switch (operatorType) {
188 case OPERATOR_VALUE: {
189 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,
decltype(work),
190 OPERATOR_VALUE,numPtsPerEval> FunctorType;
191 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
205 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,
decltype(work),
206 OPERATOR_Dn,numPtsPerEval> FunctorType;
207 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work,
212 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
213 ">>> ERROR (Basis_HVOL_HEX_Cn_FEM): Operator type not implemented" );
221 template<
typename DT,
typename OT,
typename PT>
224 const EPointType pointType ) {
230 this->pointType_ = pointType;
231 this->
vinv_ = Kokkos::DynRankView<typename ScalarViewType::value_type,DT>(
"HVOL::HEX::Cn::vinv", cardLine, cardLine);
232 lineBasis.getVandermondeInverse(this->
vinv_);
234 const ordinal_type spaceDim = 3;
245 const ordinal_type tagSize = 4;
246 const ordinal_type posScDim = 0;
247 const ordinal_type posScOrd = 1;
248 const ordinal_type posDfOrd = 2;
252 ordinal_type tags[maxCardLine*maxCardLine*maxCardLine][4];
255 ordinal_type idx = 0;
256 for (
auto k=0;k<cardLine;++k) {
257 const auto tag_z = lineBasis.
getDofTag(k);
258 for (ordinal_type j=0;j<cardLine;++j) {
259 const auto tag_y = lineBasis.
getDofTag(j);
260 for (ordinal_type i=0;i<cardLine;++i,++idx) {
261 const auto tag_x = lineBasis.
getDofTag(i);
266 tags[idx][2] = tag_x(2) + tag_x(3)*tag_y(2) + tag_x(3)*tag_y(3)*tag_z(2);
267 tags[idx][3] = tag_x(3)*tag_y(3)*tag_z(3);
288 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
291 Kokkos::DynRankView<typename ScalarViewType::value_type,DT>
292 dofCoordsLine(
"dofCoordsLine", cardLine, 1);
295 auto dofCoordsLineHost = Kokkos::create_mirror_view(Kokkos::HostSpace(), dofCoordsLine);
296 Kokkos::deep_copy(dofCoordsLineHost, dofCoordsLine);
298 ordinal_type idx = 0;
299 for (
auto k=0;k<cardLine;++k) {
300 for (ordinal_type j=0;j<cardLine;++j) {
301 for (ordinal_type i=0;i<cardLine;++i,++idx) {
302 dofCoordsHost(idx,0) = dofCoordsLineHost(i,0);
303 dofCoordsHost(idx,1) = dofCoordsLineHost(j,0);
304 dofCoordsHost(idx,2) = dofCoordsLineHost(k,0);
311 this->
dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoordsHost);
312 Kokkos::deep_copy(this->
dofCoords_, dofCoordsHost);
315 template<
typename DT,
typename OT,
typename PT>
317 Basis_HVOL_HEX_Cn_FEM<DT,OT,PT>::getScratchSpaceSize(
318 ordinal_type& perTeamSpaceSize,
319 ordinal_type& perThreadSpaceSize,
321 const EOperator operatorType)
const {
322 perTeamSpaceSize = 0;
323 perThreadSpaceSize = 4*this->vinv_.extent(0)*get_dimension_scalar(inputPoints)*
sizeof(
typename BasisBase::scalarType);
326 template<
typename DT,
typename OT,
typename PT>
327 KOKKOS_INLINE_FUNCTION
329 Basis_HVOL_HEX_Cn_FEM<DT,OT,PT>::getValues(
330 OutputViewType outputValues,
331 const PointViewType inputPoints,
332 const EOperator operatorType,
333 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
334 const typename DT::execution_space::scratch_memory_space & scratchStorage,
335 const ordinal_type subcellDim,
336 const ordinal_type subcellOrdinal)
const {
338 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
339 ">>> ERROR: (Intrepid2::Basis_HVOL_HEX_Cn_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
341 const int numPoints = inputPoints.extent(0);
342 using ScalarType =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
343 using WorkViewType = Kokkos::DynRankView< ScalarType,typename DT::execution_space::scratch_memory_space,Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
344 auto sizePerPoint = 4*this->vinv_.extent(0)*get_dimension_scalar(inputPoints);
345 WorkViewType workView(scratchStorage, sizePerPoint*team_member.team_size());
346 using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
347 switch(operatorType) {
349 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_, basisDegree_ = this->basisDegree_] (ordinal_type& pt) {
350 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type (pt,pt+1), Kokkos::ALL() );
351 const auto input = Kokkos::subview( inputPoints, range_type(pt, pt+1), Kokkos::ALL() );
352 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
353 Impl::Basis_HVOL_HEX_Cn_FEM::Serial<OPERATOR_VALUE>::getValues( output, input, work, vinv_, basisDegree_);
357 INTREPID2_TEST_FOR_ABORT(
true,
358 ">>> ERROR (Basis_HVOL_HEX_Cn_FEM): getValues not implemented for this operator");
KOKKOS_INLINE_FUNCTION ordinal_type getOperatorOrder(const EOperator operatorType)
Returns order of an 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_HVOL_HEX_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
Kokkos::DynRankView< typename ScalarViewType::value_type, DeviceType > vinv_
inverse of Generalized Vandermonde matrix (isotropic order)
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_
ordinal_type basisCardinality_
OrdinalTypeArray3DHost tagToOrdinal_
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
unsigned basisCellTopologyKey_
EFunctionSpace functionSpace_
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.
See Intrepid2::Basis_HVOL_HEX_Cn_FEM.
See Intrepid2::Basis_HVOL_HEX_Cn_FEM.