16#ifndef __INTREPID2_HGRAD_QUAD_CN_FEM_DEF_HPP__
17#define __INTREPID2_HGRAD_QUAD_CN_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 vinv,
36 const ordinal_type operatorDn ) {
37 ordinal_type opDn = operatorDn;
39 const ordinal_type cardLine = vinv.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));
46 const int 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;
51 typedef typename Kokkos::DynRankView<typename InputViewType::value_type, typename WorkViewType::memory_space> ViewType;
54 case OPERATOR_VALUE: {
59 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
60 getValues(output_x, input_x, work_line, vinv);
62 Impl::Basis_HGRAD_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);
74 for (
auto l=0;l<2;++l) {
77 ViewType output_x, output_y;
79 typename WorkViewType::value_type s = 0.0;
83 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
84 getValues(output_x, input_x, work_line, vinv, 1);
87 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
88 getValues(output_y, input_y, work_line, vinv);
94 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
95 getValues(output_x, input_x, work_line, vinv);
98 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
99 getValues(output_y, input_y, work_line, vinv, 1);
105 ordinal_type idx = 0;
106 for (ordinal_type j=0;j<cardLine;++j)
107 for (ordinal_type i=0;i<cardLine;++i,++idx)
108 for (ordinal_type k=0;k<npts;++k)
109 output.access(idx,k,l) = s*output_x.access(i,k,0)*output_y.access(j,k,0);
126 const auto dkcard = opDn + 1;
127 for (
auto l=0;l<dkcard;++l) {
130 ViewType output_x, output_y;
132 const auto mult_x = opDn - l;
133 const auto mult_y = l;
137 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
138 getValues(output_x, input_x, work_line, vinv, mult_x);
141 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
142 getValues(output_x, input_x, work_line, vinv);
147 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_Dn>::
148 getValues(output_y, input_y, work_line, vinv, mult_y);
151 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::
152 getValues(output_y, input_y, work_line, vinv);
156 ordinal_type idx = 0;
157 for (ordinal_type j=0;j<cardLine;++j)
158 for (ordinal_type i=0;i<cardLine;++i,++idx)
159 for (ordinal_type k=0;k<npts;++k)
160 output.access(idx,k,l) = output_x.access(i,k,0)*output_y.access(j,k,0);
165 INTREPID2_TEST_FOR_ABORT(
true,
166 ">>> ERROR: (Intrepid2::Basis_HGRAD_QUAD_Cn_FEM::Serial::getValues) operator is not supported" );
171 template<
typename DT, ordinal_type numPtsPerEval,
172 typename outputValueValueType,
class ...outputValueProperties,
173 typename inputPointValueType,
class ...inputPointProperties,
174 typename vinvValueType,
class ...vinvProperties>
176 Basis_HGRAD_QUAD_Cn_FEM::
177 getValues(
const typename DT::execution_space& space,
178 Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
179 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
180 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
181 const EOperator operatorType ) {
182 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
183 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
184 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
185 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
188 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
189 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
190 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
191 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(space, 0, loopSize);
195 const ordinal_type cardinality = outputValues.extent(0);
196 const ordinal_type cardLine = std::sqrt(cardinality);
197 const ordinal_type workSize = 3*cardLine;
199 auto work =
createMatchingDynRankView(inputPoints,
"Basis_HGRAD_QUAD_Cn_FEM::getValues::work", workSize, inputPoints.extent(0));
201 switch (operatorType) {
202 case OPERATOR_VALUE: {
203 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,
decltype(work),
204 OPERATOR_VALUE,numPtsPerEval> FunctorType;
205 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
208 case OPERATOR_CURL: {
209 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,
decltype(work),
210 OPERATOR_CURL,numPtsPerEval> FunctorType;
211 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
225 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,
decltype(work),
226 OPERATOR_Dn,numPtsPerEval> FunctorType;
227 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work,
232 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
233 ">>> ERROR (Basis_HGRAD_QUAD_Cn_FEM): Operator type not implemented" );
241 template<
typename DT,
typename OT,
typename PT>
244 const EPointType pointType ) {
253 this->
vinv_ = Kokkos::DynRankView<typename ScalarViewType::value_type,DT>(
"Hgrad::Quad::Cn::vinv", cardLine, cardLine);
254 lineBasis.getVandermondeInverse(this->
vinv_);
256 const ordinal_type spaceDim = 2;
268 const ordinal_type tagSize = 4;
269 const ordinal_type posScDim = 0;
270 const ordinal_type posScOrd = 1;
271 const ordinal_type posDfOrd = 2;
275 INTREPID2_TEST_FOR_EXCEPTION( order >
Parameters::MaxOrder, std::invalid_argument,
"polynomial order exceeds the max supported by this class");
278 ordinal_type tags[maxCardLine*maxCardLine][4];
280 const ordinal_type vert[2][2] = { {0,1}, {3,2} };
282 const ordinal_type edge_x[2] = {0,2};
283 const ordinal_type edge_y[2] = {3,1};
285 ordinal_type idx = 0;
286 for (ordinal_type j=0;j<cardLine;++j) {
287 const auto tag_y = lineBasis.
getDofTag(j);
288 for (ordinal_type i=0;i<cardLine;++i,++idx) {
289 const auto tag_x = lineBasis.
getDofTag(i);
291 if (tag_x(0) == 0 && tag_y(0) == 0) {
294 tags[idx][1] = vert[tag_y(1)][tag_x(1)];
297 }
else if (tag_x(0) == 1 && tag_y(0) == 0) {
300 tags[idx][1] = edge_x[tag_y(1)];
301 tags[idx][2] = tag_x(2);
302 tags[idx][3] = tag_x(3);
303 }
else if (tag_x(0) == 0 && tag_y(0) == 1) {
306 tags[idx][1] = edge_y[tag_x(1)];
307 tags[idx][2] = tag_y(2);
308 tags[idx][3] = tag_y(3);
313 tags[idx][2] = tag_x(2) + tag_x(3)*tag_y(2);
314 tags[idx][3] = tag_x(3)*tag_y(3);
335 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
338 Kokkos::DynRankView<typename ScalarViewType::value_type,DT>
339 dofCoordsLine(
"dofCoordsLine", cardLine, 1);
342 auto dofCoordsLineHost = Kokkos::create_mirror_view(dofCoordsLine);
343 Kokkos::deep_copy(dofCoordsLineHost, dofCoordsLine);
345 ordinal_type idx = 0;
346 for (ordinal_type j=0;j<cardLine;++j) {
347 for (ordinal_type i=0;i<cardLine;++i,++idx) {
348 dofCoordsHost(idx,0) = dofCoordsLineHost(i,0);
349 dofCoordsHost(idx,1) = dofCoordsLineHost(j,0);
354 this->
dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoordsHost);
355 Kokkos::deep_copy(this->
dofCoords_, dofCoordsHost);
358 template<
typename DT,
typename OT,
typename PT>
360 Basis_HGRAD_QUAD_Cn_FEM<DT,OT,PT>::getScratchSpaceSize(
361 ordinal_type& perTeamSpaceSize,
362 ordinal_type& perThreadSpaceSize,
364 const EOperator operatorType)
const {
365 perTeamSpaceSize = 0;
366 perThreadSpaceSize = 3*this->vinv_.extent(0)*get_dimension_scalar(inputPoints)*
sizeof(
typename BasisBase::scalarType);
369 template<
typename DT,
typename OT,
typename PT>
370 KOKKOS_INLINE_FUNCTION
372 Basis_HGRAD_QUAD_Cn_FEM<DT,OT,PT>::getValues(
373 OutputViewType outputValues,
374 const PointViewType inputPoints,
375 const EOperator operatorType,
376 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
377 const typename DT::execution_space::scratch_memory_space & scratchStorage,
378 const ordinal_type subcellDim,
379 const ordinal_type subcellOrdinal)
const {
381 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
382 ">>> ERROR: (Intrepid2::Basis_HGRAD_QUAD_Cn_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
384 const int numPoints = inputPoints.extent(0);
385 using ScalarType =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
386 using WorkViewType = Kokkos::DynRankView< ScalarType,typename DT::execution_space::scratch_memory_space,Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
387 ordinal_type sizePerPoint = 3*this->vinv_.extent(0)*get_dimension_scalar(inputPoints);
388 WorkViewType workView(scratchStorage, sizePerPoint*team_member.team_size());
389 using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
391 switch(operatorType) {
393 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_] (ordinal_type& pt) {
394 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type (pt,pt+1), Kokkos::ALL() );
395 const auto input = Kokkos::subview( inputPoints, range_type(pt, pt+1), Kokkos::ALL() );
396 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
397 Impl::Basis_HGRAD_QUAD_Cn_FEM::Serial<OPERATOR_VALUE>::getValues( output, input, work, vinv_ );
401 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_] (ordinal_type& pt) {
402 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type(pt,pt+1), Kokkos::ALL() );
403 const auto input = Kokkos::subview( inputPoints, range_type(pt,pt+1), Kokkos::ALL() );
404 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
405 Impl::Basis_HGRAD_QUAD_Cn_FEM::Serial<OPERATOR_GRAD>::getValues( output, input, work, vinv_ );
409 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_] (ordinal_type& pt) {
410 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type(pt,pt+1), Kokkos::ALL() );
411 const auto input = Kokkos::subview( inputPoints, range_type(pt,pt+1), Kokkos::ALL() );
412 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
413 Impl::Basis_HGRAD_QUAD_Cn_FEM::Serial<OPERATOR_CURL>::getValues( output, input, work, vinv_ );
417 INTREPID2_TEST_FOR_ABORT(
true,
418 ">>> ERROR (Basis_HGRAD_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 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.
EPointType pointType_
type of lattice used for creating the DoF coordinates
Basis_HGRAD_QUAD_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)
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_HGRAD_QUAD_Cn_FEM.
See Intrepid2::Basis_HGRAD_QUAD_Cn_FEM work is a rank 1 view having the same value_type of inputPoint...