49 #ifndef Intrepid2_LegendreBasis_HVOL_LINE_h
50 #define Intrepid2_LegendreBasis_HVOL_LINE_h
52 #include <Kokkos_View.hpp>
53 #include <Kokkos_DynRankView.hpp>
55 #include <Intrepid2_config.h>
58 #ifdef HAVE_INTREPID2_SACADO
59 #include <KokkosExp_View_Fad.hpp>
72 template<
class ExecutionSpace,
class OutputScalar,
class PointScalar,
73 class OutputFieldType,
class InputPointsType>
76 using ScratchSpace =
typename ExecutionSpace::scratch_memory_space;
77 using OutputScratchView = Kokkos::View<OutputScalar*,ScratchSpace,Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
78 using PointScratchView = Kokkos::View<PointScalar*, ScratchSpace,Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
80 using TeamPolicy = Kokkos::TeamPolicy<ExecutionSpace>;
81 using TeamMember =
typename TeamPolicy::member_type;
83 OutputFieldType output_;
84 InputPointsType inputPoints_;
87 int numFields_, numPoints_;
91 size_t fad_size_output_;
94 int polyOrder, EOperator op)
95 : output_(output), inputPoints_(inputPoints), polyOrder_(polyOrder), op_(op),
96 fad_size_output_(getScalarDimensionForView(output))
98 numFields_ = output.extent_int(0);
99 numPoints_ = output.extent_int(1);
100 INTREPID2_TEST_FOR_EXCEPTION(numPoints_ != inputPoints.extent_int(0), std::invalid_argument,
"point counts need to match!");
101 INTREPID2_TEST_FOR_EXCEPTION(numFields_ != polyOrder_+1, std::invalid_argument,
"output field size does not match basis cardinality");
104 KOKKOS_INLINE_FUNCTION
105 void operator()(
const TeamMember & teamMember )
const
107 auto pointOrdinal = teamMember.league_rank();
108 OutputScratchView field_values_at_point;
109 if (fad_size_output_ > 0) {
110 field_values_at_point = OutputScratchView(teamMember.team_shmem(), numFields_, fad_size_output_);
113 field_values_at_point = OutputScratchView(teamMember.team_shmem(), numFields_);
116 const PointScalar x = inputPoints_(pointOrdinal,0);
121 Polynomials::legendreValues(field_values_at_point, polyOrder_, x);
138 auto derivativeOrder = getOperatorOrder(op_);
139 Polynomials::legendreDerivativeValues(field_values_at_point, polyOrder_, x, derivativeOrder);
144 device_assert(
false);
147 for (
int fieldOrdinal=0; fieldOrdinal<numFields_; fieldOrdinal++)
149 output_.access(fieldOrdinal,pointOrdinal,0) = field_values_at_point(fieldOrdinal);
156 size_t team_shmem_size (
int team_size)
const
159 size_t shmem_size = 0;
160 if (fad_size_output_ > 0)
161 shmem_size += OutputScratchView::shmem_size(numFields_, fad_size_output_);
163 shmem_size += OutputScratchView::shmem_size(numFields_);
180 template<
typename ExecutionSpace=Kokkos::DefaultExecutionSpace,
181 typename OutputScalar = double,
182 typename PointScalar =
double>
184 :
public Basis<ExecutionSpace,OutputScalar,PointScalar>
206 polyOrder_(polyOrder)
210 this->
basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Line<2> >() );
215 const int degreeLength = 1;
229 const ordinal_type tagSize = 4;
230 const ordinal_type posScDim = 0;
231 const ordinal_type posScOrd = 1;
232 const ordinal_type posDfOrd = 2;
234 OrdinalTypeArray1DHost tagView(
"tag view", cardinality*tagSize);
236 for (ordinal_type i=0;i<cardinality;++i) {
237 tagView(i*tagSize+0) = 1;
238 tagView(i*tagSize+1) = 0;
239 tagView(i*tagSize+2) = i;
240 tagView(i*tagSize+3) = cardinality;
248 this->basisCardinality_,
268 return "Intrepid2_LegendreBasis_HVOL_LINE";
289 virtual void getValues( OutputViewType outputValues,
const PointViewType inputPoints,
290 const EOperator operatorType = OPERATOR_VALUE )
const override
292 auto numPoints = inputPoints.extent_int(0);
296 FunctorType functor(outputValues, inputPoints, polyOrder_, operatorType);
298 const int outputVectorSize = getVectorSizeForHierarchicalParallelism<OutputScalar>();
299 const int pointVectorSize = getVectorSizeForHierarchicalParallelism<PointScalar>();
300 const int vectorSize = std::max(outputVectorSize,pointVectorSize);
301 const int teamSize = 1;
303 auto policy = Kokkos::TeamPolicy<ExecutionSpace>(numPoints,teamSize,vectorSize);
304 Kokkos::parallel_for( policy , functor,
"Hierarchical_HVOL_LINE_Functor");
virtual void getValues(OutputViewType outputValues, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const override
Evaluation of a FEM basis on a reference cell.
LegendreBasis_HVOL_LINE(int polyOrder)
Constructor.
OrdinalTypeArray3DHost tagToOrdinal_
DoF tag to ordinal lookup table.
Functor for computing values for the LegendreBasis_HVOL_LINE class.
ordinal_type basisCardinality_
Cardinality of the basis, i.e., the number of basis functions/degrees-of-freedom. ...
ECoordinates basisCoordinates_
The coordinate system for which the basis is defined.
EFunctionSpace functionSpace_
The function space in which the basis is defined.
An abstract base class that defines interface for concrete basis implementations for Finite Element (...
Free functions, callable from device code, that implement various polynomials useful in basis definit...
ordinal_type basisDegree_
Degree of the largest complete polynomial space that can be represented by the basis.
Implementation of an assert that can safely be called from device code.
Basis defining Legendre basis on the line, a polynomial subspace of L^2 (a.k.a. H(vol)) on the line...
EBasis basisType_
Type of the basis.
virtual const char * getName() const override
Returns basis name.
OrdinalTypeArray2DHost fieldOrdinalPolynomialDegree_
Polynomial degree for each degree of freedom. Only defined for hierarchical bases right now...
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)
Fills ordinalToTag_ and tagToOrdinal_ by basis-specific tag data.
OrdinalTypeArray2DHost ordinalToTag_
"true" if tagToOrdinal_ and ordinalToTag_ have been initialized
shards::CellTopology basisCellTopology_
Base topology of the cells for which the basis is defined. See the Shards package for definition of b...