50 #ifndef __INTREPID2_BASIS_HPP__
51 #define __INTREPID2_BASIS_HPP__
53 #include "Intrepid2_ConfigDefs.hpp"
58 #include "Kokkos_Vector.hpp"
59 #include "Shards_CellTopology.hpp"
101 template<
typename ExecSpaceType = void,
102 typename outputValueType = double,
103 typename pointValueType =
double>
167 typedef typename ScalarTraits<pointValueType>::scalar_type
scalarType;
237 template<
typename OrdinalTypeView3D,
238 typename OrdinalTypeView2D,
239 typename OrdinalTypeView1D>
241 OrdinalTypeView2D &ordinalToTag,
242 const OrdinalTypeView1D tags,
243 const ordinal_type basisCard,
244 const ordinal_type tagSize,
245 const ordinal_type posScDim,
246 const ordinal_type posScOrd,
247 const ordinal_type posDfOrd ) {
249 ordinalToTag = OrdinalTypeView2D(
"ordinalToTag", basisCard, tagSize);
252 Kokkos::deep_copy( ordinalToTag, -1 );
255 for (ordinal_type i=0;i<basisCard;++i)
256 for (ordinal_type j=0;j<tagSize;++j)
257 ordinalToTag(i, j) = tags(i*tagSize + j);
261 for (ordinal_type i=0;i<basisCard;++i)
262 if (maxScDim < tags(i*tagSize + posScDim))
263 maxScDim = tags(i*tagSize + posScDim);
267 for (ordinal_type i=0;i<basisCard;++i)
268 if (maxScOrd < tags(i*tagSize + posScOrd))
269 maxScOrd = tags(i*tagSize + posScOrd);
273 for (ordinal_type i=0;i<basisCard;++i)
274 if (maxDfOrd < tags(i*tagSize + posDfOrd))
275 maxDfOrd = tags(i*tagSize + posDfOrd);
279 tagToOrdinal = OrdinalTypeView3D(
"tagToOrdinal", maxScDim, maxScOrd, maxDfOrd);
282 Kokkos::deep_copy( tagToOrdinal, -1 );
285 for (ordinal_type i=0;i<basisCard;++i)
286 tagToOrdinal(tags(i*tagSize), tags(i*tagSize+1), tags(i*tagSize+2)) = i;
315 virtual~
Basis() =
default;
328 using OutputViewType = Kokkos::DynRankView<OutputValueType,Kokkos::LayoutStride,ExecSpaceType>;
332 using PointViewType = Kokkos::DynRankView<PointValueType,Kokkos::LayoutStride,ExecSpaceType>;
336 using ScalarViewType = Kokkos::DynRankView<scalarType,Kokkos::LayoutStride,ExecSpaceType>;
360 const EOperator = OPERATOR_VALUE )
const {
361 INTREPID2_TEST_FOR_EXCEPTION(
true, std::logic_error,
362 ">>> ERROR (Basis::getValues): this method (FEM) is not supported or should be overridden accordingly by derived classes.");
389 const EOperator = OPERATOR_VALUE )
const {
390 INTREPID2_TEST_FOR_EXCEPTION(
true, std::logic_error,
391 ">>> ERROR (Basis::getValues): this method (FVM) is not supported or should be overridden accordingly by derived classes.");
401 INTREPID2_TEST_FOR_EXCEPTION(
true, std::logic_error,
402 ">>> ERROR (Basis::getDofCoords): this method is not supported or should be overridden accordingly by derived classes.");
416 INTREPID2_TEST_FOR_EXCEPTION(
true, std::logic_error,
417 ">>> ERROR (Basis::getDofCoeffs): this method is not supported or should be overridden accordingly by derived classes.");
429 INTREPID2_TEST_FOR_EXCEPTION(
basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
430 ">>> ERROR (Basis::getFieldOrdinalsForDegree): this method is not supported for non-hierarchical bases.");
432 int requestedDegreeLength = degrees.extent_int(0);
433 INTREPID2_TEST_FOR_EXCEPTION(degreeEntryLength != requestedDegreeLength, std::invalid_argument,
"length of degrees does not match the entries in fieldOrdinalPolynomialDegree_");
434 std::vector<int> fieldOrdinalsVector;
438 for (
int d=0; d<degreeEntryLength; d++)
442 if (matches) fieldOrdinalsVector.push_back(basisOrdinal);
445 for (
unsigned i=0; i<fieldOrdinalsVector.size(); i++)
447 fieldOrdinals(i) = fieldOrdinalsVector[i];
449 return fieldOrdinals;
465 INTREPID2_TEST_FOR_EXCEPTION(
basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
466 ">>> ERROR (Basis::getFieldOrdinalsForDegree): this method is not supported for non-hierarchical bases.");
468 for (
unsigned d=0; d<degrees.size(); d++)
470 degreesView(d) = degrees[d];
473 std::vector<int> fieldOrdinalsVector(fieldOrdinalsView.extent_int(0));
474 for (
int i=0; i<fieldOrdinalsView.extent_int(0); i++)
476 fieldOrdinalsVector[i] = fieldOrdinalsView(i);
478 return fieldOrdinalsVector;
489 INTREPID2_TEST_FOR_EXCEPTION(
basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
490 ">>> ERROR (Basis::getPolynomialDegreeOfField): this method is not supported for non-hierarchical bases.");
491 INTREPID2_TEST_FOR_EXCEPTION(fieldOrdinal < 0, std::invalid_argument,
"field ordinal must be non-negative");
492 INTREPID2_TEST_FOR_EXCEPTION(fieldOrdinal >=
fieldOrdinalPolynomialDegree_.extent_int(0), std::invalid_argument,
"field ordinal out of bounds");
496 for (
int d=0; d<polyDegreeLength; d++)
512 INTREPID2_TEST_FOR_EXCEPTION(
basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
513 ">>> ERROR (Basis::getPolynomialDegreeOfFieldAsVector): this method is not supported for non-hierarchical bases.");
515 std::vector<int> polynomialDegree(polynomialDegreeView.extent_int(0));
517 for (
unsigned d=0; d<polynomialDegree.size(); d++)
519 polynomialDegree[d] = polynomialDegreeView(d);
521 return polynomialDegree;
528 INTREPID2_TEST_FOR_EXCEPTION(
basisType_ != BASIS_FEM_HIERARCHICAL, std::logic_error,
529 ">>> ERROR (Basis::getPolynomialDegreeLength): this method is not supported for non-hierarchical bases.");
540 return "Intrepid2_Basis";
618 const ordinal_type subcOrd )
const {
619 if ( subcDim >= 0 && subcDim < static_cast<ordinal_type>(
tagToOrdinal_.extent(0)) &&
620 subcOrd >= 0 && subcOrd < static_cast<ordinal_type>(
tagToOrdinal_.extent(1)) )
623 if (firstDofOrdinal == -1)
return static_cast<ordinal_type
>(0);
625 return static_cast<ordinal_type
>(this->
getDofTag(firstDofOrdinal)[3]);
630 return static_cast<ordinal_type
>(0);
644 const ordinal_type subcOrd,
645 const ordinal_type subcDofOrd )
const {
647 #ifdef HAVE_INTREPID2_DEBUG
648 INTREPID2_TEST_FOR_EXCEPTION( subcDim < 0 || subcDim >= static_cast<ordinal_type>(
tagToOrdinal_.extent(0)), std::out_of_range,
649 ">>> ERROR (Basis::getDofOrdinal): subcDim is out of range");
650 INTREPID2_TEST_FOR_EXCEPTION( subcOrd < 0 || subcOrd >= static_cast<ordinal_type>(
tagToOrdinal_.extent(1)), std::out_of_range,
651 ">>> ERROR (Basis::getDofOrdinal): subcOrd is out of range");
652 INTREPID2_TEST_FOR_EXCEPTION( subcDofOrd < 0 || subcDofOrd >= static_cast<ordinal_type>(
tagToOrdinal_.extent(2)), std::out_of_range,
653 ">>> ERROR (Basis::getDofOrdinal): subcDofOrd is out of range");
655 ordinal_type r_val = -1;
656 if ( subcDim < static_cast<ordinal_type>(
tagToOrdinal_.extent(0)) &&
657 subcOrd < static_cast<ordinal_type>(
tagToOrdinal_.extent(1)) &&
658 subcDofOrd < static_cast<ordinal_type>(
tagToOrdinal_.extent(2)) )
660 #ifdef HAVE_INTREPID2_DEBUG
661 INTREPID2_TEST_FOR_EXCEPTION( r_val == -1, std::runtime_error,
662 ">>> ERROR (Basis::getDofOrdinal): Invalid DoF tag is found.");
686 #ifdef HAVE_INTREPID2_DEBUG
687 INTREPID2_TEST_FOR_EXCEPTION( dofOrd < 0 || dofOrd >= static_cast<ordinal_type>(
ordinalToTag_.extent(0)), std::out_of_range,
688 ">>> ERROR (Basis::getDofTag): dofOrd is out of range");
690 return Kokkos::subview(
ordinalToTag_, dofOrd, Kokkos::ALL());
732 KOKKOS_INLINE_FUNCTION
733 ordinal_type getFieldRank(
const EFunctionSpace spaceType);
770 KOKKOS_INLINE_FUNCTION
771 ordinal_type getOperatorRank(
const EFunctionSpace spaceType,
772 const EOperator operatorType,
773 const ordinal_type spaceDim);
780 KOKKOS_INLINE_FUNCTION
781 ordinal_type getOperatorOrder(
const EOperator operatorType);
783 template<EOperator operatorType>
784 KOKKOS_INLINE_FUNCTION
785 constexpr ordinal_type getOperatorOrder();
810 template<ordinal_type spaceDim>
811 KOKKOS_INLINE_FUNCTION
812 ordinal_type getDkEnumeration(
const ordinal_type xMult,
813 const ordinal_type yMult = -1,
814 const ordinal_type zMult = -1);
827 template<ordinal_type spaceDim>
828 KOKKOS_INLINE_FUNCTION
829 ordinal_type getPnEnumeration(
const ordinal_type p,
830 const ordinal_type q = 0,
831 const ordinal_type r = 0);
853 template<
typename value_type>
854 KOKKOS_INLINE_FUNCTION
855 void getJacobyRecurrenceCoeffs (
859 const ordinal_type alpha,
860 const ordinal_type beta ,
861 const ordinal_type n);
900 KOKKOS_INLINE_FUNCTION
901 ordinal_type getDkCardinality(
const EOperator operatorType,
902 const ordinal_type spaceDim);
904 template<EOperator operatorType, ordinal_type spaceDim>
905 KOKKOS_INLINE_FUNCTION
906 constexpr ordinal_type getDkCardinality();
919 template<ordinal_type spaceDim>
920 KOKKOS_INLINE_FUNCTION
921 ordinal_type getPnCardinality (ordinal_type n);
923 template<ordinal_type spaceDim, ordinal_type n>
924 KOKKOS_INLINE_FUNCTION
925 constexpr ordinal_type getPnCardinality ();
944 template<
typename outputValueViewType,
945 typename inputPointViewType>
946 void getValues_HGRAD_Args(
const outputValueViewType outputValues,
947 const inputPointViewType inputPoints,
948 const EOperator operatorType,
949 const shards::CellTopology cellTopo,
950 const ordinal_type basisCard );
962 template<
typename outputValueViewType,
963 typename inputPointViewType>
964 void getValues_HCURL_Args(
const outputValueViewType outputValues,
965 const inputPointViewType inputPoints,
966 const EOperator operatorType,
967 const shards::CellTopology cellTopo,
968 const ordinal_type basisCard );
980 template<
typename outputValueViewType,
981 typename inputPointViewType>
982 void getValues_HDIV_Args(
const outputValueViewType outputValues,
983 const inputPointViewType inputPoints,
984 const EOperator operatorType,
985 const shards::CellTopology cellTopo,
986 const ordinal_type basisCard );
998 template<
typename outputValueViewType,
999 typename inputPointViewType>
1000 void getValues_HVOL_Args(
const outputValueViewType outputValues,
1001 const inputPointViewType inputPoints,
1002 const EOperator operatorType,
1003 const shards::CellTopology cellTopo,
1004 const ordinal_type basisCard );
Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::PointValueType PointValueType
Point value type for basis; default is double.
const OrdinalTypeArray3DHost getAllDofOrdinal() const
DoF tag to ordinal data structure.
Kokkos::View< ECoordinates, Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace > ECoordinatesViewType
View for coordinate system type.
Kokkos::View< ordinal_type *, typename Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
Kokkos::View< ordinal_type **, typename Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray2DHost
View type for 2d host array.
OrdinalTypeArray3DHost tagToOrdinal_
DoF tag to ordinal lookup table.
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.
const OrdinalTypeArray2DHost getAllDofTags() const
Retrieves all DoF tags.
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 (...
shards::CellTopology getBaseCellTopology() const
Returns the base cell topology for which the basis is defined. See Shards documentation https://trili...
Kokkos::DynRankView< scalarType, ExecSpaceType > dofCoords_
Coordinates of degrees-of-freedom for basis functions defined in physical space.
Kokkos::View< ordinal_type ***, Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace > OrdinalTypeArray3D
View type for 3d device array.
Kokkos::View< ordinal_type *, Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace > OrdinalTypeArray1D
View type for 1d device array.
ordinal_type getCardinality() const
Returns cardinality of the basis.
virtual void getValues(OutputViewType, const PointViewType, const EOperator=OPERATOR_VALUE) const
Evaluation of a FEM basis on a reference cell.
ordinal_type basisDegree_
Degree of the largest complete polynomial space that can be represented by the basis.
Header function for Intrepid2::Util class and other utility functions.
ordinal_type getDofOrdinal(const ordinal_type subcDim, const ordinal_type subcOrd, const ordinal_type subcDofOrd) const
DoF tag to ordinal lookup.
int getPolynomialDegreeLength() const
For hierarchical bases, returns the number of entries required to specify the polynomial degree of a ...
virtual bool requireOrientation() const
True if orientation is required.
std::vector< int > getPolynomialDegreeOfFieldAsVector(int fieldOrdinal) const
For hierarchical bases, returns the polynomial degree (which may have multiple values in higher spati...
std::vector< int > getFieldOrdinalsForDegree(std::vector< int > °rees) const
For hierarchical bases, returns the field ordinals that have at most the specified degree in each dim...
EBasis basisType_
Type of the basis.
virtual void getValues(OutputViewType, const PointViewType, const PointViewType, const EOperator=OPERATOR_VALUE) const
Evaluation of an FVD basis evaluation on a physical cell.
Kokkos::View< ordinal_type **, Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace > OrdinalTypeArray2D
View type for 2d device array.
PointValueType getDummyPointValue()
Dummy array to receive input arguments.
virtual void getDofCoeffs(ScalarViewType) const
Coefficients for computing degrees of freedom for Lagrangian basis If P is an element of the space sp...
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace > OutputViewType
View type for basis value output.
ordinal_type getDofCount(const ordinal_type subcDim, const ordinal_type subcOrd) const
DoF count for specified subcell.
EFunctionSpace getFunctionSpace() const
Returns the function space for the basis.
OrdinalTypeArray2DHost fieldOrdinalPolynomialDegree_
Polynomial degree for each degree of freedom. Only defined for hierarchical bases right now...
Kokkos::View< ordinal_type ***, typename Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray3DHost
View type for 3d host array.
Kokkos::View< EBasis, Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace > EBasisViewType
View for basis type.
Contains definitions of custom data types in Intrepid2.
ordinal_type getDegree() const
Returns the degree of the basis.
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.
virtual const char * getName() const
Returns basis name.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace > PointViewType
View type for input points.
OutputValueType getDummyOutputValue()
Dummy array to receive input arguments.
virtual void getDofCoords(ScalarViewType) const
Returns spatial locations (coordinates) of degrees of freedom on the reference cell.
Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::OutputValueType OutputValueType
Output value type for basis; default is double.
Kokkos::DynRankView< scalarType, Kokkos::LayoutStride, Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace > ScalarViewType
View type for scalars.
Kokkos::DynRankView< scalarType, ExecSpaceType > dofCoeffs_
Coefficients for computing degrees of freedom for Lagrangian basis If P is an element of the space sp...
OrdinalTypeArray1DHost getFieldOrdinalsForDegree(OrdinalTypeArray1DHost °rees) const
For hierarchical bases, returns the field ordinals that have at most the specified degree in each dim...
Kokkos::View< ordinal_type, Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace > OrdinalViewType
View type for ordinal.
const OrdinalTypeArrayStride1DHost getDofTag(const ordinal_type dofOrd) const
DoF ordinal to DoF tag lookup.
Implementation file for the abstract base class Intrepid2::Basis.
ECoordinates getCoordinateSystem() const
Returns the type of coordinate system for which the basis is defined.
ScalarTraits< pointValueType >::scalar_type scalarType
Scalar type for point values.
Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace ExecutionSpace
(Kokkos) Execution space for basis.
OrdinalTypeArray1DHost getPolynomialDegreeOfField(int fieldOrdinal) const
For hierarchical bases, returns the polynomial degree (which may have multiple values in higher spati...
EBasis getBasisType() const
Returns the basis type.
Kokkos::View< ordinal_type *, Kokkos::LayoutStride, Basis_TensorBasis< HVOL_LINE, HVOL_LINE >::ExecutionSpace > OrdinalTypeArrayStride1D
View type for 1d device array.
Kokkos::View< ordinal_type *, Kokkos::LayoutStride, Kokkos::HostSpace > OrdinalTypeArrayStride1DHost
View type for 1d host array.
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...