Intrepid2
Intrepid2_HCURL_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
15
16#ifndef __INTREPID2_HCURL_HEX_IN_FEM_HPP__
17#define __INTREPID2_HCURL_HEX_IN_FEM_HPP__
18
19#include "Intrepid2_Basis.hpp"
21
22namespace Intrepid2 {
23
24 namespace Impl {
25
30 public:
31 typedef struct Hexahedron<8> cell_topology_type;
32
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 switch(opType) {
54 case OPERATOR_VALUE:
55 return 3*getPnCardinality<1>(order)+getPnCardinality<1>(order-1);
56 case OPERATOR_CURL:
57 return 5*getPnCardinality<1>(order)+getPnCardinality<1>(order-1);
58 default: {
59 INTREPID2_TEST_FOR_ABORT( true,
60 ">>> ERROR: (Intrepid2::Basis_HCURL_HEX_In_FEM::Serial::getWorkSizePerPoint) operator is not supported" );
61 return 0;
62 }
63 }
64 }
65 };
66
67 template<typename DeviceType, ordinal_type numPtsPerEval,
68 typename outputValueValueType, class ...outputValueProperties,
69 typename inputPointValueType, class ...inputPointProperties,
70 typename vinvValueType, class ...vinvProperties>
71 static void
72 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
73 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
74 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvLine,
75 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvBubble,
76 const EOperator operatorType );
77
81 template<typename outputValueViewType,
82 typename inputPointViewType,
83 typename vinvViewType,
84 typename workViewType,
85 EOperator opType,
86 ordinal_type numPtsEval>
87 struct Functor {
88 outputValueViewType _outputValues;
89 const inputPointViewType _inputPoints;
90 const vinvViewType _vinvLine;
91 const vinvViewType _vinvBubble;
92 workViewType _work;
93
94 KOKKOS_INLINE_FUNCTION
95 Functor( outputValueViewType outputValues_,
96 inputPointViewType inputPoints_,
97 vinvViewType vinvLine_,
98 vinvViewType vinvBubble_,
99 workViewType work_)
100 : _outputValues(outputValues_), _inputPoints(inputPoints_),
101 _vinvLine(vinvLine_), _vinvBubble(vinvBubble_), _work(work_) {}
102
103 KOKKOS_INLINE_FUNCTION
104 void operator()(const size_type iter) const {
105 const auto ptBegin = Util<ordinal_type>::min(iter*numPtsEval, _inputPoints.extent(0));
106 const auto ptEnd = Util<ordinal_type>::min(ptBegin+numPtsEval, _inputPoints.extent(0));
107
108 const auto ptRange = Kokkos::pair<ordinal_type,ordinal_type>(ptBegin, ptEnd);
109 const auto input = Kokkos::subview( _inputPoints, ptRange, Kokkos::ALL() );
110
111 typename workViewType::pointer_type ptr = _work.data() + _work.extent(0)*ptBegin*get_dimension_scalar(_work);
112
113 workViewType work = createMatchingUnmanagedView<workViewType>(_work, ptr, (ptEnd-ptBegin)*_work.extent(0));
114
115 switch (opType) {
116 case OPERATOR_VALUE : {
117 auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange, Kokkos::ALL() );
118 Serial<opType>::getValues( output, input, work, _vinvLine, _vinvBubble );
119 break;
120 }
121 case OPERATOR_CURL : {
122 auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange, Kokkos::ALL() );
123 Serial<opType>::getValues( output, input, work, _vinvLine, _vinvBubble );
124 break;
125 }
126 default: {
127 INTREPID2_TEST_FOR_ABORT( true,
128 ">>> ERROR: (Intrepid2::Basis_HCURL_HEX_In_FEM::Functor) operator is not supported." );
129
130 }
131 }
132 }
133 };
134 };
135 }
136
144 template<typename DeviceType = void,
145 typename outputValueType = double,
146 typename pointValueType = double>
148 : public Basis<DeviceType,outputValueType,pointValueType> {
149 public:
150 using BasisBase = Basis<DeviceType, outputValueType, pointValueType>;
151 using OrdinalTypeArray1DHost = typename BasisBase::OrdinalTypeArray1DHost;
152 using OrdinalTypeArray2DHost = typename BasisBase::OrdinalTypeArray2DHost;
153 using OrdinalTypeArray3DHost = typename BasisBase::OrdinalTypeArray3DHost;
154
157 Basis_HCURL_HEX_In_FEM(const ordinal_type order,
158 const EPointType pointType = POINTTYPE_EQUISPACED);
159
160 using OutputViewType = typename BasisBase::OutputViewType;
161 using PointViewType = typename BasisBase::PointViewType;
162 using ScalarViewType = typename BasisBase::ScalarViewType;
163
165
166 virtual
167 void
168 getValues( OutputViewType outputValues,
169 const PointViewType inputPoints,
170 const EOperator operatorType = OPERATOR_VALUE ) const override {
171#ifdef HAVE_INTREPID2_DEBUG
173 inputPoints,
174 operatorType,
175 this->getBaseCellTopology(),
176 this->getCardinality() );
177#endif
178 constexpr ordinal_type numPtsPerEval = 1;
179 Impl::Basis_HCURL_HEX_In_FEM::
180 getValues<DeviceType,numPtsPerEval>( outputValues,
181 inputPoints,
182 this->vinvLine_,
183 this->vinvBubble_,
184 operatorType );
185 }
186
187 virtual void
188 getScratchSpaceSize( ordinal_type& perTeamSpaceSize,
189 ordinal_type& perThreadSpaceSize,
190 const PointViewType inputPointsconst,
191 const EOperator operatorType = OPERATOR_VALUE) const override;
192
193 KOKKOS_INLINE_FUNCTION
194 virtual void
195 getValues(
196 OutputViewType outputValues,
197 const PointViewType inputPoints,
198 const EOperator operatorType,
199 const typename Kokkos::TeamPolicy<typename DeviceType::execution_space>::member_type& team_member,
200 const typename DeviceType::execution_space::scratch_memory_space & scratchStorage,
201 const ordinal_type subcellDim = -1,
202 const ordinal_type subcellOrdinal = -1) const override;
203
204 virtual
205 void
206 getDofCoords( ScalarViewType dofCoords ) const override {
207#ifdef HAVE_INTREPID2_DEBUG
208 // Verify rank of output array.
209 INTREPID2_TEST_FOR_EXCEPTION( dofCoords.rank() != 2, std::invalid_argument,
210 ">>> ERROR: (Intrepid2::Basis_HCURL_HEX_In_FEM::getDofCoords) rank = 2 required for dofCoords array");
211 // Verify 0th dimension of output array.
212 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(dofCoords.extent(0)) != this->getCardinality(), std::invalid_argument,
213 ">>> ERROR: (Intrepid2::Basis_HCURL_HEX_In_FEM::getDofCoords) mismatch in number of dof and 0th dimension of dofCoords array");
214 // Verify 1st dimension of output array.
215 INTREPID2_TEST_FOR_EXCEPTION( dofCoords.extent(1) != this->getBaseCellTopology().getDimension(), std::invalid_argument,
216 ">>> ERROR: (Intrepid2::Basis_HCURL_HEX_In_FEM::getDofCoords) incorrect reference cell (1st) dimension in dofCoords array");
217#endif
218 Kokkos::deep_copy(dofCoords, this->dofCoords_);
219 }
220
221 virtual
222 void
223 getDofCoeffs( ScalarViewType dofCoeffs ) const override {
224#ifdef HAVE_INTREPID2_DEBUG
225 // Verify rank of output array.
226 INTREPID2_TEST_FOR_EXCEPTION( dofCoeffs.rank() != 2, std::invalid_argument,
227 ">>> ERROR: (Intrepid2::Basis_HCURL_HEX_In_FEM::getDofCoeffs) rank = 2 required for dofCoeffs array");
228 // Verify 0th dimension of output array.
229 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(dofCoeffs.extent(0)) != this->getCardinality(), std::invalid_argument,
230 ">>> ERROR: (Intrepid2::Basis_HCURL_HEX_In_FEM::getDofCoeffs) mismatch in number of dof and 0th dimension of dofCoeffs array");
231 // Verify 1st dimension of output array.
232 INTREPID2_TEST_FOR_EXCEPTION( dofCoeffs.extent(1) != this->getBaseCellTopology().getDimension(), std::invalid_argument,
233 ">>> ERROR: (Intrepid2::Basis_HCURL_HEX_In_FEM::getDofCoeffs) incorrect reference cell (1st) dimension in dofCoeffs array");
234#endif
235 Kokkos::deep_copy(dofCoeffs, this->dofCoeffs_);
236 }
237
238 virtual
239 const char*
240 getName() const override {
241 return "Intrepid2_HCURL_HEX_In_FEM";
242 }
243
244 virtual
245 bool
246 requireOrientation() const override {
247 return true;
248 }
249
260 getSubCellRefBasis(const ordinal_type subCellDim, const ordinal_type subCellOrd) const override{
261 if(subCellDim == 1) {
262 return Teuchos::rcp(new
264 (this->basisDegree_-1, POINTTYPE_GAUSS));
265 } else if(subCellDim == 2) {
266 return Teuchos::rcp(new
268 (this->basisDegree_, pointType_));
269 }
270 INTREPID2_TEST_FOR_EXCEPTION(true,std::invalid_argument,"Input parameters out of bounds");
271 }
272
277
278 private:
279
281 Kokkos::DynRankView<typename ScalarViewType::value_type,DeviceType> vinvLine_, vinvBubble_;
282
284 EPointType pointType_;
285 };
286
287}// namespace Intrepid2
288
289
290
292
293#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).
Teuchos::RCP< Basis< DeviceType, OutputType, PointType > > BasisPtr
Basis Pointer.
void getValues_HCURL_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 HCURL-conforming FEM basis....
Definition file for FEM basis functions of degree n for H(curl) functions on HEX cells.
Header file for the Intrepid2::Basis_HCURL_QUAD_In_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...
virtual bool requireOrientation() const override
True if orientation is required.
Kokkos::DynRankView< typename ScalarViewType::value_type, ExecutionSpace > vinvLine_
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...
Basis_HCURL_HEX_In_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
virtual void getDofCoords(ScalarViewType dofCoords) const override
Returns spatial locations (coordinates) of degrees of freedom on the reference cell.
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 const char * getName() const override
Returns basis name.
Implementation of the default H(curl)-compatible FEM basis on Quadrilateral cell.
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_HCURL_HEX_In_FEM.