Intrepid2
Intrepid2_HierarchicalBasis_HDIV_TRI.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Intrepid2 Package
4 //
5 // Copyright 2007 NTESS and the Intrepid2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
17 #ifndef Intrepid2_HierarchicalBasis_HDIV_TRI_h
18 #define Intrepid2_HierarchicalBasis_HDIV_TRI_h
19 
20 #include <Kokkos_DynRankView.hpp>
21 
22 #include <Intrepid2_config.h>
23 
24 #include "Intrepid2_Basis.hpp"
27 #include "Intrepid2_Utils.hpp"
28 
29 namespace Intrepid2
30 {
31 
40  template<typename DeviceType,
41  typename OutputScalar = double,
42  typename PointScalar = double,
43  bool useCGBasis = true> // if useCGBasis is false, all basis functions will be associated with the interior
45  : public HierarchicalBasis_HCURL_TRI<DeviceType,OutputScalar,PointScalar,useCGBasis>
46  {
47  public:
49 
51 
53 
54  using typename BasisBase::OrdinalTypeArray1DHost;
55  using typename BasisBase::OrdinalTypeArray2DHost;
56 
57  using typename BasisBase::OutputViewType;
58  using typename BasisBase::PointViewType;
59  using typename BasisBase::ScalarViewType;
60 
61  using typename BasisBase::ExecutionSpace;
62 
63  public:
68  HierarchicalBasis_HDIV_TRI(int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
69  :
70  CurlBasis(polyOrder,pointType)
71  {
72  this->functionSpace_ = FUNCTION_SPACE_HDIV; // CurlBasis will set the other Basis member variables correctly…
73  }
74 
79  const char* getName() const override {
80  return "Intrepid2_HierarchicalBasis_HDIV_TRI";
81  }
82 
85  virtual bool requireOrientation() const override {
86  return (this->getDegree() > 2);
87  }
88 
89  // since the getValues() below only overrides the FEM variant, we specify that
90  // we use the base class's getValues(), which implements the FVD variant by throwing an exception.
91  // (It's an error to use the FVD variant on this basis.)
93 
112  virtual void getValues( OutputViewType outputValues, const PointViewType inputPoints,
113  const EOperator operatorType = OPERATOR_VALUE ) const override
114  {
115  // H(div) functions are a rotation of the corresponding H(curl) functions
116  if (operatorType == OPERATOR_DIV)
117  {
118  this->CurlBasis::getValues(outputValues, inputPoints, OPERATOR_CURL);
119  }
120  else if (operatorType == OPERATOR_VALUE)
121  {
122  this->CurlBasis::getValues(outputValues, inputPoints, OPERATOR_VALUE);
123 
124  const ordinal_type numFields = outputValues.extent_int(0);
125  const ordinal_type numPoints = outputValues.extent_int(1);
126 
127  auto policy = Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<2>>(Kokkos::Array<int,2>{0,0},Kokkos::Array<int,2>{numFields,numPoints});
128 
129  // multiply by [[0 1] [-1 0]]
130  Kokkos::parallel_for("apply rotation to H(curl) values", policy,
131  KOKKOS_LAMBDA (const int &fieldOrdinal, const int &pointOrdinal) {
132  const auto tempValue = outputValues(fieldOrdinal,pointOrdinal,0);
133  outputValues(fieldOrdinal,pointOrdinal,0) = outputValues(fieldOrdinal,pointOrdinal,1);
134  outputValues(fieldOrdinal,pointOrdinal,1) = -tempValue;
135  });
136  }
137  }
138 
143  virtual BasisPtr<typename Kokkos::HostSpace::device_type, OutputScalar, PointScalar>
144  getHostBasis() const override {
145  using HostDeviceType = typename Kokkos::HostSpace::device_type;
147  return Teuchos::rcp( new HostBasisType(this->CurlBasis::polyOrder_) );
148  }
149  };
150 } // end namespace Intrepid2
151 
152 #endif /* Intrepid2_HierarchicalBasis_HDIV_TRI_h */
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
const char * getName() const override
Returns basis name.
Kokkos::DynRankView< scalarType, Kokkos::LayoutStride, DeviceType > ScalarViewType
View type for scalars.
virtual bool requireOrientation() const override
True if orientation is required.
Free functions, callable from device code, that implement various polynomials useful in basis definit...
H(curl) basis on the triangle using a construction involving Legendre and integrated Jacobi polynomia...
EFunctionSpace functionSpace_
The function space in which the basis is defined.
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.
Header function for Intrepid2::Util class and other utility functions.
For mathematical details of the construction, see:
Kokkos::View< ordinal_type **, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray2DHost
View type for 2d host array.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
HierarchicalBasis_HDIV_TRI(int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Constructor.
virtual void getValues(OutputViewType outputValues, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const override
Evaluation of a FEM basis on a reference cell.
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 getDegree() const
Returns the degree of the basis.
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, DeviceType > OutputViewType
View type for basis value output.
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.
For mathematical details of the construction, see:
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...