Intrepid2
Intrepid2_HGRAD_TRI_Cn_FEM_ORTH.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid2 Package
5 // Copyright (2007) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Kyungjoo Kim (kyukim@sandia.gov), or
38 // Mauro Perego (mperego@sandia.gov)
39 //
40 // ************************************************************************
41 // @HEADER
42 
49 #ifndef __INTREPID2_HGRAD_TRI_CN_FEM_ORTH_HPP__
50 #define __INTREPID2_HGRAD_TRI_CN_FEM_ORTH_HPP__
51 
52 #include "Intrepid2_Basis.hpp"
53 
54 namespace Intrepid2 {
55 
65 namespace Impl {
66 
70 template<typename OutputViewType,
71 typename inputViewType,
72 typename workViewType,
73 bool hasDeriv, ordinal_type n>
75  KOKKOS_INLINE_FUNCTION
76  static void
77  generate( OutputViewType output,
78  const inputViewType input,
79  workViewType work,
80  const ordinal_type p );
81 };
82 
86 template<typename OutputViewType,
87 typename inputViewType,
88 typename workViewType,
89 bool hasDeriv>
90 struct OrthPolynomialTri<OutputViewType,inputViewType,workViewType,hasDeriv,0> {
91  KOKKOS_INLINE_FUNCTION
92  static void
93  generate( OutputViewType output,
94  const inputViewType input,
95  workViewType work,
96  const ordinal_type p );
97 };
98 
102 template<typename OutputViewType,
103 typename inputViewType,
104 typename workViewType,
105 bool hasDeriv>
106 struct OrthPolynomialTri<OutputViewType,inputViewType,workViewType,hasDeriv,1> {
107  KOKKOS_INLINE_FUNCTION
108  static void
109  generate( OutputViewType output,
110  const inputViewType input,
111  workViewType work,
112  const ordinal_type p );
113 };
114 
119 public:
120 
124  template<EOperator opType>
125  struct Serial {
126  template<typename OutputViewType,
127  typename inputViewType,
128  typename workViewType>
129  KOKKOS_INLINE_FUNCTION
130  static void
131  getValues( OutputViewType output,
132  const inputViewType input,
133  workViewType work,
134  const ordinal_type order);
135  };
136 
137  template<typename DeviceType, ordinal_type numPtsPerEval,
138  typename outputValueValueType, class ...outputValueProperties,
139  typename inputPointValueType, class ...inputPointProperties>
140  static void
141  getValues( const typename DeviceType::execution_space& space,
142  Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
143  const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
144  const ordinal_type order,
145  const EOperator operatorType );
146 
150  template<typename outputValueViewType,
151  typename inputPointViewType,
152  typename workViewType,
153  EOperator opType,
154  ordinal_type numPtsEval>
155  struct Functor {
156  outputValueViewType _outputValues;
157  const inputPointViewType _inputPoints;
158  workViewType _work;
159  const ordinal_type _order;
160 
161  KOKKOS_INLINE_FUNCTION
162  Functor( outputValueViewType outputValues_,
163  inputPointViewType inputPoints_,
164  workViewType work_,
165  const ordinal_type order_ )
166  : _outputValues(outputValues_), _inputPoints(inputPoints_), _work(work_),_order(order_){}
167 
168  KOKKOS_INLINE_FUNCTION
169  void operator()(const size_type iter) const {
170  const auto ptBegin = Util<ordinal_type>::min(iter*numPtsEval, _inputPoints.extent(0));
171  const auto ptEnd = Util<ordinal_type>::min(ptBegin+numPtsEval, _inputPoints.extent(0));
172 
173  const auto ptRange = Kokkos::pair<ordinal_type,ordinal_type>(ptBegin, ptEnd);
174  const auto input = Kokkos::subview( _inputPoints, ptRange, Kokkos::ALL() );
175 
176  switch (opType) {
177  case OPERATOR_VALUE : {
178  auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange );
179  Serial<opType>::getValues( output, input, _work, _order ); //here work is not used
180  break;
181  }
182  case OPERATOR_GRAD :
183  case OPERATOR_D1 :
184  {
185  const auto work = Kokkos::subview( _work, Kokkos::ALL(), ptRange, Kokkos::ALL() );
186  auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange, Kokkos::ALL() );
187  Serial<opType>::getValues( output, input, work, _order);
188  break;
189  }
190  case OPERATOR_D2 :
191  case OPERATOR_D3 :
192  case OPERATOR_D4 :
193  case OPERATOR_D5 :
194  case OPERATOR_D6 :
195  case OPERATOR_D7 :
196  case OPERATOR_D8 :
197  case OPERATOR_D9 :
198  case OPERATOR_D10 :
199  {
200  auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange, Kokkos::ALL() );
201  Serial<opType>::getValues( output, input, _work, _order); //here work is not used
202  break;
203  }
204  default: {
205  INTREPID2_TEST_FOR_ABORT( true,
206  ">>> ERROR: (Intrepid2::Basis_HGRAD_TRI_Cn_FEM_ORTH::Functor) operator is not supported");
207 
208  }
209  }
210  }
211  };
212 
213 };
214 
215 }
216 
217 template<typename DeviceType = void,
218  typename outputValueType = double,
219  typename pointValueType = double>
221  : public Basis<DeviceType,outputValueType,pointValueType> {
222  public:
223  typedef double value_type;
224 
226  using typename BasisBase::ExecutionSpace;
227 
228  using typename BasisBase::OrdinalTypeArray1DHost;
229  using typename BasisBase::OrdinalTypeArray2DHost;
230  using typename BasisBase::OrdinalTypeArray3DHost;
231 
232  using typename BasisBase::OutputViewType;
233  using typename BasisBase::PointViewType ;
234  using typename BasisBase::ScalarViewType;
235 
238  Basis_HGRAD_TRI_Cn_FEM_ORTH( const ordinal_type order );
239 
240  using BasisBase::getValues;
241 
242  virtual
243  void
244  getValues( const ExecutionSpace& space,
245  OutputViewType outputValues,
246  const PointViewType inputPoints,
247  const EOperator operatorType = OPERATOR_VALUE ) const override {
248  #ifdef HAVE_INTREPID2_DEBUG
249  Intrepid2::getValues_HGRAD_Args(outputValues,
250  inputPoints,
251  operatorType,
252  this->getBaseCellTopology(),
253  this->getCardinality() );
254  #endif
255  constexpr ordinal_type numPtsPerEval = Parameters::MaxNumPtsPerBasisEval;
256  Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
257  getValues<DeviceType,numPtsPerEval>(space,
258  outputValues,
259  inputPoints,
260  this->getDegree(),
261  operatorType);
262  }
263 };
264 
265 }// namespace Intrepid2
266 
268 
269 #endif
270 
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.
virtual void getValues(const ExecutionSpace &, OutputViewType, const PointViewType, const EOperator=OPERATOR_VALUE) const
Evaluation of a FEM basis on a reference cell.
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...
Implementation of the default H(grad)-compatible orthogonal basis (Dubiner) of arbitrary degree on tr...
Kokkos::DynRankView< scalarType, Kokkos::LayoutStride, DeviceType > ScalarViewType
View type for scalars.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
See Intrepid2::Basis_HGRAD_TRI_Cn_FEM_ORTH.
See Intrepid2::Basis_HGRAD_TRI_Cn_FEM_ORTH.
Kokkos::View< ordinal_type **, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray2DHost
View type for 2d host array.
typename DeviceType::execution_space ExecutionSpace
(Kokkos) Execution space for basis.
static constexpr ordinal_type MaxNumPtsPerBasisEval
The maximum number of points to eval in serial mode.
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, DeviceType > OutputViewType
View type for basis value output.
Definition file for FEM orthogonal basis functions of arbitrary degree for H(grad) functions on TRI...
virtual void getValues(const ExecutionSpace &space, OutputViewType outputValues, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const override
Evaluation of a FEM basis on a reference cell.
Basis_HGRAD_TRI_Cn_FEM_ORTH(const ordinal_type order)
Constructor.
Kokkos::View< ordinal_type ***, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray3DHost
View type for 3d host array.
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, DeviceType > OutputViewType
View type for basis value output.
ordinal_type getDegree() const
Returns the degree of the basis.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
Header file for the abstract base class Intrepid2::Basis.
typename DeviceType::execution_space ExecutionSpace
(Kokkos) Execution space for basis.