Intrepid2
Intrepid2_DerivedBasis_HCURL_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 
53 #ifndef Intrepid2_DerivedBasis_HCURL_QUAD_h
54 #define Intrepid2_DerivedBasis_HCURL_QUAD_h
55 
56 #include <Kokkos_View.hpp>
57 #include <Kokkos_DynRankView.hpp>
58 
60 
63 
64 namespace Intrepid2
65 {
66  template<class HGRAD_LINE, class HVOL_LINE>
68  : public Basis_TensorBasis<HVOL_LINE, HGRAD_LINE>
69  {
70  public:
71  using ExecutionSpace = typename HGRAD_LINE::ExecutionSpace;
72  using OutputValueType = typename HGRAD_LINE::OutputValueType;
73  using PointValueType = typename HGRAD_LINE::PointValueType;
74 
75  using OutputViewType = typename HGRAD_LINE::OutputViewType;
76  using PointViewType = typename HGRAD_LINE::PointViewType ;
77  using ScalarViewType = typename HGRAD_LINE::ScalarViewType;
78 
79  using LineGradBasis = HGRAD_LINE;
80  using LineHVolBasis = HVOL_LINE;
81 
83  public:
88  Basis_Derived_HCURL_Family1_QUAD(int polyOrder_x, int polyOrder_y)
89  :
90  TensorBasis(LineHVolBasis(polyOrder_x-1),
91  LineGradBasis(polyOrder_y))
92  {
93  this->functionSpace_ = FUNCTION_SPACE_HCURL;
94  }
95 
97 
105  virtual void getValues(OutputViewType outputValues, const EOperator operatorType,
106  const PointViewType inputPoints1, const PointViewType inputPoints2,
107  bool tensorPoints) const
108  {
109  Intrepid2::EOperator op1, op2;
110  if (operatorType == Intrepid2::OPERATOR_VALUE)
111  {
112  op1 = Intrepid2::OPERATOR_VALUE;
113  op2 = Intrepid2::OPERATOR_VALUE;
114 
115  // family 1 goes in the x component; 0 in the y component
116  auto outputValuesComponent1 = Kokkos::subview(outputValues,Kokkos::ALL(),Kokkos::ALL(),0);
117  auto outputValuesComponent2 = Kokkos::subview(outputValues,Kokkos::ALL(),Kokkos::ALL(),1);
118 
119  this->TensorBasis::getValues(outputValuesComponent1,
120  inputPoints1, op1,
121  inputPoints2, op2, tensorPoints);
122  // place 0 in the y component
123  Kokkos::deep_copy(outputValuesComponent2,0.0);
124  }
125  else if (operatorType == Intrepid2::OPERATOR_CURL)
126  {
127  // family 1 gets a -d/dy applied to the first (nonzero) vector component
128  // since this is H(VOL)(x) * H(GRAD)(y), this amounts to taking the derivative in the second tensorial component
129  op1 = Intrepid2::OPERATOR_VALUE;
130  op2 = Intrepid2::OPERATOR_GRAD;
131 
132  double weight = -1.0; // the minus sign in front of d/dy
133  this->TensorBasis::getValues(outputValues,
134  inputPoints1, op1,
135  inputPoints2, op2, tensorPoints, weight);
136  }
137  else
138  {
139  INTREPID2_TEST_FOR_EXCEPTION(true,std::invalid_argument,"operator not yet supported");
140  }
141  }
142  };
143 
144  template<class HGRAD_LINE, class HVOL_LINE>
146  : public Basis_TensorBasis<HGRAD_LINE, HVOL_LINE>
147  {
148  public:
149  using ExecutionSpace = typename HGRAD_LINE::ExecutionSpace;
150  using OutputValueType = typename HGRAD_LINE::OutputValueType;
151  using PointValueType = typename HGRAD_LINE::PointValueType;
152 
153  using OutputViewType = typename HGRAD_LINE::OutputViewType;
154  using PointViewType = typename HGRAD_LINE::PointViewType ;
155  using ScalarViewType = typename HGRAD_LINE::ScalarViewType;
156 
157  using LineGradBasis = HGRAD_LINE;
158  using LineHVolBasis = HVOL_LINE;
159 
161 
166  Basis_Derived_HCURL_Family2_QUAD(int polyOrder_x, int polyOrder_y)
167  :
168  TensorBasis(LineGradBasis(polyOrder_x),
169  LineHVolBasis(polyOrder_y-1))
170  {
171  this->functionSpace_ = FUNCTION_SPACE_HCURL;
172  }
173 
175 
183  virtual void getValues(OutputViewType outputValues, const EOperator operatorType,
184  const PointViewType inputPoints1, const PointViewType inputPoints2,
185  bool tensorPoints) const
186  {
187  Intrepid2::EOperator op1, op2;
188  if (operatorType == Intrepid2::OPERATOR_VALUE)
189  {
190  op1 = Intrepid2::OPERATOR_VALUE;
191  op2 = Intrepid2::OPERATOR_VALUE;
192 
193  // family 2 goes in the y component; 0 in the x component
194  auto outputValuesComponent1 = Kokkos::subview(outputValues,Kokkos::ALL(),Kokkos::ALL(),0);
195  auto outputValuesComponent2 = Kokkos::subview(outputValues,Kokkos::ALL(),Kokkos::ALL(),1);
196 
197  // place 0 in the x component
198  Kokkos::deep_copy(outputValuesComponent1, 0.0);
199  this->TensorBasis::getValues(outputValuesComponent2,
200  inputPoints1, op1,
201  inputPoints2, op2, tensorPoints);
202 
203  }
204  else if (operatorType == Intrepid2::OPERATOR_CURL)
205  {
206  // family 2 gets a d/dx applied to the second (nonzero) vector component
207  // since this is H(GRAD)(x) * H(VOL)(y), this amounts to taking the derivative in the first tensorial component
208  op1 = Intrepid2::OPERATOR_GRAD;
209  op2 = Intrepid2::OPERATOR_VALUE;
210 
211  this->TensorBasis::getValues(outputValues,
212  inputPoints1, op1,
213  inputPoints2, op2, tensorPoints);
214  }
215  else
216  {
217  INTREPID2_TEST_FOR_EXCEPTION(true,std::invalid_argument,"operator not yet supported");
218  }
219  }
220  };
221 
222  template<class HGRAD_LINE, class HVOL_LINE>
224  : public Basis_DirectSumBasis<Basis_Derived_HCURL_Family1_QUAD<HGRAD_LINE, HVOL_LINE>,
225  Basis_Derived_HCURL_Family2_QUAD<HGRAD_LINE, HVOL_LINE> >
226  {
230  public:
235  Basis_Derived_HCURL_QUAD(int polyOrder_x, int polyOrder_y)
236  :
237  DirectSumBasis(Family1(polyOrder_x, polyOrder_y),
238  Family2(polyOrder_x, polyOrder_y)) {
239  this->functionSpace_ = FUNCTION_SPACE_HCURL;
240  }
241 
245  Basis_Derived_HCURL_QUAD(int polyOrder) : Basis_Derived_HCURL_QUAD(polyOrder, polyOrder) {}
246 
249  virtual bool requireOrientation() const {
250  return (this->getDofCount(1,0) > 0); //if it has edge DOFs, than it needs orientations
251  }
252 
253  };
254 } // end namespace Intrepid2
255 
256 #endif /* Intrepid2_DerivedBasis_HCURL_QUAD_h */
Implementation of bases that are tensor products of two or three component bases. ...
Basis_Derived_HCURL_QUAD(int polyOrder_x, int polyOrder_y)
Constructor.
void getValues(OutputViewType outputValues, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const override
Evaluation of a FEM basis on a reference cell.
Free functions, callable from device code, that implement various polynomials useful in basis definit...
Implementation of a basis that is the direct sum of two other bases.
A basis that is the direct sum of two other bases.
Basis_Derived_HCURL_Family2_QUAD(int polyOrder_x, int polyOrder_y)
Constructor.
virtual void getValues(OutputViewType outputValues, const EOperator operatorType, const PointViewType inputPoints1, const PointViewType inputPoints2, bool tensorPoints) const
multi-component getValues() method (required/called by TensorBasis)
EOperator
Enumeration of primitive operators available in Intrepid. Primitive operators act on reconstructed fu...
virtual void getValues(OutputViewType outputValues, const EOperator operatorType, const PointViewType inputPoints1, const PointViewType inputPoints2, bool tensorPoints) const
multi-component getValues() method (required/called by TensorBasis)
Basis_Derived_HCURL_Family1_QUAD(int polyOrder_x, int polyOrder_y)
Constructor.
Basis defined as the tensor product of two component bases.
virtual bool requireOrientation() const
True if orientation is required.