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
30 Basis_HVOL_QUAD_Cn_FEM::Serial<OpType>::
31 getValues( OutputViewType output,
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;
51 auto vcprop = Kokkos::common_view_alloc_prop(input);
54 case OPERATOR_VALUE: {
55 ViewType work_line(Kokkos::view_wrap(ptr0, vcprop), cardLine, npts);
56 ViewType output_x(Kokkos::view_wrap(ptr1, vcprop), cardLine, npts);
57 ViewType output_y(Kokkos::view_wrap(ptr2, vcprop), cardLine, npts);
59 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
60 getValues(output_x, input_x, work_line, vinv);
62 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
63 getValues(output_y, input_y, work_line, vinv);
67 for (ordinal_type j=0;j<cardLine;++j)
68 for (ordinal_type i=0;i<cardLine;++i,++idx)
69 for (ordinal_type k=0;k<npts;++k)
70 output.access(idx,k) = output_x.access(i,k)*output_y.access(j,k);
84 opDn = getOperatorOrder(OpType);
86 const auto dkcard = opDn + 1;
87 for (
auto l=0;l<dkcard;++l) {
88 ViewType work_line(Kokkos::view_wrap(ptr0, vcprop), cardLine, npts);
90 ViewType output_x, output_y;
92 const auto mult_x = opDn - l;
93 const auto mult_y = l;
96 output_x = ViewType(Kokkos::view_wrap(ptr1, vcprop), cardLine, npts, 1);
97 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
98 getValues(output_x, input_x, work_line, vinv, mult_x);
100 output_x = ViewType(Kokkos::view_wrap(ptr1, vcprop), cardLine, npts);
101 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
102 getValues(output_x, input_x, work_line, vinv);
106 output_y = ViewType(Kokkos::view_wrap(ptr2, vcprop), cardLine, npts, 1);
107 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
108 getValues(output_y, input_y, work_line, vinv, mult_y);
110 output_y = ViewType(Kokkos::view_wrap(ptr2, vcprop), cardLine, npts);
111 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
112 getValues(output_y, input_y, work_line, vinv);
116 ordinal_type idx = 0;
117 for (ordinal_type j=0;j<cardLine;++j)
118 for (ordinal_type i=0;i<cardLine;++i,++idx)
119 for (ordinal_type k=0;k<npts;++k)
120 output.access(idx,k,l) = output_x.access(i,k,0)*output_y.access(j,k,0);
125 INTREPID2_TEST_FOR_ABORT(
true,
126 ">>> ERROR: (Intrepid2::Basis_HVOL_QUAD_Cn_FEM::Serial::getValues) operator is not supported" );
131 template<
typename DT, ordinal_type numPtsPerEval,
132 typename outputValueValueType,
class ...outputValueProperties,
133 typename inputPointValueType,
class ...inputPointProperties,
134 typename vinvValueType,
class ...vinvProperties>
136 Basis_HVOL_QUAD_Cn_FEM::
137 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
138 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
139 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
140 const EOperator operatorType ) {
141 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
142 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
143 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
144 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
147 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
148 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
149 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
150 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
152 typedef typename inputPointViewType::value_type inputPointType;
154 const ordinal_type cardinality = outputValues.extent(0);
155 const ordinal_type cardLine = std::sqrt(cardinality);
156 const ordinal_type workSize = 3*cardLine;
158 auto vcprop = Kokkos::common_view_alloc_prop(inputPoints);
159 typedef typename Kokkos::DynRankView< inputPointType, typename inputPointViewType::memory_space> workViewType;
160 workViewType work(Kokkos::view_alloc(
"Basis_HVOL_QUAD_Cn_FEM::getValues::work", vcprop), workSize, inputPoints.extent(0));
162 switch (operatorType) {
163 case OPERATOR_VALUE: {
164 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,workViewType,
165 OPERATOR_VALUE,numPtsPerEval> FunctorType;
166 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
180 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,workViewType,
181 OPERATOR_Dn,numPtsPerEval> FunctorType;
182 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work,
183 getOperatorOrder(operatorType)) );
187 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
188 ">>> ERROR (Basis_HVOL_QUAD_Cn_FEM): Operator type not implemented" );
196 template<
typename DT,
typename OT,
typename PT>
199 const EPointType pointType ) {
208 this->pointType_ = pointType;
209 this->vinv_ = Kokkos::DynRankView<typename ScalarViewType::value_type,DT>(
"HVOL::Quad::Cn::vinv", cardLine, cardLine);
210 lineBasis.getVandermondeInverse(this->vinv_);
212 const ordinal_type spaceDim = 2;
213 this->basisCardinality_ = cardLine*cardLine;
214 this->basisDegree_ = order;
215 this->basisCellTopologyKey_ = shards::Quadrilateral<4>::key;
216 this->basisType_ = BASIS_FEM_LAGRANGIAN;
217 this->basisCoordinates_ = COORDINATES_CARTESIAN;
218 this->functionSpace_ = FUNCTION_SPACE_HVOL;
223 const ordinal_type tagSize = 4;
224 const ordinal_type posScDim = 0;
225 const ordinal_type posScOrd = 1;
226 const ordinal_type posDfOrd = 2;
230 ordinal_type tags[maxCardLine*maxCardLine][4];
233 ordinal_type idx = 0;
234 for (ordinal_type j=0;j<cardLine;++j) {
235 const auto tag_y = lineBasis.
getDofTag(j);
236 for (ordinal_type i=0;i<cardLine;++i,++idx) {
237 const auto tag_x = lineBasis.
getDofTag(i);
242 tags[idx][2] = tag_x(2) + tag_x(3)*tag_y(2);
243 tags[idx][3] = tag_x(3)*tag_y(3);
252 this->setOrdinalTagData(this->tagToOrdinal_,
255 this->basisCardinality_,
263 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
264 dofCoordsHost(
"dofCoordsHost", this->basisCardinality_, spaceDim);
266 Kokkos::DynRankView<typename ScalarViewType::value_type,DT>
267 dofCoordsLine(
"dofCoordsLine", cardLine, 1);
270 auto dofCoordsLineHost = Kokkos::create_mirror_view(dofCoordsLine);
271 Kokkos::deep_copy(dofCoordsLineHost, dofCoordsLine);
273 ordinal_type idx = 0;
274 for (ordinal_type j=0;j<cardLine;++j) {
275 for (ordinal_type i=0;i<cardLine;++i,++idx) {
276 dofCoordsHost(idx,0) = dofCoordsLineHost(i,0);
277 dofCoordsHost(idx,1) = dofCoordsLineHost(j,0);
282 this->dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoordsHost);
283 Kokkos::deep_copy(this->dofCoords_, dofCoordsHost);
286 template<
typename DT,
typename OT,
typename PT>
289 ordinal_type& perTeamSpaceSize,
290 ordinal_type& perThreadSpaceSize,
292 const EOperator operatorType)
const {
293 perTeamSpaceSize = 0;
294 perThreadSpaceSize = 3*this->vinv_.extent(0)*get_dimension_scalar(inputPoints)*
sizeof(
typename BasisBase::scalarType);
297 template<
typename DT,
typename OT,
typename PT>
298 KOKKOS_INLINE_FUNCTION
301 OutputViewType outputValues,
302 const PointViewType inputPoints,
303 const EOperator operatorType,
304 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
305 const typename DT::execution_space::scratch_memory_space & scratchStorage,
306 const ordinal_type subcellDim,
307 const ordinal_type subcellOrdinal)
const {
309 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
310 ">>> ERROR: (Intrepid2::Basis_HVOL_QUAD_Cn_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
312 const int numPoints = inputPoints.extent(0);
313 using ScalarType =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
314 using WorkViewType = Kokkos::DynRankView< ScalarType,typename DT::execution_space::scratch_memory_space,Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
315 auto sizePerPoint = 3*this->vinv_.extent(0)*get_dimension_scalar(inputPoints);
316 WorkViewType workView(scratchStorage, sizePerPoint*team_member.team_size());
317 using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
318 switch(operatorType) {
320 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
321 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type (pt,pt+1), Kokkos::ALL() );
322 const auto input = Kokkos::subview( inputPoints, range_type(pt, pt+1), Kokkos::ALL() );
323 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
328 INTREPID2_TEST_FOR_ABORT(
true,
329 ">>> ERROR (Basis_HVOL_QUAD_Cn_FEM): getValues not implemented for this operator");
const OrdinalTypeArrayStride1DHost getDofTag(const ordinal_type dofOrd) const
DoF ordinal to DoF tag lookup.
virtual void getDofCoords(ScalarViewType dofCoords) const override
Returns spatial locations (coordinates) of degrees of freedom on the reference cell.
ordinal_type getCardinality() const
Returns cardinality of the basis.
ScalarTraits< pointValueType >::scalar_type scalarType
Scalar type for point values.
virtual void getValues(OutputViewType outputValues, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const override
Basis_HVOL_QUAD_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
virtual void getScratchSpaceSize(ordinal_type &perTeamSpaceSize, ordinal_type &perThreadSpaceSize, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const override
Return the size of the scratch space, in bytes, needed for using the team-level implementation of get...
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
Implementation of the locally HVOL-compatible FEM basis of variable order on the [-1,1] reference line cell, using Lagrange polynomials.
See Intrepid2::Basis_HVOL_QUAD_Cn_FEM.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.