Intrepid2
Intrepid2_HDIV_QUAD_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
15
16#ifndef __INTREPID2_HDIV_QUAD_IN_FEM_HPP__
17#define __INTREPID2_HDIV_QUAD_IN_FEM_HPP__
18
19#include "Intrepid2_Basis.hpp"
22
23namespace Intrepid2 {
24
25 namespace Impl {
26
31 public:
32 typedef struct Quadrilateral<4> 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)+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 workViewType work = createMatchingUnmanagedView<workViewType>(_work, ptr, (ptEnd-ptBegin)*_work.extent(0));
104
105 switch (opType) {
106 case OPERATOR_VALUE : {
107 auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange, Kokkos::ALL() );
108 Serial<opType>::getValues( output, input, work, _vinvLine, _vinvBubble );
109 break;
110 }
111 case OPERATOR_DIV : {
112 auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange );
113 Serial<opType>::getValues( output, input, work, _vinvLine, _vinvBubble );
114 break;
115 }
116 default: {
117 INTREPID2_TEST_FOR_ABORT( true,
118 ">>> ERROR: (Intrepid2::Basis_HDIV_QUAD_In_FEM::Functor) operator is not supported");
119
120 }
121 }
122 }
123 };
124 };
125 }
126
130
131 template<typename DeviceType = void,
132 typename outputValueType = double,
133 typename pointValueType = double>
135 : public Basis<DeviceType,outputValueType,pointValueType> {
136 public:
137 using BasisBase = Basis<DeviceType, outputValueType, pointValueType>;
138 using OrdinalTypeArray1DHost = typename BasisBase::OrdinalTypeArray1DHost;
139 using OrdinalTypeArray2DHost = typename BasisBase::OrdinalTypeArray2DHost;
140 using OrdinalTypeArray3DHost = typename BasisBase::OrdinalTypeArray3DHost;
141
144 Basis_HDIV_QUAD_In_FEM(const ordinal_type order,
145 const EPointType pointType = POINTTYPE_EQUISPACED);
146
147 using OutputViewType = typename BasisBase::OutputViewType;
148 using PointViewType = typename BasisBase::PointViewType;
149 using ScalarViewType = typename BasisBase::ScalarViewType;
150
152
153 virtual
154 void
155 getValues( OutputViewType outputValues,
156 const PointViewType inputPoints,
157 const EOperator operatorType = OPERATOR_VALUE ) const override {
158#ifdef HAVE_INTREPID2_DEBUG
160 inputPoints,
161 operatorType,
162 this->getBaseCellTopology(),
163 this->getCardinality() );
164#endif
165 constexpr ordinal_type numPtsPerEval = Parameters::MaxNumPtsPerBasisEval;
166 Impl::Basis_HDIV_QUAD_In_FEM::
167 getValues<DeviceType,numPtsPerEval>( outputValues,
168 inputPoints,
169 this->vinvLine_,
170 this->vinvBubble_,
171 operatorType );
172 }
173
174 virtual void
175 getScratchSpaceSize( ordinal_type& perTeamSpaceSize,
176 ordinal_type& perThreadSpaceSize,
177 const PointViewType inputPointsconst,
178 const EOperator operatorType = OPERATOR_VALUE) const override;
179
180 KOKKOS_INLINE_FUNCTION
181 virtual void
182 getValues(
183 OutputViewType outputValues,
184 const PointViewType inputPoints,
185 const EOperator operatorType,
186 const typename Kokkos::TeamPolicy<typename DeviceType::execution_space>::member_type& team_member,
187 const typename DeviceType::execution_space::scratch_memory_space & scratchStorage,
188 const ordinal_type subcellDim = -1,
189 const ordinal_type subcellOrdinal = -1) const override;
190
191 virtual
192 void
193 getDofCoords( ScalarViewType dofCoords ) const override {
194#ifdef HAVE_INTREPID2_DEBUG
195 // Verify rank of output array.
196 INTREPID2_TEST_FOR_EXCEPTION( dofCoords.rank() != 2, std::invalid_argument,
197 ">>> ERROR: (Intrepid2::Basis_HDIV_QUAD_In_FEM::getDofCoords) rank = 2 required for dofCoords array");
198 // Verify 0th dimension of output array.
199 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(dofCoords.extent(0)) != this->getCardinality(), std::invalid_argument,
200 ">>> ERROR: (Intrepid2::Basis_HDIV_QUAD_In_FEM::getDofCoords) mismatch in number of dof and 0th dimension of dofCoords array");
201 // Verify 1st dimension of output array.
202 INTREPID2_TEST_FOR_EXCEPTION( dofCoords.extent(1) != this->getBaseCellTopology().getDimension(), std::invalid_argument,
203 ">>> ERROR: (Intrepid2::Basis_HDIV_QUAD_In_FEM::getDofCoords) incorrect reference cell (1st) dimension in dofCoords array");
204#endif
205 Kokkos::deep_copy(dofCoords, this->dofCoords_);
206 }
207
208 virtual
209 void
210 getDofCoeffs( ScalarViewType dofCoeffs ) const override {
211#ifdef HAVE_INTREPID2_DEBUG
212 // Verify rank of output array.
213 INTREPID2_TEST_FOR_EXCEPTION( dofCoeffs.rank() != 2, std::invalid_argument,
214 ">>> ERROR: (Intrepid2::Basis_HDIV_QUAD_In_FEM::getDofCoeffs) rank = 2 required for dofCoeffs array");
215 // Verify 0th dimension of output array.
216 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(dofCoeffs.extent(0)) != this->getCardinality(), std::invalid_argument,
217 ">>> ERROR: (Intrepid2::Basis_HDIV_QUAD_In_FEM::getDofCoeffs) mismatch in number of dof and 0th dimension of dofCoeffs array");
218 // Verify 1st dimension of output array.
219 INTREPID2_TEST_FOR_EXCEPTION( dofCoeffs.extent(1) != this->getBaseCellTopology().getDimension(), std::invalid_argument,
220 ">>> ERROR: (Intrepid2::Basis_HDIV_QUAD_In_FEM::getDofCoeffs) incorrect reference cell (1st) dimension in dofCoeffs array");
221#endif
222 Kokkos::deep_copy(dofCoeffs, this->dofCoeffs_);
223 }
224
225 virtual
226 const char*
227 getName() const override {
228 return "Intrepid2_HDIV_QUAD_In_FEM";
229 }
230
231 virtual
232 bool
233 requireOrientation() const override {
234 return true;
235 }
236
247 getSubCellRefBasis(const ordinal_type subCellDim, const ordinal_type subCellOrd) const override{
248 if(subCellDim == 1)
249 return Teuchos::rcp( new
251 ( this->basisDegree_ - 1, POINTTYPE_GAUSS ) );
252
253 INTREPID2_TEST_FOR_EXCEPTION(true,std::invalid_argument,"Input parameters out of bounds");
254 }
255
260 private:
261
263 Kokkos::DynRankView<typename ScalarViewType::value_type,DeviceType> vinvLine_, vinvBubble_;
264 EPointType pointType_;
265 };
266
267}// namespace Intrepid2
268
270
271#endif
Header file for the abstract base class Intrepid2::Basis.
KOKKOS_INLINE_FUNCTION ordinal_type getPnCardinality(ordinal_type n)
Returns cardinality of Polynomials of order n (P^n).
void getValues_HDIV_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 HDIV-conforming FEM basis....
Teuchos::RCP< Basis< DeviceType, OutputType, PointType > > BasisPtr
Basis Pointer.
Definition file for FEM basis functions of degree n for H(div) functions on QUAD cells.
Header file for the Intrepid2::Basis_HGRAD_LINE_Cn_FEM class.
Header file for the Intrepid2::Basis_HVOL_LINE_Cn_FEM class.
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...
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.
Basis_HDIV_QUAD_In_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
virtual bool requireOrientation() const override
True if orientation is required.
Kokkos::DynRankView< typename ScalarViewType::value_type, ExecutionSpace > vinvLine_
BasisPtr< DeviceType, outputValueType, pointValueType > getSubCellRefBasis(const ordinal_type subCellDim, const ordinal_type subCellOrd) const override
returns the basis associated to a subCell.
virtual const char * getName() const override
Returns basis name.
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...
Implementation of the locally HVOL-compatible FEM basis of variable order on the [-1,...
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
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
View type for basis value output.
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
View type for scalars.
Kokkos::DynRankView< scalarType, DeviceType > dofCoords_
Coordinates of degrees-of-freedom for basis functions defined in physical space.
Kokkos::DynRankView< scalarType, DeviceType > dofCoeffs_
Coefficients for computing degrees of freedom for Lagrangian basis If P is an element of the space sp...
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_HDIV_QUAD_In_FEM.
static constexpr ordinal_type MaxNumPtsPerBasisEval
The maximum number of points to eval in serial mode.