Intrepid2
Intrepid2_HDIV_HEX_In_FEM.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 
16 #ifndef __INTREPID2_HDIV_HEX_IN_FEM_HPP__
17 #define __INTREPID2_HDIV_HEX_IN_FEM_HPP__
18 
19 #include "Intrepid2_Basis.hpp"
22 
23 namespace Intrepid2 {
24 
25  namespace Impl {
26 
31  public:
32  typedef struct Hexahedron<8> cell_topology_type;
36  template<EOperator opType>
37  struct Serial {
38  template<typename outputValueViewType,
39  typename inputPointViewType,
40  typename workViewType,
41  typename vinvViewType>
42  KOKKOS_INLINE_FUNCTION
43  static void
44  getValues( outputValueViewType outputValues,
45  const inputPointViewType inputPoints,
46  workViewType work,
47  const vinvViewType vinvLine,
48  const vinvViewType vinvBubble );
49 
50  KOKKOS_INLINE_FUNCTION
51  static ordinal_type
52  getWorkSizePerPoint(ordinal_type order) {
53  return 2*getPnCardinality<1>(order)+2*getPnCardinality<1>(order-1);
54  }
55  };
56 
57  template<typename DeviceType, ordinal_type numPtsPerEval,
58  typename outputValueValueType, class ...outputValueProperties,
59  typename inputPointValueType, class ...inputPointProperties,
60  typename vinvValueType, class ...vinvProperties>
61  static void
62  getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
63  const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
64  const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvLine,
65  const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvBubble,
66  const EOperator operatorType );
67 
71  template<typename outputValueViewType,
72  typename inputPointViewType,
73  typename vinvViewType,
74  typename workViewType,
75  EOperator opType,
76  ordinal_type numPtsEval>
77  struct Functor {
78  outputValueViewType _outputValues;
79  const inputPointViewType _inputPoints;
80  const vinvViewType _vinvLine;
81  const vinvViewType _vinvBubble;
82  workViewType _work;
83 
84  KOKKOS_INLINE_FUNCTION
85  Functor( outputValueViewType outputValues_,
86  inputPointViewType inputPoints_,
87  vinvViewType vinvLine_,
88  vinvViewType vinvBubble_,
89  workViewType work_)
90  : _outputValues(outputValues_), _inputPoints(inputPoints_),
91  _vinvLine(vinvLine_), _vinvBubble(vinvBubble_), _work(work_) {}
92 
93  KOKKOS_INLINE_FUNCTION
94  void operator()(const size_type iter) const {
95  const auto ptBegin = Util<ordinal_type>::min(iter*numPtsEval, _inputPoints.extent(0));
96  const auto ptEnd = Util<ordinal_type>::min(ptBegin+numPtsEval, _inputPoints.extent(0));
97 
98  const auto ptRange = Kokkos::pair<ordinal_type,ordinal_type>(ptBegin, ptEnd);
99  const auto input = Kokkos::subview( _inputPoints, ptRange, Kokkos::ALL() );
100 
101  typename workViewType::pointer_type ptr = _work.data() + _work.extent(0)*ptBegin*get_dimension_scalar(_work);
102 
103  auto vcprop = Kokkos::common_view_alloc_prop(_work);
104  workViewType work(Kokkos::view_wrap(ptr,vcprop), (ptEnd-ptBegin)*_work.extent(0));
105 
106  switch (opType) {
107  case OPERATOR_VALUE : {
108  auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange, Kokkos::ALL() );
109  Serial<opType>::getValues( output, input, work, _vinvLine, _vinvBubble );
110  break;
111  }
112  case OPERATOR_DIV : {
113  auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange );
114  Serial<opType>::getValues( output, input, work, _vinvLine, _vinvBubble );
115  break;
116  }
117  default: {
118  INTREPID2_TEST_FOR_ABORT( true,
119  ">>> ERROR: (Intrepid2::Basis_HDIV_HEX_In_FEM::Functor) operator is not supported." );
120 
121  }
122  }
123  }
124  };
125  };
126  }
127 
135  template<typename DeviceType = void,
136  typename outputValueType = double,
137  typename pointValueType = double>
139  : public Basis<DeviceType,outputValueType,pointValueType> {
140  public:
142  using OrdinalTypeArray1DHost = typename BasisBase::OrdinalTypeArray1DHost;
143  using OrdinalTypeArray2DHost = typename BasisBase::OrdinalTypeArray2DHost;
144  using OrdinalTypeArray3DHost = typename BasisBase::OrdinalTypeArray3DHost;
145 
148  Basis_HDIV_HEX_In_FEM(const ordinal_type order,
149  const EPointType pointType = POINTTYPE_EQUISPACED);
150 
151  using OutputViewType = typename BasisBase::OutputViewType;
152  using PointViewType = typename BasisBase::PointViewType;
153  using ScalarViewType = typename BasisBase::ScalarViewType;
154 
155  using BasisBase::getValues;
156 
157  virtual
158  void
159  getValues( OutputViewType outputValues,
160  const PointViewType inputPoints,
161  const EOperator operatorType = OPERATOR_VALUE ) const override {
162 #ifdef HAVE_INTREPID2_DEBUG
163  Intrepid2::getValues_HDIV_Args(outputValues,
164  inputPoints,
165  operatorType,
166  this->getBaseCellTopology(),
167  this->getCardinality() );
168 #endif
169  constexpr ordinal_type numPtsPerEval = 1;
170  Impl::Basis_HDIV_HEX_In_FEM::
171  getValues<DeviceType,numPtsPerEval>( outputValues,
172  inputPoints,
173  this->vinvLine_,
174  this->vinvBubble_,
175  operatorType );
176  }
177 
178  virtual void
179  getScratchSpaceSize( ordinal_type& perTeamSpaceSize,
180  ordinal_type& perThreadSpaceSize,
181  const PointViewType inputPointsconst,
182  const EOperator operatorType = OPERATOR_VALUE) const override;
183 
184  KOKKOS_INLINE_FUNCTION
185  virtual void
186  getValues(
187  OutputViewType outputValues,
188  const PointViewType inputPoints,
189  const EOperator operatorType,
190  const typename Kokkos::TeamPolicy<typename DeviceType::execution_space>::member_type& team_member,
191  const typename DeviceType::execution_space::scratch_memory_space & scratchStorage,
192  const ordinal_type subcellDim = -1,
193  const ordinal_type subcellOrdinal = -1) const override;
194 
195  virtual
196  void
197  getDofCoords( ScalarViewType dofCoords ) const override {
198 #ifdef HAVE_INTREPID2_DEBUG
199  // Verify rank of output array.
200  INTREPID2_TEST_FOR_EXCEPTION( dofCoords.rank() != 2, std::invalid_argument,
201  ">>> ERROR: (Intrepid2::Basis_HDIV_HEX_In_FEM::getDofCoords) rank = 2 required for dofCoords array");
202  // Verify 0th dimension of output array.
203  INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(dofCoords.extent(0)) != this->getCardinality(), std::invalid_argument,
204  ">>> ERROR: (Intrepid2::Basis_HDIV_HEX_In_FEM::getDofCoords) mismatch in number of dof and 0th dimension of dofCoords array");
205  // Verify 1st dimension of output array.
206  INTREPID2_TEST_FOR_EXCEPTION( dofCoords.extent(1) != this->getBaseCellTopology().getDimension(), std::invalid_argument,
207  ">>> ERROR: (Intrepid2::Basis_HDIV_HEX_In_FEM::getDofCoords) incorrect reference cell (1st) dimension in dofCoords array");
208 #endif
209  Kokkos::deep_copy(dofCoords, this->dofCoords_);
210  }
211 
212 
213  virtual
214  void
215  getDofCoeffs( ScalarViewType dofCoeffs ) const override {
216 #ifdef HAVE_INTREPID2_DEBUG
217  // Verify rank of output array.
218  INTREPID2_TEST_FOR_EXCEPTION( dofCoeffs.rank() != 2, std::invalid_argument,
219  ">>> ERROR: (Intrepid2::Basis_HDIV_HEX_In_FEM::getDofCoeffs) rank = 2 required for dofCoeffs array");
220  // Verify 0th dimension of output array.
221  INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(dofCoeffs.extent(0)) != this->getCardinality(), std::invalid_argument,
222  ">>> ERROR: (Intrepid2::Basis_HDIV_HEX_In_FEM::getDofCoeffs) mismatch in number of dof and 0th dimension of dofCoeffs array");
223  // Verify 1st dimension of output array.
224  INTREPID2_TEST_FOR_EXCEPTION( dofCoeffs.extent(1) != this->getBaseCellTopology().getDimension(), std::invalid_argument,
225  ">>> ERROR: (Intrepid2::Basis_HDIV_HEX_In_FEM::getDofCoeffs) incorrect reference cell (1st) dimension in dofCoeffs array");
226 #endif
227  Kokkos::deep_copy(dofCoeffs, this->dofCoeffs_);
228  }
229 
230  virtual
231  const char*
232  getName() const override {
233  return "Intrepid2_HDIV_HEX_In_FEM";
234  }
235 
236  virtual
237  bool
238  requireOrientation() const override {
239  return true;
240  }
241 
251  BasisPtr<DeviceType,outputValueType,pointValueType>
252  getSubCellRefBasis(const ordinal_type subCellDim, const ordinal_type subCellOrd) const override{
253 
254  if(subCellDim == 2) {
255  return Teuchos::rcp(new
257  (this->basisDegree_-1,POINTTYPE_GAUSS));
258  }
259  INTREPID2_TEST_FOR_EXCEPTION(true,std::invalid_argument,"Input parameters out of bounds");
260  }
261 
262  BasisPtr<typename Kokkos::HostSpace::device_type,outputValueType,pointValueType>
263  getHostBasis() const override{
265  }
266  private:
267 
269  Kokkos::DynRankView<typename ScalarViewType::value_type,DeviceType> vinvLine_, vinvBubble_;
270  EPointType pointType_;
271  };
272 
273 }// namespace Intrepid2
274 
276 
277 #endif
See Intrepid2::Basis_HDIV_HEX_In_FEM.
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
small utility functions
ordinal_type getCardinality() const
Returns cardinality of the basis.
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, Kokkos::LayoutStride, DeviceType > ScalarViewType
View type for scalars.
virtual bool requireOrientation() const override
True if orientation is required.
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.
Basis_HDIV_HEX_In_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
Kokkos::View< ordinal_type **, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray2DHost
View type for 2d host array.
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, DeviceType > OutputViewType
View type for basis value output.
Definition file for FEM basis functions of degree n for H(div) functions on HEX cells.
Header file for the Intrepid2::Basis_HVOL_QUAD_Cn_FEM class.
Implementation of the default HVOL-compatible FEM basis of degree n on Quadrilateral cell Implements ...
Header file for the Intrepid2::Basis_HGRAD_QUAD_Cn_FEM class.
Kokkos::DynRankView< typename ScalarViewType::value_type, DeviceType > vinvLine_
inverse of Generalized Vandermonde matrix (isotropic order)
BasisPtr< typename Kokkos::HostSpace::device_type, outputValueType, pointValueType > getHostBasis() const override
Creates and returns a Basis object whose DeviceType template argument is Kokkos::HostSpace::device_ty...
Kokkos::View< ordinal_type ***, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray3DHost
View type for 3d host array.
BasisPtr< DeviceType, outputValueType, pointValueType > getSubCellRefBasis(const ordinal_type subCellDim, const ordinal_type subCellOrd) const override
returns the basis associated to a subCell.
Kokkos::DynRankView< scalarType, DeviceType > dofCoeffs_
Coefficients for computing degrees of freedom for Lagrangian basis If P is an element of the space sp...
Implementation of the default H(div)-compatible FEM basis on Hexahedron cell.
virtual const char * getName() const override
Returns basis name.
Kokkos::DynRankView< scalarType, DeviceType > dofCoords_
Coordinates of degrees-of-freedom for basis functions defined in physical space.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
Header file for the abstract base class Intrepid2::Basis.