15#ifndef __INTREPID2_HVOL_QUAD_CN_FEM_DEF_HPP__
16#define __INTREPID2_HVOL_QUAD_CN_FEM_DEF_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));
45 const ordinal_type dim_s = get_dimension_scalar(input);
46 auto ptr0 = work.data();
47 auto ptr1 = work.data()+cardLine*npts*dim_s;
48 auto ptr2 = work.data()+2*cardLine*npts*dim_s;
50 typedef typename Kokkos::DynRankView<typename InputViewType::value_type, typename WorkViewType::memory_space> ViewType;
53 case OPERATOR_VALUE: {
58 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
59 getValues(output_x, input_x, work_line, vinv);
61 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
62 getValues(output_y, input_y, work_line, vinv);
66 for (ordinal_type j=0;j<cardLine;++j)
67 for (ordinal_type i=0;i<cardLine;++i,++idx)
68 for (ordinal_type k=0;k<npts;++k)
69 output.access(idx,k) = output_x.access(i,k)*output_y.access(j,k);
85 const auto dkcard = opDn + 1;
86 for (
auto l=0;l<dkcard;++l) {
89 ViewType output_x, output_y;
91 const auto mult_x = opDn - l;
92 const auto mult_y = l;
96 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
97 getValues(output_x, input_x, work_line, vinv, mult_x);
100 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
101 getValues(output_x, input_x, work_line, vinv);
106 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
107 getValues(output_y, input_y, work_line, vinv, mult_y);
110 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
111 getValues(output_y, input_y, work_line, vinv);
115 ordinal_type idx = 0;
116 for (ordinal_type j=0;j<cardLine;++j)
117 for (ordinal_type i=0;i<cardLine;++i,++idx)
118 for (ordinal_type k=0;k<npts;++k)
119 output.access(idx,k,l) = output_x.access(i,k,0)*output_y.access(j,k,0);
124 INTREPID2_TEST_FOR_ABORT(
true,
125 ">>> ERROR: (Intrepid2::Basis_HVOL_QUAD_Cn_FEM::Serial::getValues) operator is not supported" );
130 template<
typename DT, ordinal_type numPtsPerEval,
131 typename outputValueValueType,
class ...outputValueProperties,
132 typename inputPointValueType,
class ...inputPointProperties,
133 typename vinvValueType,
class ...vinvProperties>
135 Basis_HVOL_QUAD_Cn_FEM::
136 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
137 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
138 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
139 const EOperator operatorType ) {
140 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
141 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
142 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
143 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
146 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
147 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
148 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
149 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
153 const ordinal_type cardinality = outputValues.extent(0);
154 const ordinal_type cardLine = std::sqrt(cardinality);
155 const ordinal_type workSize = 3*cardLine;
157 auto work =
createMatchingDynRankView(inputPoints,
"Basis_HVOL_QUAD_Cn_FEM::getValues::work", workSize, inputPoints.extent(0));
159 switch (operatorType) {
160 case OPERATOR_VALUE: {
161 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,
decltype(work),
162 OPERATOR_VALUE,numPtsPerEval> FunctorType;
163 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
177 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,
decltype(work),
178 OPERATOR_Dn,numPtsPerEval> FunctorType;
179 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work,
184 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
185 ">>> ERROR (Basis_HVOL_QUAD_Cn_FEM): Operator type not implemented" );
193 template<
typename DT,
typename OT,
typename PT>
196 const EPointType pointType ) {
205 this->pointType_ = pointType;
206 this->
vinv_ = Kokkos::DynRankView<typename ScalarViewType::value_type,DT>(
"HVOL::Quad::Cn::vinv", cardLine, cardLine);
207 lineBasis.getVandermondeInverse(this->
vinv_);
209 const ordinal_type spaceDim = 2;
220 const ordinal_type tagSize = 4;
221 const ordinal_type posScDim = 0;
222 const ordinal_type posScOrd = 1;
223 const ordinal_type posDfOrd = 2;
227 ordinal_type tags[maxCardLine*maxCardLine][4];
230 ordinal_type idx = 0;
231 for (ordinal_type j=0;j<cardLine;++j) {
232 const auto tag_y = lineBasis.
getDofTag(j);
233 for (ordinal_type i=0;i<cardLine;++i,++idx) {
234 const auto tag_x = lineBasis.
getDofTag(i);
239 tags[idx][2] = tag_x(2) + tag_x(3)*tag_y(2);
240 tags[idx][3] = tag_x(3)*tag_y(3);
260 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
263 Kokkos::DynRankView<typename ScalarViewType::value_type,DT>
264 dofCoordsLine(
"dofCoordsLine", cardLine, 1);
267 auto dofCoordsLineHost = Kokkos::create_mirror_view(dofCoordsLine);
268 Kokkos::deep_copy(dofCoordsLineHost, dofCoordsLine);
270 ordinal_type idx = 0;
271 for (ordinal_type j=0;j<cardLine;++j) {
272 for (ordinal_type i=0;i<cardLine;++i,++idx) {
273 dofCoordsHost(idx,0) = dofCoordsLineHost(i,0);
274 dofCoordsHost(idx,1) = dofCoordsLineHost(j,0);
279 this->
dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoordsHost);
280 Kokkos::deep_copy(this->
dofCoords_, dofCoordsHost);
283 template<
typename DT,
typename OT,
typename PT>
285 Basis_HVOL_QUAD_Cn_FEM<DT,OT,PT>::getScratchSpaceSize(
286 ordinal_type& perTeamSpaceSize,
287 ordinal_type& perThreadSpaceSize,
289 const EOperator operatorType)
const {
290 perTeamSpaceSize = 0;
291 perThreadSpaceSize = 3*this->vinv_.extent(0)*get_dimension_scalar(inputPoints)*
sizeof(
typename BasisBase::scalarType);
294 template<
typename DT,
typename OT,
typename PT>
295 KOKKOS_INLINE_FUNCTION
297 Basis_HVOL_QUAD_Cn_FEM<DT,OT,PT>::getValues(
298 OutputViewType outputValues,
299 const PointViewType inputPoints,
300 const EOperator operatorType,
301 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
302 const typename DT::execution_space::scratch_memory_space & scratchStorage,
303 const ordinal_type subcellDim,
304 const ordinal_type subcellOrdinal)
const {
306 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
307 ">>> ERROR: (Intrepid2::Basis_HVOL_QUAD_Cn_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
309 const int numPoints = inputPoints.extent(0);
310 using ScalarType =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
311 using WorkViewType = Kokkos::DynRankView< ScalarType,typename DT::execution_space::scratch_memory_space,Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
312 auto sizePerPoint = 3*this->vinv_.extent(0)*get_dimension_scalar(inputPoints);
313 WorkViewType workView(scratchStorage, sizePerPoint*team_member.team_size());
314 using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
315 switch(operatorType) {
317 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_, basisDegree_ = this->basisDegree_] (ordinal_type& pt) {
318 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type (pt,pt+1), Kokkos::ALL() );
319 const auto input = Kokkos::subview( inputPoints, range_type(pt, pt+1), Kokkos::ALL() );
320 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
321 Impl::Basis_HVOL_QUAD_Cn_FEM::Serial<OPERATOR_VALUE>::getValues( output, input, work, vinv_, basisDegree_);
325 INTREPID2_TEST_FOR_ABORT(
true,
326 ">>> ERROR (Basis_HVOL_QUAD_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...
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.
Kokkos::DynRankView< typename ScalarViewType::value_type, DeviceType > vinv_
inverse of Generalized Vandermonde matrix (isotropic order)
Basis_HVOL_QUAD_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
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_QUAD_Cn_FEM.
See Intrepid2::Basis_HVOL_QUAD_Cn_FEM.