Intrepid2
Intrepid2_HGRAD_QUAD_Cn_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
15
16#ifndef __INTREPID2_HGRAD_QUAD_CN_FEM_HPP__
17#define __INTREPID2_HGRAD_QUAD_CN_FEM_HPP__
18
19#include "Intrepid2_Basis.hpp"
21
22namespace Intrepid2 {
23
24 namespace Impl {
25
30 public:
31 typedef struct Quadrilateral<4> cell_topology_type;
32
38 template<EOperator opType>
39 struct Serial {
40 template<typename outputValueViewType,
41 typename inputPointViewType,
42 typename workViewType,
43 typename vinvViewType>
44 KOKKOS_INLINE_FUNCTION
45 static void
46 getValues( outputValueViewType outputValues,
47 const inputPointViewType inputPoints,
48 workViewType work,
49 const vinvViewType vinv,
50 const ordinal_type operatorDn = 0 );
51 };
52
53 template<typename DeviceType, ordinal_type numPtsPerEval,
54 typename outputValueValueType, class ...outputValueProperties,
55 typename inputPointValueType, class ...inputPointProperties,
56 typename vinvValueType, class ...vinvProperties>
57 static void
58 getValues( const typename DeviceType::execution_space& space,
59 Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
60 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
61 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
62 const EOperator operatorType);
63
64
68 template<typename outputValueViewType,
69 typename inputPointViewType,
70 typename vinvViewType,
71 typename workViewType,
72 EOperator opType,
73 ordinal_type numPtsEval>
74 struct Functor {
75 outputValueViewType _outputValues;
76 const inputPointViewType _inputPoints;
77 const vinvViewType _vinv;
78 workViewType _work;
79 const ordinal_type _opDn;
80
81 KOKKOS_INLINE_FUNCTION
82 Functor( outputValueViewType outputValues_,
83 inputPointViewType inputPoints_,
84 vinvViewType vinv_,
85 workViewType work_,
86 const ordinal_type opDn_ = 0 )
87 : _outputValues(outputValues_), _inputPoints(inputPoints_),
88 _vinv(vinv_), _work(work_), _opDn(opDn_) {}
89
90 KOKKOS_INLINE_FUNCTION
91 void operator()(const size_type iter) const {
92 const auto ptBegin = Util<ordinal_type>::min(iter*numPtsEval, _inputPoints.extent(0));
93 const auto ptEnd = Util<ordinal_type>::min(ptBegin+numPtsEval, _inputPoints.extent(0));
94
95 const auto ptRange = Kokkos::pair<ordinal_type,ordinal_type>(ptBegin, ptEnd);
96 const auto input = Kokkos::subview( _inputPoints, ptRange, Kokkos::ALL() );
97
98 typename workViewType::pointer_type ptr = _work.data() + _work.extent(0)*ptBegin*get_dimension_scalar(_work);
99
100 workViewType work = createMatchingUnmanagedView<workViewType>(_work, ptr, (ptEnd-ptBegin)*_work.extent(0));
101
102 switch (opType) {
103 case OPERATOR_VALUE : {
104 auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange );
105 Serial<opType>::getValues( output, input, work, _vinv );
106 break;
107 }
108 case OPERATOR_CURL :
109 case OPERATOR_Dn : {
110 auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange, Kokkos::ALL() );
111 Serial<opType>::getValues( output, input, work, _vinv, _opDn );
112 break;
113 }
114 default: {
115 INTREPID2_TEST_FOR_ABORT( true,
116 ">>> ERROR: (Intrepid2::Basis_HGRAD_QUAD_Cn_FEM::Functor) operator is not supported");
117
118 }
119 }
120 }
121 };
122 };
123 }
124
130 template<typename DeviceType = void,
131 typename outputValueType = double,
132 typename pointValueType = double>
134 : public Basis<DeviceType,outputValueType,pointValueType> {
135 public:
136 using BasisBase = Basis<DeviceType, outputValueType, pointValueType>;
137 using typename BasisBase::ExecutionSpace;
141
142 using typename BasisBase::OutputViewType;
143 using typename BasisBase::PointViewType;
144 using typename BasisBase::ScalarViewType;
145
146 private:
148 Kokkos::DynRankView<typename ScalarViewType::value_type,DeviceType> vinv_;
149
151 EPointType pointType_;
152
153 public:
156 Basis_HGRAD_QUAD_Cn_FEM(const ordinal_type order,
157 const EPointType pointType = POINTTYPE_EQUISPACED);
158
160
161 virtual
162 void
163 getValues( const ExecutionSpace& space,
164 OutputViewType outputValues,
165 const PointViewType inputPoints,
166 const EOperator operatorType = OPERATOR_VALUE ) const override {
167#ifdef HAVE_INTREPID2_DEBUG
169 inputPoints,
170 operatorType,
171 this->getBaseCellTopology(),
172 this->getCardinality() );
173#endif
174 constexpr ordinal_type numPtsPerEval = Parameters::MaxNumPtsPerBasisEval;
175 Impl::Basis_HGRAD_QUAD_Cn_FEM::
176 getValues<DeviceType,numPtsPerEval>(space,
177 outputValues,
178 inputPoints,
179 this->vinv_,
180 operatorType);
181 }
182
183 virtual void
184 getScratchSpaceSize( ordinal_type& perTeamSpaceSize,
185 ordinal_type& perThreadSpaceSize,
186 const PointViewType inputPointsconst,
187 const EOperator operatorType = OPERATOR_VALUE) const override;
188
189 KOKKOS_INLINE_FUNCTION
190 virtual void
191 getValues(
192 OutputViewType outputValues,
193 const PointViewType inputPoints,
194 const EOperator operatorType,
195 const typename Kokkos::TeamPolicy<typename DeviceType::execution_space>::member_type& team_member,
196 const typename DeviceType::execution_space::scratch_memory_space & scratchStorage,
197 const ordinal_type subcellDim = -1,
198 const ordinal_type subcellOrdinal = -1) const override;
199
200 virtual
201 void
202 getDofCoords( ScalarViewType dofCoords ) const override {
203#ifdef HAVE_INTREPID2_DEBUG
204 // Verify rank of output array.
205 INTREPID2_TEST_FOR_EXCEPTION( rank(dofCoords) != 2, std::invalid_argument,
206 ">>> ERROR: (Intrepid2::Basis_HGRAD_QUAD_Cn_FEM::getDofCoords) rank = 2 required for dofCoords array");
207 // Verify 0th dimension of output array.
208 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(dofCoords.extent(0)) != this->getCardinality(), std::invalid_argument,
209 ">>> ERROR: (Intrepid2::Basis_HGRAD_QUAD_Cn_FEM::getDofCoords) mismatch in number of dof and 0th dimension of dofCoords array");
210 // Verify 1st dimension of output array.
211 INTREPID2_TEST_FOR_EXCEPTION( dofCoords.extent(1) != this->getBaseCellTopology().getDimension(), std::invalid_argument,
212 ">>> ERROR: (Intrepid2::Basis_HGRAD_QUAD_Cn_FEM::getDofCoords) incorrect reference cell (1st) dimension in dofCoords array");
213#endif
214 Kokkos::deep_copy(dofCoords, this->dofCoords_);
215 }
216
217 virtual
218 void
219 getDofCoeffs( ScalarViewType dofCoeffs ) const override {
220#ifdef HAVE_INTREPID2_DEBUG
221 // Verify rank of output array.
222 INTREPID2_TEST_FOR_EXCEPTION( rank(dofCoeffs) != 1, std::invalid_argument,
223 ">>> ERROR: (Intrepid2::Basis_HGRAD_QUAD_Cn_FEM::getdofCoeffs) rank = 1 required for dofCoeffs array");
224 // Verify 0th dimension of output array.
225 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(dofCoeffs.extent(0)) != this->getCardinality(), std::invalid_argument,
226 ">>> ERROR: (Intrepid2::Basis_HGRAD_QUAD_Cn_FEM::getdofCoeffs) mismatch in number of dof and 0th dimension of dofCoeffs array");
227#endif
228 Kokkos::deep_copy(dofCoeffs, 1.0);
229 }
230
231 virtual
232 const char*
233 getName() const override {
234 return "Intrepid2_HGRAD_QUAD_Cn_FEM";
235 }
236
237 virtual
238 bool
239 requireOrientation() const override {
240 return (this->basisDegree_ > 2);
241 }
242
243 Kokkos::DynRankView<typename ScalarViewType::const_value_type,DeviceType>
244 getVandermondeInverse() const {
245 return vinv_;
246 }
247
248 ordinal_type
249 getWorkSizePerPoint(const EOperator operatorType) const {
250 return 3*getPnCardinality<1>(this->basisDegree_);
251 }
252
261 BasisPtr<DeviceType,outputValueType,pointValueType>
262 getSubCellRefBasis(const ordinal_type subCellDim, const ordinal_type subCellOrd) const override{
263 if(subCellDim == 1) {
264 return Teuchos::rcp(new
266 (this->basisDegree_,pointType_));
267 }
268 INTREPID2_TEST_FOR_EXCEPTION(true,std::invalid_argument,"Input parameters out of bounds");
269 }
270
275 };
276
277}// namespace Intrepid2
278
280
281#endif
Header file for the abstract base class Intrepid2::Basis.
void getValues_HGRAD_Args(const outputValueViewType outputValues, const inputPointViewType inputPoints, const EOperator operatorType, const shards::CellTopology cellTopo, const ordinal_type basisCard)
Runtime check of the arguments for the getValues method in an HGRAD-conforming FEM basis....
Teuchos::RCP< Basis< DeviceType, OutputType, PointType > > BasisPtr
Basis Pointer.
Header file for the Intrepid2::Basis_HGRAD_LINE_Cn_FEM class.
Definition file for FEM basis functions of degree n for H(grad) functions on QUAD cells.
KOKKOS_INLINE_FUNCTION std::enable_if< std::is_pointer_v< CtorProp > &&!std::is_convertible_v< CtorProp, constchar * >, OutViewType >::type createMatchingUnmanagedView(const InViewType &view, const CtorProp &data, const Dims... dims)
Creates an unmanaged view that matches the value_type of the provided view The type of the output vie...
Implementation of the locally H(grad)-compatible FEM basis of variable order on the [-1,...
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...
virtual void getDofCoords(ScalarViewType dofCoords) const override
Returns spatial locations (coordinates) of degrees of freedom on the reference cell.
virtual const char * getName() const override
Returns basis name.
BasisPtr< DeviceType, outputValueType, pointValueType > getSubCellRefBasis(const ordinal_type subCellDim, const ordinal_type subCellOrd) const override
returns the basis associated to a subCell.
virtual void getDofCoeffs(ScalarViewType dofCoeffs) const override
Coefficients for computing degrees of freedom for Lagrangian basis If P is an element of the space sp...
virtual bool requireOrientation() const override
True if orientation is required.
Basis_HGRAD_QUAD_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
Kokkos::DynRankView< typename ScalarViewType::value_type, ExecutionSpace > vinv_
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
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.
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, DeviceType > OutputViewType
Kokkos::View< ordinal_type ***, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray3DHost
ordinal_type basisDegree_
Degree of the largest complete polynomial space that can be represented by the basis.
Kokkos::DynRankView< scalarType, Kokkos::LayoutStride, DeviceType > ScalarViewType
Kokkos::DynRankView< scalarType, DeviceType > dofCoords_
Coordinates of degrees-of-freedom for basis functions defined in physical space.
Kokkos::View< ordinal_type **, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray2DHost
shards::CellTopology getBaseCellTopology() const
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
See Intrepid2::Basis_HGRAD_QUAD_Cn_FEM.
static constexpr ordinal_type MaxNumPtsPerBasisEval
The maximum number of points to eval in serial mode.
See Intrepid2::Basis_HGRAD_QUAD_Cn_FEM work is a rank 1 view having the same value_type of inputPoint...