15 #ifndef Intrepid2_LegendreBasis_HVOL_LINE_h
16 #define Intrepid2_LegendreBasis_HVOL_LINE_h
18 #include <Kokkos_DynRankView.hpp>
20 #include <Intrepid2_config.h>
23 #ifdef HAVE_INTREPID2_SACADO
24 #include <KokkosExp_View_Fad.hpp>
38 template<
class DeviceType,
class OutputScalar,
class PointScalar,
39 class OutputFieldType,
class InputPointsType>
42 using ExecutionSpace =
typename DeviceType::execution_space;
43 using ScratchSpace =
typename ExecutionSpace::scratch_memory_space;
44 using OutputScratchView = Kokkos::View<OutputScalar*,ScratchSpace,Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
45 using PointScratchView = Kokkos::View<PointScalar*, ScratchSpace,Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
47 using TeamPolicy = Kokkos::TeamPolicy<ExecutionSpace>;
48 using TeamMember =
typename TeamPolicy::member_type;
50 OutputFieldType output_;
51 InputPointsType inputPoints_;
54 int numFields_, numPoints_;
58 size_t fad_size_output_;
61 int polyOrder, EOperator op)
62 : output_(output), inputPoints_(inputPoints), polyOrder_(polyOrder), op_(op),
63 fad_size_output_(getScalarDimensionForView(output))
65 numFields_ = output.extent_int(0);
66 numPoints_ = output.extent_int(1);
67 INTREPID2_TEST_FOR_EXCEPTION(numPoints_ != inputPoints.extent_int(0), std::invalid_argument,
"point counts need to match!");
68 INTREPID2_TEST_FOR_EXCEPTION(numFields_ != polyOrder_+1, std::invalid_argument,
"output field size does not match basis cardinality");
71 KOKKOS_INLINE_FUNCTION
72 void operator()(
const TeamMember & teamMember )
const
74 auto pointOrdinal = teamMember.league_rank();
75 OutputScratchView field_values_at_point;
76 if (fad_size_output_ > 0) {
77 field_values_at_point = OutputScratchView(teamMember.team_shmem(), numFields_, fad_size_output_);
80 field_values_at_point = OutputScratchView(teamMember.team_shmem(), numFields_);
83 const PointScalar x = inputPoints_(pointOrdinal,0);
88 Polynomials::legendreValues(field_values_at_point, polyOrder_, x);
105 auto derivativeOrder = getOperatorOrder(op_);
106 Polynomials::legendreDerivativeValues(field_values_at_point, polyOrder_, x, derivativeOrder);
111 device_assert(
false);
114 for (
int fieldOrdinal=0; fieldOrdinal<numFields_; fieldOrdinal++)
116 output_.access(fieldOrdinal,pointOrdinal,0) = field_values_at_point(fieldOrdinal);
123 size_t team_shmem_size (
int team_size)
const
126 size_t shmem_size = 0;
127 if (fad_size_output_ > 0)
128 shmem_size += OutputScratchView::shmem_size(numFields_, fad_size_output_);
130 shmem_size += OutputScratchView::shmem_size(numFields_);
147 template<
typename DeviceType,
148 typename OutputScalar = double,
149 typename PointScalar =
double>
151 :
public Basis<DeviceType,OutputScalar,PointScalar>
168 EPointType pointType_;
180 polyOrder_(polyOrder),
181 pointType_(pointType)
183 INTREPID2_TEST_FOR_EXCEPTION(pointType!=POINTTYPE_DEFAULT,std::invalid_argument,
"PointType not supported");
191 const int degreeLength = 1;
207 const ordinal_type tagSize = 4;
208 const ordinal_type posScDim = 0;
209 const ordinal_type posScOrd = 1;
210 const ordinal_type posDfOrd = 2;
214 for (ordinal_type i=0;i<cardinality;++i) {
215 tagView(i*tagSize+0) = 1;
216 tagView(i*tagSize+1) = 0;
217 tagView(i*tagSize+2) = i;
218 tagView(i*tagSize+3) = cardinality;
226 this->basisCardinality_,
246 return "Intrepid2_LegendreBasis_HVOL_LINE";
268 const EOperator operatorType = OPERATOR_VALUE )
const override
270 auto numPoints = inputPoints.extent_int(0);
274 FunctorType functor(outputValues, inputPoints, polyOrder_, operatorType);
276 const int outputVectorSize = getVectorSizeForHierarchicalParallelism<OutputScalar>();
277 const int pointVectorSize = getVectorSizeForHierarchicalParallelism<PointScalar>();
278 const int vectorSize = std::max(outputVectorSize,pointVectorSize);
279 const int teamSize = 1;
282 Kokkos::TeamPolicy<ExecutionSpace>(numPoints, teamSize, vectorSize);
283 Kokkos::parallel_for(
"Hierarchical_HVOL_LINE_Functor", policy , functor);
290 virtual BasisPtr<typename Kokkos::HostSpace::device_type, OutputScalar, PointScalar>
292 using HostDeviceType =
typename Kokkos::HostSpace::device_type;
294 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.
unsigned basisCellTopologyKey_
Identifier of the base topology of the cells for which the basis is defined. See the Shards package f...
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.
virtual KOKKOS_INLINE_FUNCTION void getValues(OutputViewType, const PointViewType, const EOperator, const typename Kokkos::TeamPolicy< ExecutionSpace >::member_type &teamMember, const typename ExecutionSpace::scratch_memory_space &scratchStorage, const ordinal_type subcellDim=-1, const ordinal_type subcellOrdinal=-1) const
Team-level evaluation of basis functions on a reference cell.
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.
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.