Intrepid2
Intrepid2_HGRAD_LINE_Cn_FEM_JACOBI.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_LINE_CN_FEM_JACOBI_HPP__
50 #define __INTREPID2_HGRAD_LINE_CN_FEM_JACOBI_HPP__
51 
52 #include "Intrepid2_Basis.hpp"
53 #include "Intrepid2_Polylib.hpp"
54 
55 namespace Intrepid2 {
56 
131  namespace Impl {
132 
137  public:
138 
142  template<EOperator opType>
143  struct Serial {
144  template<typename OutputViewType,
145  typename inputViewType>
146  KOKKOS_INLINE_FUNCTION
147  static void
148  getValues( OutputViewType output,
149  const inputViewType input,
150  const ordinal_type order,
151  const double alpha,
152  const double beta,
153  const ordinal_type opDn = 0 );
154  };
155 
156  template<typename DeviceType, ordinal_type numPtsPerEval,
157  typename outputValueValueType, class ...outputValueProperties,
158  typename inputPointValueType, class ...inputPointProperties>
159  static void
160  getValues( const typename DeviceType::execution_space& space,
161  Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
162  const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
163  const ordinal_type order,
164  const double alpha,
165  const double beta,
166  const EOperator operatorType );
167 
171  template<typename outputValueViewType,
172  typename inputPointViewType,
173  EOperator opType,
174  ordinal_type numPtsEval>
175  struct Functor {
176  outputValueViewType _outputValues;
177  const inputPointViewType _inputPoints;
178  const ordinal_type _order;
179  const double _alpha, _beta;
180  const ordinal_type _opDn;
181 
182  KOKKOS_INLINE_FUNCTION
183  Functor( outputValueViewType outputValues_,
184  inputPointViewType inputPoints_,
185  const ordinal_type order_,
186  const double alpha_,
187  const double beta_,
188  const ordinal_type opDn_ = 0 )
189  : _outputValues(outputValues_), _inputPoints(inputPoints_),
190  _order(order_), _alpha(alpha_), _beta(beta_), _opDn(opDn_) {}
191 
192  KOKKOS_INLINE_FUNCTION
193  void operator()(const size_type iter) const {
194  const auto ptBegin = Util<ordinal_type>::min(iter*numPtsEval, _inputPoints.extent(0));
195  const auto ptEnd = Util<ordinal_type>::min(ptBegin+numPtsEval, _inputPoints.extent(0));
196 
197  const auto ptRange = Kokkos::pair<ordinal_type,ordinal_type>(ptBegin, ptEnd);
198  const auto input = Kokkos::subview( _inputPoints, ptRange, Kokkos::ALL() );
199 
200  if (input.extent(0)) {
201  switch (opType) {
202  case OPERATOR_VALUE : {
203  auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange );
204  Serial<opType>::getValues( output, input, _order, _alpha, _beta );
205  break;
206  }
207  case OPERATOR_GRAD : {
208  auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange, Kokkos::ALL() );
209  Serial<opType>::getValues( output, input, _order, _alpha, _beta );
210  break;
211  }
212  case OPERATOR_Dn: {
213  auto output = Kokkos::subview( _outputValues, Kokkos::ALL(), ptRange, Kokkos::ALL() );
214  Serial<opType>::getValues( output, input, _order, _alpha, _beta, _opDn );
215  break;
216  }
217  default: {
218  INTREPID2_TEST_FOR_ABORT( true,
219  ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM_JACOBI::Functor) operator is not supported");
220 
221  }
222  }
223  }
224  }
225  };
226  };
227  }
228 
229  template<typename DeviceType = void,
230  typename outputValueType = double,
231  typename pointValueType = double>
233  : public Basis<DeviceType,outputValueType,pointValueType> {
234  public:
235  typedef double value_type;
236 
238  using typename BasisBase::ExecutionSpace;
239 
240  using typename BasisBase::OrdinalTypeArray1DHost;
241  using typename BasisBase::OrdinalTypeArray2DHost;
242  using typename BasisBase::OrdinalTypeArray3DHost;
243 
244  using typename BasisBase::OutputViewType;
245  using typename BasisBase::PointViewType ;
246  using typename BasisBase::ScalarViewType;
247 
250  Basis_HGRAD_LINE_Cn_FEM_JACOBI( const ordinal_type order,
251  const double alpha = 0,
252  const double beta = 0 );
253 
254  using BasisBase::getValues;
255 
256  virtual
257  void
258  getValues( const ExecutionSpace& space,
259  OutputViewType outputValues,
260  const PointViewType inputPoints,
261  const EOperator operatorType = OPERATOR_VALUE ) const override {
262 #ifdef HAVE_INTREPID2_DEBUG
263  Intrepid2::getValues_HGRAD_Args(outputValues,
264  inputPoints,
265  operatorType,
266  this->getBaseCellTopology(),
267  this->getCardinality() );
268 #endif
269  constexpr ordinal_type numPtsPerEval = 1;
270  Impl::Basis_HGRAD_LINE_Cn_FEM_JACOBI::
271  getValues<DeviceType,numPtsPerEval>(space,
272  outputValues,
273  inputPoints,
274  this->getDegree(),
275  this->alpha_,
276  this->beta_,
277  operatorType);
278  }
279 
280  private:
281  double alpha_, beta_;
282 
283  };
284 
285 }
286 
288 
289 #endif
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, DeviceType > OutputViewType
View type for basis value output.
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
small utility functions
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
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.
Basis_HGRAD_LINE_Cn_FEM_JACOBI(const ordinal_type order, const double alpha=0, const double beta=0)
Constructor.
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.
Header file for Intrepid2::Polylib class providing orthogonal polynomial calculus and interpolation...
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...
Kokkos::DynRankView< scalarType, Kokkos::LayoutStride, DeviceType > ScalarViewType
View type for scalars.
typename DeviceType::execution_space ExecutionSpace
(Kokkos) Execution space for basis.
Kokkos::View< ordinal_type **, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray2DHost
View type for 2d host array.
Kokkos::DynRankView< OutputValueType, Kokkos::LayoutStride, DeviceType > OutputViewType
View type for basis value output.
Implementation of the locally H(grad)-compatible FEM basis of variable order on the [-1...
Kokkos::View< ordinal_type ***, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray3DHost
View type for 3d host array.
ordinal_type getDegree() const
Returns the degree of the basis.
Definition file for FEM orthogonal basis functions of degree n for H(grad) functions on LINE...
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.