Intrepid2
Intrepid2_HGRAD_TET_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 
50 #ifndef __INTREPID2_HGRAD_TET_Cn_FEM_ORTH_HPP__
51 #define __INTREPID2_HGRAD_TET_Cn_FEM_ORTH_HPP__
52 
53 #include "Intrepid2_Basis.hpp"
54 
55 namespace Intrepid2 {
56 
65 namespace Impl {
66 
69 template<typename OutputViewType,
70 typename inputViewType,
71 typename workViewType,
72 bool hasDeriv, ordinal_type n>
74  KOKKOS_INLINE_FUNCTION
75  static void
76  generate( OutputViewType output,
77  const inputViewType input,
78  workViewType work,
79  const ordinal_type p );
80 };
81 
84 template<typename OutputViewType,
85 typename inputViewType,
86 typename workViewType,
87 bool hasDeriv>
88 struct OrthPolynomialTet<OutputViewType,inputViewType,workViewType,hasDeriv,0> {
89  KOKKOS_INLINE_FUNCTION
90  static void
91  generate( OutputViewType output,
92  const inputViewType input,
93  workViewType work,
94  const ordinal_type p );
95 };
96 
99 template<typename OutputViewType,
100 typename inputViewType,
101 typename workViewType,
102 bool hasDeriv>
103 struct OrthPolynomialTet<OutputViewType,inputViewType,workViewType,hasDeriv,1> {
104  KOKKOS_INLINE_FUNCTION
105  static void
106  generate( OutputViewType output,
107  const inputViewType input,
108  workViewType work,
109  const ordinal_type p );
110 };
111 
116 public:
117 
121  template<EOperator opType>
122  struct Serial {
123  template<typename OutputViewType,
124  typename inputViewType,
125  typename workViewType>
126  KOKKOS_INLINE_FUNCTION
127  static void
128  getValues( OutputViewType output,
129  const inputViewType input,
130  workViewType work,
131  const ordinal_type order);
132  };
133 
134  template<typename ExecSpaceType, ordinal_type numPtsPerEval,
135  typename outputValueValueType, class ...outputValueProperties,
136  typename inputPointValueType, class ...inputPointProperties>
137  static void
138  getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
139  const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
140  const ordinal_type order,
141  const EOperator operatorType );
142 
146  template<typename outputValueViewType,
147  typename inputPointViewType,
148  typename workViewType,
149  EOperator opType,
150  ordinal_type numPtsEval>
151  struct Functor {
152  outputValueViewType _outputValues;
153  const inputPointViewType _inputPoints;
154  workViewType _work;
155  const ordinal_type _order;
156 
157  KOKKOS_INLINE_FUNCTION
158  Functor( outputValueViewType outputValues_,
159  inputPointViewType inputPoints_,
160  workViewType work_,
161  const ordinal_type order_ )
162  : _outputValues(outputValues_), _inputPoints(inputPoints_), _work(work_),_order(order_){}
163 
164  KOKKOS_INLINE_FUNCTION
165  void operator()(const size_type iter) const {
166  const auto ptBegin = Util<ordinal_type>::min(iter*numPtsEval, _inputPoints.extent(0));
167  const auto ptEnd = Util<ordinal_type>::min(ptBegin+numPtsEval, _inputPoints.extent(0));
168 
169  const auto ptRange = Kokkos::pair<ordinal_type,ordinal_type>(ptBegin, ptEnd);
170  const auto input = Kokkos::subview( _inputPoints, ptRange, Kokkos::ALL() );
171 
172  switch (opType) {
173  case OPERATOR_VALUE : {
174  auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange );
175  Serial<opType>::getValues( output, input, _work, _order ); //here work is not used
176  break;
177  }
178  case OPERATOR_GRAD :
179  case OPERATOR_D1 :
180  {
181  const auto work = Kokkos::subview( _work, Kokkos::ALL(), ptRange, Kokkos::ALL() );
182  auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange, Kokkos::ALL() );
183  Serial<opType>::getValues( output, input, work, _order);
184  break;
185  }
186  case OPERATOR_D2 :
187  case OPERATOR_D3 :
188  case OPERATOR_D4 :
189  case OPERATOR_D5 :
190  case OPERATOR_D6 :
191  case OPERATOR_D7 :
192  case OPERATOR_D8 :
193  case OPERATOR_D9 :
194  case OPERATOR_D10 :
195  {
196  auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange, Kokkos::ALL() );
197  Serial<opType>::getValues( output, input, _work, _order); //here work is not used
198  break;
199  }
200  default: {
201  INTREPID2_TEST_FOR_ABORT( true,
202  ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_Cn_FEM_ORTH::Functor) operator is not supported");
203 
204  }
205  }
206  }
207  };
208 
209 };
210 
211 }
212 
213 template<typename ExecSpaceType = void,
214  typename outputValueType = double,
215  typename pointValueType = double>
217  : public Basis<ExecSpaceType,outputValueType,pointValueType> {
218  public:
219  typedef double value_type;
223 
226  Basis_HGRAD_TET_Cn_FEM_ORTH( const ordinal_type order );
227 
231 
233 
234  virtual
235  void
236  getValues( OutputViewType outputValues,
237  const PointViewType inputPoints,
238  const EOperator operatorType = OPERATOR_VALUE ) const {
239  #ifdef HAVE_INTREPID2_DEBUG
240  Intrepid2::getValues_HGRAD_Args(outputValues,
241  inputPoints,
242  operatorType,
243  this->getBaseCellTopology(),
244  this->getCardinality() );
245  #endif
246  constexpr ordinal_type numPtsPerEval = Parameters::MaxNumPtsPerBasisEval;
247  Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
248  getValues<ExecSpaceType,numPtsPerEval>( outputValues,
249  inputPoints,
250  this->getDegree(),
251  operatorType );
252  }
253 };
254 
255 }// namespace Intrepid2
256 
258 
259 #endif
260 
small utility functions
Kokkos::View< ordinal_type *, typename ExecSpaceType::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
See Intrepid2::Basis_HGRAD_TET_Cn_FEM_ORTH.
Kokkos::View< ordinal_type **, typename ExecSpaceType::array_layout, Kokkos::HostSpace > OrdinalTypeArray2DHost
View type for 2d host array.
Basis_HGRAD_TET_Cn_FEM_ORTH(const ordinal_type order)
Constructor.
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...
ordinal_type getCardinality() const
Returns cardinality of the basis.
Implementation of the default H(grad)-compatible orthogonal basis of arbitrary degree on tetrahedron...
static constexpr ordinal_type MaxNumPtsPerBasisEval
The maximum number of points to eval in serial mode.
Definition file for FEM orthogonal basis functions of degree n for H(grad) functions on TET cells...
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, ExecSpaceType > OutputViewType
View type for basis value output.
Kokkos::View< ordinal_type ***, typename ExecSpaceType::array_layout, Kokkos::HostSpace > OrdinalTypeArray3DHost
View type for 3d host array.
ordinal_type getDegree() const
Returns the degree of the basis.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, ExecSpaceType > PointViewType
View type for input points.
Kokkos::DynRankView< scalarType, Kokkos::LayoutStride, ExecSpaceType > ScalarViewType
View type for scalars.
virtual void getValues(OutputViewType outputValues, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const
Evaluation of a FEM basis on a reference cell.
Header file for the abstract base class Intrepid2::Basis.
See Intrepid2::Basis_HGRAD_TET_Cn_FEM_ORTH.