49 #ifndef Intrepid2_LegendreBasis_HVOL_LINE_h
50 #define Intrepid2_LegendreBasis_HVOL_LINE_h
52 #include <Kokkos_DynRankView.hpp>
54 #include <Intrepid2_config.h>
57 #ifdef HAVE_INTREPID2_SACADO
58 #include <KokkosExp_View_Fad.hpp>
72 template<
class DeviceType,
class OutputScalar,
class PointScalar,
73 class OutputFieldType,
class InputPointsType>
76 using ExecutionSpace =
typename DeviceType::execution_space;
77 using ScratchSpace =
typename ExecutionSpace::scratch_memory_space;
78 using OutputScratchView = Kokkos::View<OutputScalar*,ScratchSpace,Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
79 using PointScratchView = Kokkos::View<PointScalar*, ScratchSpace,Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
81 using TeamPolicy = Kokkos::TeamPolicy<ExecutionSpace>;
82 using TeamMember =
typename TeamPolicy::member_type;
84 OutputFieldType output_;
85 InputPointsType inputPoints_;
88 int numFields_, numPoints_;
92 size_t fad_size_output_;
95 int polyOrder, EOperator op)
96 : output_(output), inputPoints_(inputPoints), polyOrder_(polyOrder), op_(op),
97 fad_size_output_(getScalarDimensionForView(output))
99 numFields_ = output.extent_int(0);
100 numPoints_ = output.extent_int(1);
101 INTREPID2_TEST_FOR_EXCEPTION(numPoints_ != inputPoints.extent_int(0), std::invalid_argument,
"point counts need to match!");
102 INTREPID2_TEST_FOR_EXCEPTION(numFields_ != polyOrder_+1, std::invalid_argument,
"output field size does not match basis cardinality");
105 KOKKOS_INLINE_FUNCTION
106 void operator()(
const TeamMember & teamMember )
const
108 auto pointOrdinal = teamMember.league_rank();
109 OutputScratchView field_values_at_point;
110 if (fad_size_output_ > 0) {
111 field_values_at_point = OutputScratchView(teamMember.team_shmem(), numFields_, fad_size_output_);
114 field_values_at_point = OutputScratchView(teamMember.team_shmem(), numFields_);
117 const PointScalar x = inputPoints_(pointOrdinal,0);
122 Polynomials::legendreValues(field_values_at_point, polyOrder_, x);
139 auto derivativeOrder = getOperatorOrder(op_);
140 Polynomials::legendreDerivativeValues(field_values_at_point, polyOrder_, x, derivativeOrder);
145 device_assert(
false);
148 for (
int fieldOrdinal=0; fieldOrdinal<numFields_; fieldOrdinal++)
150 output_.access(fieldOrdinal,pointOrdinal,0) = field_values_at_point(fieldOrdinal);
157 size_t team_shmem_size (
int team_size)
const
160 size_t shmem_size = 0;
161 if (fad_size_output_ > 0)
162 shmem_size += OutputScratchView::shmem_size(numFields_, fad_size_output_);
164 shmem_size += OutputScratchView::shmem_size(numFields_);
181 template<
typename DeviceType,
182 typename OutputScalar = double,
183 typename PointScalar =
double>
185 :
public Basis<DeviceType,OutputScalar,PointScalar>
202 EPointType pointType_;
214 polyOrder_(polyOrder),
215 pointType_(pointType)
217 INTREPID2_TEST_FOR_EXCEPTION(pointType!=POINTTYPE_DEFAULT,std::invalid_argument,
"PointType not supported");
220 this->
basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Line<2> >() );
225 const int degreeLength = 1;
241 const ordinal_type tagSize = 4;
242 const ordinal_type posScDim = 0;
243 const ordinal_type posScOrd = 1;
244 const ordinal_type posDfOrd = 2;
248 for (ordinal_type i=0;i<cardinality;++i) {
249 tagView(i*tagSize+0) = 1;
250 tagView(i*tagSize+1) = 0;
251 tagView(i*tagSize+2) = i;
252 tagView(i*tagSize+3) = cardinality;
260 this->basisCardinality_,
280 return "Intrepid2_LegendreBasis_HVOL_LINE";
302 const EOperator operatorType = OPERATOR_VALUE )
const override
304 auto numPoints = inputPoints.extent_int(0);
308 FunctorType functor(outputValues, inputPoints, polyOrder_, operatorType);
310 const int outputVectorSize = getVectorSizeForHierarchicalParallelism<OutputScalar>();
311 const int pointVectorSize = getVectorSizeForHierarchicalParallelism<PointScalar>();
312 const int vectorSize = std::max(outputVectorSize,pointVectorSize);
313 const int teamSize = 1;
316 Kokkos::TeamPolicy<ExecutionSpace>(numPoints, teamSize, vectorSize);
317 Kokkos::parallel_for(
"Hierarchical_HVOL_LINE_Functor", policy , functor);
324 virtual BasisPtr<typename Kokkos::HostSpace::device_type, OutputScalar, PointScalar>
326 using HostDeviceType =
typename Kokkos::HostSpace::device_type;
328 return Teuchos::rcp(
new HostBasisType(polyOrder_, pointType_) );
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
virtual const char * getName() const override
Returns basis name.
virtual void getValues(const ExecutionSpace &, OutputViewType, const PointViewType, const EOperator=OPERATOR_VALUE) const
Evaluation of a FEM basis on a reference cell.
EBasis basisType_
Type of the basis.
Functor for computing values for the LegendreBasis_HVOL_LINE class.
An abstract base class that defines interface for concrete basis implementations for Finite Element (...
Kokkos::DynRankView< scalarType, Kokkos::LayoutStride, DeviceType > ScalarViewType
View type for scalars.
Free functions, callable from device code, that implement various polynomials useful in basis definit...
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
EFunctionSpace functionSpace_
The function space in which the basis is defined.
ordinal_type basisDegree_
Degree of the largest complete polynomial space that can be represented by the basis.
LegendreBasis_HVOL_LINE(int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Constructor.
Implementation of an assert that can safely be called from device code.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
Kokkos::View< ordinal_type **, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray2DHost
View type for 2d host array.
Basis defining Legendre basis on the line, a polynomial subspace of L^2 (a.k.a. H(vol)) on the line...
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, DeviceType > OutputViewType
View type for basis value output.
virtual void getValues(OutputViewType outputValues, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const override
Evaluation of a FEM basis on a reference cell.
ordinal_type basisCardinality_
Cardinality of the basis, i.e., the number of basis functions/degrees-of-freedom. ...
OrdinalTypeArray3DHost tagToOrdinal_
DoF tag to ordinal lookup table.
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, DeviceType > OutputViewType
View type for basis value output.
OrdinalTypeArray2DHost ordinalToTag_
"true" if tagToOrdinal_ and ordinalToTag_ have been initialized
ECoordinates basisCoordinates_
The coordinate system for which the basis is defined.
shards::CellTopology basisCellTopology_
Base topology of the cells for which the basis is defined. See the Shards package for definition of b...
virtual BasisPtr< typename Kokkos::HostSpace::device_type, OutputScalar, PointScalar > getHostBasis() const override
Creates and returns a Basis object whose DeviceType template argument is Kokkos::HostSpace::device_ty...
OrdinalTypeArray2DHost fieldOrdinalH1PolynomialDegree_
H^1 polynomial degree for each degree of freedom. Only defined for hierarchical bases right now...
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.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
Header file for the abstract base class Intrepid2::Basis.
typename DeviceType::execution_space ExecutionSpace
(Kokkos) Execution space for basis.