Intrepid2
Intrepid2_DerivedBasis_HGRAD_QUAD.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),
38 // Mauro Perego (mperego@sandia.gov), or
39 // Nate Roberts (nvrober@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
51 #ifndef Intrepid2_DerivedBasis_HGRAD_QUAD_h
52 #define Intrepid2_DerivedBasis_HGRAD_QUAD_h
53 
55 
56 namespace Intrepid2
57 {
58  template<class HGRAD_LINE>
60  : public Basis_TensorBasis<HGRAD_LINE, HGRAD_LINE>
61  {
62  public:
63  using ExecutionSpace = typename HGRAD_LINE::ExecutionSpace;
64  using OutputValueType = typename HGRAD_LINE::OutputValueType;
65  using PointValueType = typename HGRAD_LINE::PointValueType;
66 
67  using OutputViewType = typename HGRAD_LINE::OutputViewType;
68  using PointViewType = typename HGRAD_LINE::PointViewType ;
69  using ScalarViewType = typename HGRAD_LINE::ScalarViewType;
70 
71  using LineBasis = HGRAD_LINE;
73 
78  Basis_Derived_HGRAD_QUAD(int polyOrder_x, int polyOrder_y)
79  :
80  TensorBasis(LineBasis(polyOrder_x),
81  LineBasis(polyOrder_y))
82  {
83  this->functionSpace_ = FUNCTION_SPACE_HGRAD;
84  }
85 
89  Basis_Derived_HGRAD_QUAD(int polyOrder) : Basis_Derived_HGRAD_QUAD(polyOrder,polyOrder) {}
90 
93  virtual bool requireOrientation() const override {
94  return (this->getDofCount(1,0) > 1); //if it has more than 1 DOF per edge, than it needs orientations
95  }
96 
98 
106  virtual void getValues(OutputViewType outputValues, const EOperator operatorType,
107  const PointViewType inputPoints1, const PointViewType inputPoints2,
108  bool tensorPoints) const override
109  {
110  Intrepid2::EOperator op1, op2;
111  if (operatorType == Intrepid2::OPERATOR_VALUE)
112  {
113  op1 = Intrepid2::OPERATOR_VALUE;
114  op2 = Intrepid2::OPERATOR_VALUE;
115 
116  this->TensorBasis::getValues(outputValues,
117  inputPoints1, op1,
118  inputPoints2, op2, tensorPoints);
119  }
120  else if (operatorType == Intrepid2::OPERATOR_GRAD)
121  {
122  // to evaluate gradient, we actually need both OP_VALUE and OP_GRAD (thanks to product rule)
123  // for 1D line x line, we will put derivative * value in first component, and value * derivative in second
124 
125  // outputValues1 and outputValues2 are computed by basis1 and basis2 -- these are tensorial components
126  // outputValuesComponent1 is a slice of the final output container (similarly, outputValuesComponent2)
127  // when the component basis is 1D, it expects not to have a "dimension" component in the output container
128  // the int argument in the dimension component creates a subview that skips the dimension component; the std::pair argument retains it
129  auto outputValuesComponent1 = Kokkos::subview(outputValues,Kokkos::ALL(),Kokkos::ALL(),0);
130  auto outputValuesComponent2 = Kokkos::subview(outputValues,Kokkos::ALL(),Kokkos::ALL(),1);
131 
132  // compute first component -- derivative happens in x, and value taken in y
133  op1 = Intrepid2::OPERATOR_GRAD;
134  op2 = Intrepid2::OPERATOR_VALUE;
135 
136  this->TensorBasis::getValues(outputValuesComponent1,
137  inputPoints1, op1,
138  inputPoints2, op2, tensorPoints);
139 
140  // second component -- value in x, derivative in y
141  op1 = Intrepid2::OPERATOR_VALUE;
142  op2 = Intrepid2::OPERATOR_GRAD;
143 
144  this->TensorBasis::getValues(outputValuesComponent2,
145  inputPoints1, op1,
146  inputPoints2, op2, tensorPoints);
147  }
148  else
149  {
150  INTREPID2_TEST_FOR_EXCEPTION(true,std::invalid_argument,"operator not yet supported");
151  }
152  }
153  };
154 } // end namespace Intrepid2
155 
156 #endif /* Intrepid2_DerivedBasis_HGRAD_QUAD_h */
Implementation of bases that are tensor products of two or three component bases. ...
An abstract base class that defines interface for concrete basis implementations for Finite Element (...
void getValues(OutputViewType outputValues, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const override
Evaluation of a FEM basis on a reference cell.
virtual void getValues(OutputViewType outputValues, const EOperator operatorType, const PointViewType inputPoints1, const PointViewType inputPoints2, bool tensorPoints) const override
multi-component getValues() method (required/called by TensorBasis)
ordinal_type getDofCount(const ordinal_type subcDim, const ordinal_type subcOrd) const
DoF count for specified subcell.
Basis_Derived_HGRAD_QUAD(int polyOrder_x, int polyOrder_y)
Constructor.
virtual bool requireOrientation() const override
True if orientation is required.
Basis defined as the tensor product of two component bases.