Nektar++
StdExpansion2D.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: StdExpansion2D.h
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Daughter of StdExpansion. This class contains routine
32 // which are common to 2D expansion. Typically this inolves physiocal
33 // space operations.
34 //
35 ///////////////////////////////////////////////////////////////////////////////
36 
37 #ifndef STDEXP2D_H
38 #define STDEXP2D_H
39 
42 
43 namespace Nektar
44 {
45 namespace StdRegions
46 {
47 
48 class StdExpansion2D : virtual public StdExpansion
49 {
50 public:
52  STD_REGIONS_EXPORT StdExpansion2D(int numcoeffs,
53  const LibUtilities::BasisKey &Ba,
54  const LibUtilities::BasisKey &Bb);
56  STD_REGIONS_EXPORT virtual ~StdExpansion2D() override;
57 
58  // Generic operations in different element
59 
60  /** \brief Calculate the 2D derivative in the local
61  * tensor/collapsed coordinate at the physical points
62  *
63  * This function is independent of the expansion basis and can
64  * therefore be defined for all tensor product distribution of
65  * quadrature points in a generic manner. The key operations are:
66  *
67  * - \f$ \frac{d}{d\eta_1} \rightarrow {\bf D^T_0 u } \f$ \n
68  * - \f$ \frac{d}{d\eta_2} \rightarrow {\bf D_1 u } \f$
69  *
70  * \param inarray array of physical points to be differentiated
71  * \param outarray_d0 the resulting array of derivative in the
72  * \f$\eta_1\f$ direction will be stored in outarray_d0 as output
73  * of the function
74  * \param outarray_d1 the resulting array of derivative in the
75  * \f$\eta_2\f$ direction will be stored in outarray_d1 as output
76  * of the function
77  *
78  * Recall that:
79  * \f$
80  * \hspace{1cm} \begin{array}{llll}
81  * \mbox{Shape} & \mbox{Cartesian coordinate range} &
82  * \mbox{Collapsed coord.} &
83  * \mbox{Collapsed coordinate definition}\\
84  * \mbox{Quadrilateral} & -1 \leq \xi_1,\xi_2 \leq 1
85  * & -1 \leq \eta_1,\eta_2 \leq 1
86  * & \eta_1 = \xi_1, \eta_2 = \xi_2\\
87  * \mbox{Triangle} & -1 \leq \xi_1,\xi_2; \xi_1+\xi_2 \leq 0
88  * & -1 \leq \eta_1,\eta_2 \leq 1
89  * & \eta_1 = \frac{2(1+\xi_1)}{(1-\xi_2)}-1, \eta_2 = \xi_2 \\
90  * \end{array} \f$
91  */
93  const Array<OneD, const NekDouble> &inarray,
94  Array<OneD, NekDouble> &outarray_d0,
95  Array<OneD, NekDouble> &outarray_d1);
96 
100  const Array<OneD, const NekDouble> &w1);
101 
102  // find derivative of u (inarray) at all coords points
104  const Array<OneD, NekDouble> &coord,
105  const Array<OneD, const NekDouble> &inarray,
106  std::array<NekDouble, 3> &firstOrderDerivs)
107  {
108  const int nq0 = m_base[0]->GetNumPoints();
109  const int nq1 = m_base[1]->GetNumPoints();
110 
111  const NekDouble *ptr = &inarray[0];
112  Array<OneD, NekDouble> deriv0(nq1, 0.0);
113  Array<OneD, NekDouble> phys0(nq1, 0.0);
114 
115  for (int j = 0; j < nq1; ++j, ptr += nq0)
116  {
117  phys0[j] =
118  StdExpansion::BaryEvaluate<0, true>(coord[0], ptr, deriv0[j]);
119  }
120  firstOrderDerivs[0] =
121  StdExpansion::BaryEvaluate<1, false>(coord[1], &deriv0[0]);
122 
123  return StdExpansion::BaryEvaluate<1, true>(coord[1], &phys0[0],
124  firstOrderDerivs[1]);
125  }
126 
128  const Array<OneD, const NekDouble> &base0,
129  const Array<OneD, const NekDouble> &base1,
130  const Array<OneD, const NekDouble> &inarray,
132  bool doCheckCollDir0 = true, bool doCheckCollDir1 = true);
133 
135  const Array<OneD, const NekDouble> &base0,
136  const Array<OneD, const NekDouble> &base1,
137  const Array<OneD, const NekDouble> &inarray,
139  bool doCheckCollDir0 = true, bool doCheckCollDir1 = true);
140 
141 protected:
142  /** \brief This function evaluates the expansion at a single
143  * (arbitrary) point of the domain
144  *
145  * This function is a wrapper around the virtual function
146  * \a v_PhysEvaluate()
147  *
148  * Based on the value of the expansion at the quadrature points,
149  * this function calculates the value of the expansion at an
150  * arbitrary single points (with coordinates \f$ \mathbf{x_c}\f$
151  * given by the pointer \a coords). This operation, equivalent to
152  * \f[ u(\mathbf{x_c}) = \sum_p \phi_p(\mathbf{x_c}) \hat{u}_p \f]
153  * is evaluated using Lagrangian interpolants through the quadrature
154  * points:
155  * \f[ u(\mathbf{x_c}) = \sum_p h_p(\mathbf{x_c}) u_p\f]
156  *
157  * This function requires that the physical value array
158  * \f$\mathbf{u}\f$ (implemented as the attribute #m_phys)
159  * is set.
160  *
161  * \param coords the coordinates of the single point
162  * \return returns the value of the expansion at the single point
163  */
165  const Array<OneD, const NekDouble> &coords,
166  const Array<OneD, const NekDouble> &physvals) override;
167 
170  const Array<OneD, const NekDouble> &physvals) override;
171 
173  const Array<OneD, NekDouble> &coord,
174  const Array<OneD, const NekDouble> &inarray,
175  std::array<NekDouble, 3> &firstOrderDerivs) override;
176 
178  const Array<OneD, const NekDouble> &base0,
179  const Array<OneD, const NekDouble> &base1,
180  const Array<OneD, const NekDouble> &inarray,
182  bool doCheckCollDir0, bool doCheckCollDir1) = 0;
183 
185  const Array<OneD, const NekDouble> &base0,
186  const Array<OneD, const NekDouble> &base1,
187  const Array<OneD, const NekDouble> &inarray,
189  bool doCheckCollDir0, bool doCheckCollDir1) = 0;
190 
192  const Array<OneD, const NekDouble> &inarray,
193  Array<OneD, NekDouble> &outarray,
194  const StdRegions::StdMatrixKey &mkey) override;
196  const Array<OneD, const NekDouble> &inarray,
197  Array<OneD, NekDouble> &outarray,
198  const StdRegions::StdMatrixKey &mkey) override;
199 
201  const unsigned int traceid,
202  Array<OneD, unsigned int> &maparray) override;
203 
205  const unsigned int eid, Array<OneD, unsigned int> &maparray,
206  Array<OneD, int> &signarray, Orientation edgeOrient, int P,
207  int Q) override;
208 
210  const int eid, Array<OneD, unsigned int> &maparray,
211  Array<OneD, int> &signarray, Orientation edgeOrient = eForwards,
212  int P = -1, int Q = -1) override;
213 
215  const int dir, DNekMatSharedPtr &mat) override;
216 
217 private:
218  virtual int v_GetShapeDimension() const override final
219  {
220  return 2;
221  }
222 };
223 
224 typedef std::shared_ptr<StdExpansion2D> StdExpansion2DSharedPtr;
225 
226 } // namespace StdRegions
227 } // namespace Nektar
228 
229 #endif // STDEXP2D_H
#define STD_REGIONS_EXPORT
Describes the specification for a Basis.
Definition: Basis.h:50
virtual void v_GenStdMatBwdDeriv(const int dir, DNekMatSharedPtr &mat) override
virtual void v_IProductWRTBase_SumFacKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, Array< OneD, NekDouble > &wsp, bool doCheckCollDir0, bool doCheckCollDir1)=0
void PhysTensorDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray_d0, Array< OneD, NekDouble > &outarray_d1)
Calculate the 2D derivative in the local tensor/collapsed coordinate at the physical points.
virtual void v_HelmholtzMatrixOp_MatFree(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::StdMatrixKey &mkey) override
virtual void v_GetTraceToElementMap(const int eid, Array< OneD, unsigned int > &maparray, Array< OneD, int > &signarray, Orientation edgeOrient=eForwards, int P=-1, int Q=-1) override
virtual void v_BwdTrans_SumFacKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, Array< OneD, NekDouble > &wsp, bool doCheckCollDir0, bool doCheckCollDir1)=0
NekDouble BaryTensorDeriv(const Array< OneD, NekDouble > &coord, const Array< OneD, const NekDouble > &inarray, std::array< NekDouble, 3 > &firstOrderDerivs)
NekDouble Integral(const Array< OneD, const NekDouble > &inarray, const Array< OneD, const NekDouble > &w0, const Array< OneD, const NekDouble > &w1)
void BwdTrans_SumFacKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, Array< OneD, NekDouble > &wsp, bool doCheckCollDir0=true, bool doCheckCollDir1=true)
virtual void v_GetTraceCoeffMap(const unsigned int traceid, Array< OneD, unsigned int > &maparray) override
virtual void v_LaplacianMatrixOp_MatFree(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::StdMatrixKey &mkey) override
void IProductWRTBase_SumFacKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, Array< OneD, NekDouble > &wsp, bool doCheckCollDir0=true, bool doCheckCollDir1=true)
virtual NekDouble v_PhysEvaluate(const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &physvals) override
This function evaluates the expansion at a single (arbitrary) point of the domain.
virtual void v_GetElmtTraceToTraceMap(const unsigned int eid, Array< OneD, unsigned int > &maparray, Array< OneD, int > &signarray, Orientation edgeOrient, int P, int Q) override
Determine the mapping to re-orientate the coefficients along the element trace (assumed to align with...
virtual int v_GetShapeDimension() const override final
The base class for all shapes.
Definition: StdExpansion.h:71
Array< OneD, LibUtilities::BasisSharedPtr > m_base
std::shared_ptr< StdExpansion2D > StdExpansion2DSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:75
double NekDouble