Intrepid2
Intrepid2_HVOL_TET_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
14
15#ifndef __INTREPID2_HVOL_TET_CN_FEM_HPP__
16#define __INTREPID2_HVOL_TET_CN_FEM_HPP__
17
18#include "Intrepid2_Basis.hpp"
19
21#include "Teuchos_LAPACK.hpp"
22
23
24namespace Intrepid2 {
25
40
41 namespace Impl {
42
47 public:
48 typedef struct Tetrahedron<4> cell_topology_type;
52 template<EOperator opType>
53 struct Serial {
54 template<typename outputValueViewType,
55 typename inputPointViewType,
56 typename workViewType,
57 typename vinvViewType>
58 KOKKOS_INLINE_FUNCTION
59 static void
60 getValues( outputValueViewType outputValues,
61 const inputPointViewType inputPoints,
62 workViewType work,
63 const vinvViewType vinv );
64
65
66 KOKKOS_INLINE_FUNCTION
67 static ordinal_type
68 getWorkSizePerPoint(ordinal_type order) {
69 auto cardinality = getPnCardinality<3>(order);
70 switch (opType) {
71 case OPERATOR_GRAD:
72 case OPERATOR_CURL:
73 case OPERATOR_D1:
74 return 7*cardinality;
75 default:
76 return getDkCardinality<opType,3>()*cardinality;
77 }
78 }
79 };
80
81 template<typename DeviceType, ordinal_type numPtsPerEval,
82 typename outputValueValueType, class ...outputValueProperties,
83 typename inputPointValueType, class ...inputPointProperties,
84 typename vinvValueType, class ...vinvProperties>
85 static void
86 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
87 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
88 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
89 const EOperator operatorType);
90
94 template<typename outputValueViewType,
95 typename inputPointViewType,
96 typename vinvViewType,
97 typename workViewType,
98 EOperator opType,
99 ordinal_type numPtsEval>
100 struct Functor {
101 outputValueViewType _outputValues;
102 const inputPointViewType _inputPoints;
103 const vinvViewType _vinv;
104 workViewType _work;
105
106 KOKKOS_INLINE_FUNCTION
107 Functor( outputValueViewType outputValues_,
108 inputPointViewType inputPoints_,
109 vinvViewType vinv_,
110 workViewType work_)
111 : _outputValues(outputValues_), _inputPoints(inputPoints_),
112 _vinv(vinv_), _work(work_) {}
113
114 KOKKOS_INLINE_FUNCTION
115 void operator()(const size_type iter) const {
116 const auto ptBegin = Util<ordinal_type>::min(iter*numPtsEval, _inputPoints.extent(0));
117 const auto ptEnd = Util<ordinal_type>::min(ptBegin+numPtsEval, _inputPoints.extent(0));
118
119 const auto ptRange = Kokkos::pair<ordinal_type,ordinal_type>(ptBegin, ptEnd);
120 const auto input = Kokkos::subview( _inputPoints, ptRange, Kokkos::ALL() );
121
122 typename workViewType::pointer_type ptr = _work.data() + _work.extent(0)*ptBegin*get_dimension_scalar(_work);
123
124 workViewType work = createMatchingUnmanagedView<workViewType>(_work, ptr, (ptEnd-ptBegin)*_work.extent(0));
125
126 switch (opType) {
127 case OPERATOR_VALUE : {
128 auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange );
129 Serial<opType>::getValues( output, input, work, _vinv );
130 break;
131 }
132 case OPERATOR_GRAD :
133 case OPERATOR_D1 :
134 case OPERATOR_D2 :
135 //case OPERATOR_D3 :
136 {
137 auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange, Kokkos::ALL() );
138 Serial<opType>::getValues( output, input, work, _vinv );
139 break;
140 }
141 default: {
142 INTREPID2_TEST_FOR_ABORT( true,
143 ">>> ERROR: (Intrepid2::Basis_HVOL_TET_Cn_FEM::Functor) operator is not supported");
144
145 }
146 }
147 }
148 };
149 };
150 }
151
152 template<typename DeviceType = void,
153 typename outputValueType = double,
154 typename pointValueType = double>
156 : public Basis<DeviceType,outputValueType,pointValueType> {
157 public:
158 using BasisBase = Basis<DeviceType,outputValueType,pointValueType>;
159
163
164 using typename BasisBase::OutputViewType;
165 using typename BasisBase::PointViewType ;
166 using typename BasisBase::ScalarViewType;
167
170 Basis_HVOL_TET_Cn_FEM(const ordinal_type order,
171 const EPointType pointType = POINTTYPE_EQUISPACED);
172
173 using scalarType = typename BasisBase::scalarType;
175
176 virtual
177 void
178 getValues( OutputViewType outputValues,
179 const PointViewType inputPoints,
180 const EOperator operatorType = OPERATOR_VALUE) const override {
181#ifdef HAVE_INTREPID2_DEBUG
183 inputPoints,
184 operatorType,
185 this->getBaseCellTopology(),
186 this->getCardinality() );
187#endif
188 constexpr ordinal_type numPtsPerEval = Parameters::MaxNumPtsPerBasisEval;
189 Impl::Basis_HVOL_TET_Cn_FEM::
190 getValues<DeviceType,numPtsPerEval>( outputValues,
191 inputPoints,
192 this->vinv_,
193 operatorType);
194 }
195
196 virtual void
197 getScratchSpaceSize( ordinal_type& perTeamSpaceSize,
198 ordinal_type& perThreadSpaceSize,
199 const PointViewType inputPoints,
200 const EOperator operatorType = OPERATOR_VALUE) const override;
201
202 KOKKOS_INLINE_FUNCTION
203 virtual void
204 getValues(
205 OutputViewType outputValues,
206 const PointViewType inputPoints,
207 const EOperator operatorType,
208 const typename Kokkos::TeamPolicy<typename DeviceType::execution_space>::member_type& team_member,
209 const typename DeviceType::execution_space::scratch_memory_space & scratchStorage,
210 const ordinal_type subcellDim = -1,
211 const ordinal_type subcellOrdinal = -1) const override;
212
213
214 virtual
215 void
216 getDofCoords( ScalarViewType dofCoords ) const override {
217#ifdef HAVE_INTREPID2_DEBUG
218 // Verify rank of output array.
219 INTREPID2_TEST_FOR_EXCEPTION( dofCoords.rank() != 2, std::invalid_argument,
220 ">>> ERROR: (Intrepid2::Basis_HVOL_TET_Cn_FEM::getDofCoords) rank = 2 required for dofCoords array");
221 // Verify 0th dimension of output array.
222 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(dofCoords.extent(0)) != this->getCardinality(), std::invalid_argument,
223 ">>> ERROR: (Intrepid2::Basis_HVOL_TET_Cn_FEM::getDofCoords) mismatch in number of dof and 0th dimension of dofCoords array");
224 // Verify 1st dimension of output array.
225 INTREPID2_TEST_FOR_EXCEPTION( dofCoords.extent(1) != this->getBaseCellTopology().getDimension(), std::invalid_argument,
226 ">>> ERROR: (Intrepid2::Basis_HVOL_TET_Cn_FEM::getDofCoords) incorrect reference cell (1st) dimension in dofCoords array");
227#endif
228 Kokkos::deep_copy(dofCoords, this->dofCoords_);
229 }
230
231 virtual
232 void
233 getDofCoeffs( ScalarViewType dofCoeffs ) const override {
234#ifdef HAVE_INTREPID2_DEBUG
235 // Verify rank of output array.
236 INTREPID2_TEST_FOR_EXCEPTION( dofCoeffs.rank() != 1, std::invalid_argument,
237 ">>> ERROR: (Intrepid2::Basis_HVOL_TET_Cn_FEM::getdofCoeffs) rank = 1 required for dofCoeffs array");
238 // Verify 0th dimension of output array.
239 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(dofCoeffs.extent(0)) != this->getCardinality(), std::invalid_argument,
240 ">>> ERROR: (Intrepid2::Basis_HVOL_TET_Cn_FEM::getdofCoeffs) mismatch in number of dof and 0th dimension of dofCoeffs array");
241#endif
242 Kokkos::deep_copy(dofCoeffs, 1.0);
243 }
244
245 void
246 getVandermondeInverse( ScalarViewType vinv ) const {
247 // has to be same rank and dimensions
248 Kokkos::deep_copy(vinv, this->vinv_);
249 }
250
251 virtual
252 const char*
253 getName() const override {
254 return "Intrepid2_HVOL_TET_Cn_FEM";
255 }
256
257 virtual
258 bool
259 requireOrientation() const override {
260 return false;
261 }
262
267
268 private:
269
272 Kokkos::DynRankView<scalarType,DeviceType> vinv_;
273 EPointType pointType_;
274
275 };
276
277}// namespace Intrepid2
278
280
281#endif
Header file for the abstract base class Intrepid2::Basis.
BasisPtr< typename Kokkos::HostSpace::device_type, OutputType, PointType > HostBasisPtr
Pointer to a Basis whose device type is on the host (Kokkos::HostSpace::device_type),...
KOKKOS_INLINE_FUNCTION ordinal_type getPnCardinality(ordinal_type n)
Returns cardinality of Polynomials of order n (P^n).
KOKKOS_INLINE_FUNCTION ordinal_type getDkCardinality(const EOperator operatorType, const ordinal_type spaceDim)
Returns multiplicities of dx, dy, and dz based on the enumeration of the partial derivative,...
void getValues_HVOL_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 HVOL-conforming FEM basis....
Definition file for FEM basis functions of degree n for H(vol) functions on TET.
Header file for Intrepid2::PointTools class to provide utilities for barycentric coordinates,...
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 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...
virtual bool requireOrientation() const override
True if orientation is required.
Basis_HVOL_TET_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
virtual HostBasisPtr< 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.
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
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, DeviceType > OutputViewType
Kokkos::View< ordinal_type ***, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray3DHost
Kokkos::DynRankView< scalarType, Kokkos::LayoutStride, DeviceType > ScalarViewType
Kokkos::DynRankView< scalarType, DeviceType > dofCoords_
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_HVOL_TET_Cn_FEM.
static constexpr ordinal_type MaxNumPtsPerBasisEval
The maximum number of points to eval in serial mode.