49 #ifndef __INTREPID2_BASIS_HPP__ 50 #define __INTREPID2_BASIS_HPP__ 52 #include "Intrepid2_ConfigDefs.hpp" 57 #include "Shards_CellTopology.hpp" 90 template<
typename ExecSpaceType = void,
91 typename outputValueType = double,
92 typename pointValueType =
double>
145 typedef typename ScalarTraits<pointValueType>::scalar_type
scalarType;
212 template<
typename OrdinalTypeView3D,
213 typename OrdinalTypeView2D,
214 typename OrdinalTypeView1D>
216 OrdinalTypeView2D &ordinalToTag,
217 const OrdinalTypeView1D tags,
218 const ordinal_type basisCard,
219 const ordinal_type tagSize,
220 const ordinal_type posScDim,
221 const ordinal_type posScOrd,
222 const ordinal_type posDfOrd ) {
224 ordinalToTag = OrdinalTypeView2D(
"ordinalToTag", basisCard, tagSize);
227 Kokkos::deep_copy( ordinalToTag, -1 );
230 for (ordinal_type i=0;i<basisCard;++i)
231 for (ordinal_type j=0;j<tagSize;++j)
232 ordinalToTag(i, j) = tags(i*tagSize + j);
236 for (ordinal_type i=0;i<basisCard;++i)
237 if (maxScDim < tags(i*tagSize + posScDim))
238 maxScDim = tags(i*tagSize + posScDim);
242 for (ordinal_type i=0;i<basisCard;++i)
243 if (maxScOrd < tags(i*tagSize + posScOrd))
244 maxScOrd = tags(i*tagSize + posScOrd);
248 for (ordinal_type i=0;i<basisCard;++i)
249 if (maxDfOrd < tags(i*tagSize + posDfOrd))
250 maxDfOrd = tags(i*tagSize + posDfOrd);
254 tagToOrdinal = OrdinalTypeView3D(
"tagToOrdinal", maxScDim, maxScOrd, maxDfOrd);
257 Kokkos::deep_copy( tagToOrdinal, -1 );
260 for (ordinal_type i=0;i<basisCard;++i)
261 tagToOrdinal(tags(i*tagSize), tags(i*tagSize+1), tags(i*tagSize+2)) = i;
282 virtual~
Basis() =
default;
295 typedef Kokkos::DynRankView<outputValueType,Kokkos::LayoutStride,ExecSpaceType>
outputViewType;
299 typedef Kokkos::DynRankView<pointValueType,Kokkos::LayoutStride,ExecSpaceType>
pointViewType;
303 typedef Kokkos::DynRankView<scalarType,Kokkos::LayoutStride,ExecSpaceType>
scalarViewType;
327 const EOperator operatorType = OPERATOR_VALUE )
const {
328 INTREPID2_TEST_FOR_EXCEPTION(
true, std::logic_error,
329 ">>> ERROR (Basis::getValues): this method (FEM) is not supported or should be over-riden accordingly by derived classes.");
356 const EOperator operatorType = OPERATOR_VALUE )
const {
357 INTREPID2_TEST_FOR_EXCEPTION(
true, std::logic_error,
358 ">>> ERROR (Basis::getValues): this method (FVM) is not supported or should be over-riden accordingly by derived classes.");
368 INTREPID2_TEST_FOR_EXCEPTION(
true, std::logic_error,
369 ">>> ERROR (Basis::getDofCoords): this method is not supported or should be over-riden accordingly by derived classes.");
383 INTREPID2_TEST_FOR_EXCEPTION(
true, std::logic_error,
384 ">>> ERROR (Basis::getDofCoeffs): this method is not supported or should be over-riden accordingly by derived classes.");
395 return "Intrepid2_Basis";
465 const ordinal_type subcOrd )
const {
466 if ( subcDim >= 0 && subcDim < static_cast<ordinal_type>(
tagToOrdinal_.extent(0)) &&
467 subcOrd >= 0 && subcOrd < static_cast<ordinal_type>(
tagToOrdinal_.extent(1)) )
470 if (firstDofOrdinal == -1)
return static_cast<ordinal_type
>(0);
472 return static_cast<ordinal_type
>(this->
getDofTag(firstDofOrdinal)[3]);
477 return static_cast<ordinal_type
>(0);
491 const ordinal_type subcOrd,
492 const ordinal_type subcDofOrd )
const {
494 #ifdef HAVE_INTREPID2_DEBUG 495 INTREPID2_TEST_FOR_EXCEPTION( subcDim < 0 || subcDim >= static_cast<ordinal_type>(
tagToOrdinal_.extent(0)), std::out_of_range,
496 ">>> ERROR (Basis::getDofOrdinal): subcDim is out of range");
497 INTREPID2_TEST_FOR_EXCEPTION( subcOrd < 0 || subcOrd >= static_cast<ordinal_type>(
tagToOrdinal_.extent(1)), std::out_of_range,
498 ">>> ERROR (Basis::getDofOrdinal): subcOrd is out of range");
499 INTREPID2_TEST_FOR_EXCEPTION( subcDofOrd < 0 || subcDofOrd >= static_cast<ordinal_type>(
tagToOrdinal_.extent(2)), std::out_of_range,
500 ">>> ERROR (Basis::getDofOrdinal): subcDofOrd is out of range");
502 ordinal_type r_val = -1;
503 if ( subcDim < static_cast<ordinal_type>(
tagToOrdinal_.extent(0)) &&
504 subcOrd < static_cast<ordinal_type>(
tagToOrdinal_.extent(1)) &&
505 subcDofOrd < static_cast<ordinal_type>(
tagToOrdinal_.extent(2)) )
507 #ifdef HAVE_INTREPID2_DEBUG 508 INTREPID2_TEST_FOR_EXCEPTION( r_val == -1, std::runtime_error,
509 ">>> ERROR (Basis::getDofOrdinal): Invalid DoF tag is found.");
533 #ifdef HAVE_INTREPID2_DEBUG 534 INTREPID2_TEST_FOR_EXCEPTION( dofOrd < 0 || dofOrd >= static_cast<ordinal_type>(
ordinalToTag_.extent(0)), std::out_of_range,
535 ">>> ERROR (Basis::getDofTag): dofOrd is out of range");
537 return Kokkos::subview(
ordinalToTag_, dofOrd, Kokkos::ALL());
579 KOKKOS_INLINE_FUNCTION
580 ordinal_type getFieldRank(
const EFunctionSpace spaceType);
617 KOKKOS_INLINE_FUNCTION
618 ordinal_type getOperatorRank(
const EFunctionSpace spaceType,
619 const EOperator operatorType,
620 const ordinal_type spaceDim);
627 KOKKOS_INLINE_FUNCTION
628 ordinal_type getOperatorOrder(
const EOperator operatorType);
630 template<EOperator operatorType>
631 KOKKOS_INLINE_FUNCTION
632 constexpr ordinal_type getOperatorOrder();
657 template<ordinal_type spaceDim>
658 KOKKOS_INLINE_FUNCTION
659 ordinal_type getDkEnumeration(
const ordinal_type xMult,
660 const ordinal_type yMult = -1,
661 const ordinal_type zMult = -1);
674 template<ordinal_type spaceDim>
675 KOKKOS_INLINE_FUNCTION
676 ordinal_type getPnEnumeration(
const ordinal_type p,
677 const ordinal_type q = 0,
678 const ordinal_type r = 0);
700 template<
typename value_type>
701 KOKKOS_INLINE_FUNCTION
702 void getJacobyRecurrenceCoeffs (
706 const ordinal_type alpha,
707 const ordinal_type beta ,
708 const ordinal_type n);
747 KOKKOS_INLINE_FUNCTION
748 ordinal_type getDkCardinality(
const EOperator operatorType,
749 const ordinal_type spaceDim);
751 template<EOperator operatorType, ordinal_type spaceDim>
752 KOKKOS_INLINE_FUNCTION
753 constexpr ordinal_type getDkCardinality();
766 template<ordinal_type spaceDim>
767 KOKKOS_INLINE_FUNCTION
768 ordinal_type getPnCardinality (ordinal_type n);
770 template<ordinal_type spaceDim, ordinal_type n>
771 KOKKOS_INLINE_FUNCTION
772 constexpr ordinal_type getPnCardinality ();
791 template<
typename outputValueViewType,
792 typename inputPointViewType>
793 void getValues_HGRAD_Args(
const outputValueViewType outputValues,
794 const inputPointViewType inputPoints,
795 const EOperator operatorType,
796 const shards::CellTopology cellTopo,
797 const ordinal_type basisCard );
809 template<
typename outputValueViewType,
810 typename inputPointViewType>
811 void getValues_HCURL_Args(
const outputValueViewType outputValues,
812 const inputPointViewType inputPoints,
813 const EOperator operatorType,
814 const shards::CellTopology cellTopo,
815 const ordinal_type basisCard );
827 template<
typename outputValueViewType,
828 typename inputPointViewType>
829 void getValues_HDIV_Args(
const outputValueViewType outputValues,
830 const inputPointViewType inputPoints,
831 const EOperator operatorType,
832 const shards::CellTopology cellTopo,
833 const ordinal_type basisCard );
845 template<
typename outputValueViewType,
846 typename inputPointViewType>
847 void getValues_HVOL_Args(
const outputValueViewType outputValues,
848 const inputPointViewType inputPoints,
849 const EOperator operatorType,
850 const shards::CellTopology cellTopo,
851 const ordinal_type basisCard );
Kokkos::View< ordinal_type *, Kokkos::LayoutStride, ExecSpaceType > ordinal_type_array_stride_1d
View type for 1d device array.
Kokkos::View< ordinal_type ***, ExecSpaceType > ordinal_type_array_3d
View type for 3d device array.
const ordinal_type_array_2d_host getAllDofTags() const
Retrieves all DoF tags.
Kokkos::DynRankView< scalarType, Kokkos::LayoutStride, ExecSpaceType > scalarViewType
View type for scalars.
Kokkos::View< ordinal_type **,ExecSpaceType > ordinal_type_array_2d
View type for 2d device array.
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.
ordinal_type getCardinality() const
Returns cardinality of the basis.
An abstract base class that defines interface for concrete basis implementations for Finite Element (...
Kokkos::DynRankView< outputValueType, Kokkos::LayoutStride, ExecSpaceType > outputViewType
View type for basis value output.
Kokkos::DynRankView< scalarType, ExecSpaceType > dofCoords_
Coordinates of degrees-of-freedom for basis functions defined in physical space.
const ordinal_type_array_stride_1d_host getDofTag(const ordinal_type dofOrd) const
DoF ordinal to DoF tag lookup.
virtual void getDofCoords(scalarViewType dofCoords) const
Returns spatial locations (coordinates) of degrees of freedom on the reference cell.
shards::CellTopology getBaseCellTopology() const
Returns the base cell topology for which the basis is defined. See Shards documentation https://trili...
ECoordinates
Enumeration of coordinate systems for geometrical entities (cells, points).
EBasis getBasisType() const
Returns the basis type.
Kokkos::View< ordinal_type ***, typename ExecSpaceType::array_layout, Kokkos::HostSpace > ordinal_type_array_3d_host
View type for 3d host array.
outputValueType getDummyOutputValue()
Dummy array to receive input arguments.
ordinal_type basisDegree_
Degree of the largest complete polynomial space that can be represented by the basis.
Kokkos::View< ECoordinates, ExecSpaceType > ecoordinates_view_type
View for coordinate system type.
Header function for Intrepid2::Util class and other utility functions.
ordinal_type getDofCount(const ordinal_type subcDim, const ordinal_type subcOrd) const
DoF count for specified subcell.
Kokkos::View< ordinal_type *, Kokkos::LayoutStride, Kokkos::HostSpace > ordinal_type_array_stride_1d_host
View type for 1d host array.
ordinal_type_array_2d_host ordinalToTag_
"true" if tagToOrdinal_ and ordinalToTag_ have been initialized
virtual bool requireOrientation() const
True if orientation is required.
const ordinal_type_array_3d_host getAllDofOrdinal() const
DoF tag to ordinal data structure.
EBasis basisType_
Type of the basis.
EBasis
Enumeration of basis types for discrete spaces in Intrepid.
EOperator
Enumeration of primitive operators available in Intrepid. Primitive operators act on reconstructed fu...
Kokkos::View< ordinal_type *,typename ExecSpaceType::array_layout, Kokkos::HostSpace > ordinal_type_array_1d_host
View type for 1d host array.
Kokkos::View< ordinal_type *,ExecSpaceType > ordinal_type_array_1d
View type for 1d device array.
Kokkos::DynRankView< pointValueType, Kokkos::LayoutStride, ExecSpaceType > pointViewType
View type for input points.
Contains definitions of custom data types in Intrepid2.
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.
ordinal_type_array_3d_host tagToOrdinal_
DoF tag to ordinal lookup table.
ordinal_type getDofOrdinal(const ordinal_type subcDim, const ordinal_type subcOrd, const ordinal_type subcDofOrd) const
DoF tag to ordinal lookup.
ordinal_type getDegree() const
Returns the degree of the basis.
virtual void getValues(outputViewType outputValues, const pointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const
Evaluation of a FEM basis on a reference cell.
ECoordinates getCoordinateSystem() const
Returns the type of coordinate system for which the basis is defined.
Kokkos::View< EBasis, ExecSpaceType > ebasis_view_type
View for basis type.
Kokkos::DynRankView< scalarType, ExecSpaceType > dofCoeffs_
Coefficients for computing degrees of freedom for Lagrangian basis If P is an element of the space sp...
Kokkos::View< ordinal_type, ExecSpaceType > ordinal_view_type
View type for ordinal.
virtual void getValues(outputViewType outputValues, const pointViewType inputPoints, const pointViewType cellVertices, const EOperator operatorType=OPERATOR_VALUE) const
Evaluation of an FVD basis evaluation on a physical cell.
Implementation file for the abstract base class Intrepid2::Basis.
ScalarTraits< pointValueType >::scalar_type scalarType
Scalar type for point values.
virtual void getDofCoeffs(scalarViewType dofCoeffs) const
Coefficients for computing degrees of freedom for Lagrangian basis If P is an element of the space sp...
pointValueType getDummyPointValue()
Dummy array to receive input arguments.
virtual const char * getName() const
Returns basis name.
Kokkos::View< ordinal_type **,typename ExecSpaceType::array_layout, Kokkos::HostSpace > ordinal_type_array_2d_host
View type for 2d host array.
shards::CellTopology basisCellTopology_
Base topology of the cells for which the basis is defined. See the Shards package for definition of b...