Nektar++
StdExpansion3D.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: StdExpansion3D.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 3D expansion. Typically this inolves physiocal
33 // space operations.
34 //
35 ///////////////////////////////////////////////////////////////////////////////
36 
37 #ifndef STDEXP3D_H
38 #define STDEXP3D_H
39 
42 
43 namespace Nektar
44 {
45 namespace StdRegions
46 {
47 
48 class StdExpansion3D;
49 typedef std::shared_ptr<StdExpansion3D> StdExpansion3DSharedPtr;
50 
51 class StdExpansion3D : virtual public StdExpansion
52 {
53 
54 public:
56  STD_REGIONS_EXPORT StdExpansion3D(int numcoeffs,
57  const LibUtilities::BasisKey &Ba,
58  const LibUtilities::BasisKey &Bb,
59  const LibUtilities::BasisKey &Bc);
61  STD_REGIONS_EXPORT virtual ~StdExpansion3D() override;
62 
63  // Differentiation
64 
65  /** \brief Calculate the 3D derivative in the local
66  * tensor/collapsed coordinate at the physical points
67  *
68  * This function is independent of the expansion basis and can
69  * therefore be defined for all tensor product distribution of
70  * quadrature points in a generic manner. The key operations are:
71  *
72  * - \f$ \frac{d}{d\eta_1} \rightarrow {\bf D^T_0 u } \f$ \n
73  * - \f$ \frac{d}{d\eta_2} \rightarrow {\bf D_1 u } \f$
74  * - \f$ \frac{d}{d\eta_3} \rightarrow {\bf D_2 u } \f$
75  *
76  * \param inarray array of physical points to be differentiated
77  * \param outarray_d1 the resulting array of derivative in the
78  * \f$\eta_1\f$ direction will be stored in outarray_d1 as output
79  * of the function
80  * \param outarray_d2 the resulting array of derivative in the
81  * \f$\eta_2\f$ direction will be stored in outarray_d2 as output
82  * of the function
83  * \param outarray_d3 the resulting array of derivative in the
84  * \f$\eta_3\f$ direction will be stored in outarray_d3 as output
85  * of the function
86  *
87  * Recall that:
88  * \f$
89  * \hspace{1cm} \begin{array}{llll}
90  * \mbox{Shape} & \mbox{Cartesian coordinate range} &
91  * \mbox{Collapsed coord.} &
92  * \mbox{Collapsed coordinate definition}\\
93  * \mbox{Hexahedral} & -1 \leq \xi_1,\xi_2, \xi_3 \leq 1
94  * & -1 \leq \eta_1,\eta_2, \eta_3 \leq 1
95  * & \eta_1 = \xi_1, \eta_2 = \xi_2, \eta_3 = \xi_3 \\
96  * \mbox{Tetrahedral} & -1 \leq \xi_1,\xi_2,\xi_3; \xi_1+\xi_2 +\xi_3 \leq
97  * -1 & -1 \leq \eta_1,\eta_2, \eta_3 \leq 1
98  * & \eta_1 = \frac{2(1+\xi_1)}{-\xi_2 -\xi_3}-1, \eta_2 =
99  * \frac{2(1+\xi_2)}{1 - \xi_3}-1, \eta_3 = \xi_3 \\ \end{array} \f$
100  */
102  const Array<OneD, const NekDouble> &inarray,
103  Array<OneD, NekDouble> &outarray_d1,
104  Array<OneD, NekDouble> &outarray_d2,
105  Array<OneD, NekDouble> &outarray_d3);
106 
108  const Array<OneD, const NekDouble> &base0,
109  const Array<OneD, const NekDouble> &base1,
110  const Array<OneD, const NekDouble> &base2,
111  const Array<OneD, const NekDouble> &inarray,
113  bool doCheckCollDir0, bool doCheckCollDir1, bool doCheckCollDir2);
114 
116  const Array<OneD, const NekDouble> &base0,
117  const Array<OneD, const NekDouble> &base1,
118  const Array<OneD, const NekDouble> &base2,
119  const Array<OneD, const NekDouble> &inarray,
121  bool doCheckCollDir0, bool doCheckCollDir1, bool doCheckCollDir2);
122 
123  /** \brief return the number of edges in 3D expansion
124  */
125  int GetNedges() const
126  {
127  return v_GetNedges();
128  }
129 
130  /** \brief This function returns the number of expansion coefficients
131  * belonging to the \a i-th edge
132  *
133  * This function is a wrapper around the virtual function
134  * \a v_GetEdgeNcoeffs()
135  *
136  * \param i specifies which edge
137  * \return returns the number of expansion coefficients belonging to
138  * the \a i-th edge
139  */
140  int GetEdgeNcoeffs(const int i) const
141  {
142  return v_GetEdgeNcoeffs(i);
143  }
144 
145  void GetEdgeInteriorToElementMap(const int tid,
146  Array<OneD, unsigned int> &maparray,
147  Array<OneD, int> &signarray,
148  Orientation traceOrient = eForwards)
149  {
150  v_GetEdgeInteriorToElementMap(tid, maparray, signarray, traceOrient);
151  }
152 
153 protected:
154  /** \brief This function evaluates the expansion at a single
155  * (arbitrary) point of the domain
156  *
157  *
158  * Based on the value of the expansion at the quadrature points,
159  * this function calculates the value of the expansion at an
160  * arbitrary single points (with coordinates \f$ \mathbf{x_c}\f$
161  * given by the pointer \a coords). This operation, equivalent to
162  * \f[ u(\mathbf{x_c}) = \sum_p \phi_p(\mathbf{x_c}) \hat{u}_p \f]
163  * is evaluated using Lagrangian interpolants through the quadrature
164  * points:
165  * \f[ u(\mathbf{x_c}) = \sum_p h_p(\mathbf{x_c}) u_p\f]
166  *
167  * This function requires that the physical value array
168  * \f$\mathbf{u}\f$ (implemented as the attribute #phys)
169  * is set.
170  *
171  * \param coords the coordinates of the single point
172  * \return returns the value of the expansion at the single point
173  */
175  const Array<OneD, const NekDouble> &coords,
176  const Array<OneD, const NekDouble> &physvals) override;
177 
180  const Array<OneD, const NekDouble> &physvals) override;
181 
183  const Array<OneD, NekDouble> &coord,
184  const Array<OneD, const NekDouble> &inarray,
185  std::array<NekDouble, 3> &firstOrderDerivs) override;
186 
188  const Array<OneD, const NekDouble> &base0,
189  const Array<OneD, const NekDouble> &base1,
190  const Array<OneD, const NekDouble> &base2,
191  const Array<OneD, const NekDouble> &inarray,
193  bool doCheckCollDir0, bool doCheckCollDir1, bool doCheckCollDir2) = 0;
194 
196  const Array<OneD, const NekDouble> &base0,
197  const Array<OneD, const NekDouble> &base1,
198  const Array<OneD, const NekDouble> &base2,
199  const Array<OneD, const NekDouble> &inarray,
201  bool doCheckCollDir0, bool doCheckCollDir1, bool doCheckCollDir2) = 0;
202 
204  const Array<OneD, const NekDouble> &inarray,
205  Array<OneD, NekDouble> &outarray,
206  const StdRegions::StdMatrixKey &mkey) override;
207 
209  const Array<OneD, const NekDouble> &inarray,
210  Array<OneD, NekDouble> &outarray,
211  const StdRegions::StdMatrixKey &mkey) override;
212 
214  const Array<OneD, const NekDouble> &inarray) override;
215 
216  STD_REGIONS_EXPORT virtual int v_GetNedges(void) const;
217  STD_REGIONS_EXPORT virtual int v_GetEdgeNcoeffs(const int i) const;
218 
219  /**
220  * Performs tensor product evaluation in 3D to evaluate the physical
221  * and derivative values in each direction at input coordinate
222  * @param coord using input physical values at quadrature points
223  * @param inarray. Returns via reference the derivatives.
224 
225  * @param coord Global coordinate
226  * @param inarray Phys values
227  * @param out_d0 Return by reference parameter for 0th derivative
228  * @param out_d1 Return by reference parameter for 1st derivative
229  * @param out_d2 Return by reference parameter for 2nd derivative
230  * @return Physical value at @param coord
231  */
233  const Array<OneD, NekDouble> &coord,
234  const Array<OneD, const NekDouble> &inarray,
235  std::array<NekDouble, 3> &firstOrderDerivs)
236  {
237  const int nq0 = m_base[0]->GetNumPoints();
238  const int nq1 = m_base[1]->GetNumPoints();
239  const int nq2 = m_base[2]->GetNumPoints();
240 
241  const NekDouble *ptr = &inarray[0];
242  Array<OneD, NekDouble> deriv0(nq1 * nq2, 0.0);
243  Array<OneD, NekDouble> phys0(nq1 * nq2, 0.0);
244  Array<OneD, NekDouble> deriv0phys1(nq1, 0.0);
245  Array<OneD, NekDouble> phys0deriv1(nq1, 0.0);
246  Array<OneD, NekDouble> phys0phys1(nq1, 0.0);
247 
248  for (int j = 0; j < nq1 * nq2; ++j, ptr += nq0)
249  {
250  phys0[j] =
251  StdExpansion::BaryEvaluate<0, true>(coord[0], ptr, deriv0[j]);
252  }
253 
254  for (int j = 0; j < nq2; ++j)
255  {
256  deriv0phys1[j] = StdExpansion::BaryEvaluate<1, false>(
257  coord[1], &deriv0[j * nq1]);
258  }
259  firstOrderDerivs[0] =
260  StdExpansion::BaryEvaluate<2, false>(coord[2], &deriv0phys1[0]);
261 
262  for (int j = 0; j < nq2; ++j)
263  {
264  phys0phys1[j] = StdExpansion::BaryEvaluate<1, true>(
265  coord[1], &phys0[j * nq1], phys0deriv1[j]);
266  }
267  firstOrderDerivs[1] =
268  StdExpansion::BaryEvaluate<2, false>(coord[2], &phys0deriv1[0]);
269 
270  return StdExpansion::BaryEvaluate<2, true>(coord[2], &phys0phys1[0],
271  firstOrderDerivs[2]);
272  }
273 
275  const int tid, Array<OneD, unsigned int> &maparray,
276  Array<OneD, int> &signarray, Orientation traceOrient = eForwards);
277 
279  const int tid, Array<OneD, unsigned int> &maparray,
280  Array<OneD, int> &signarray, Orientation traceOrient, int P,
281  int Q) override;
282 
284  const int dir, DNekMatSharedPtr &mat) override;
285 
286 private:
287  virtual int v_GetShapeDimension() const override final
288  {
289  return 3;
290  }
291 };
292 
294  const int facedir, const LibUtilities::BasisType faceDirBasisType,
295  const int numpoints, const int nummodes);
296 
298  const int facedir, const LibUtilities::BasisType faceDirBasisType,
299  const int numpoints, const int nummodes);
300 } // namespace StdRegions
301 } // namespace Nektar
302 
303 #endif // STDEXP3D_H
#define STD_REGIONS_EXPORT
Describes the specification for a Basis.
Definition: Basis.h:50
virtual int v_GetNedges(void) const
void BwdTrans_SumFacKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &base2, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, Array< OneD, NekDouble > &wsp, bool doCheckCollDir0, bool doCheckCollDir1, bool doCheckCollDir2)
virtual void v_GetEdgeInteriorToElementMap(const int tid, Array< OneD, unsigned int > &maparray, Array< OneD, int > &signarray, Orientation traceOrient=eForwards)
void IProductWRTBase_SumFacKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &base2, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, Array< OneD, NekDouble > &wsp, bool doCheckCollDir0, bool doCheckCollDir1, bool doCheckCollDir2)
int GetEdgeNcoeffs(const int i) const
This function returns the number of expansion coefficients belonging to the i-th edge.
virtual void v_BwdTrans_SumFacKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &base2, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, Array< OneD, NekDouble > &wsp, bool doCheckCollDir0, bool doCheckCollDir1, bool doCheckCollDir2)=0
virtual void v_HelmholtzMatrixOp_MatFree(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::StdMatrixKey &mkey) override
int GetNedges() const
return the number of edges in 3D expansion
NekDouble BaryTensorDeriv(const Array< OneD, NekDouble > &coord, const Array< OneD, const NekDouble > &inarray, std::array< NekDouble, 3 > &firstOrderDerivs)
virtual int v_GetShapeDimension() const override final
virtual void v_LaplacianMatrixOp_MatFree(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::StdMatrixKey &mkey) override
virtual int v_GetEdgeNcoeffs(const int i) const
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 NekDouble v_Integral(const Array< OneD, const NekDouble > &inarray) override
Integrates the specified function over the domain.
virtual void v_GenStdMatBwdDeriv(const int dir, DNekMatSharedPtr &mat) override
void GetEdgeInteriorToElementMap(const int tid, Array< OneD, unsigned int > &maparray, Array< OneD, int > &signarray, Orientation traceOrient=eForwards)
virtual void v_GetTraceToElementMap(const int tid, Array< OneD, unsigned int > &maparray, Array< OneD, int > &signarray, Orientation traceOrient, int P, int Q) override
virtual void v_IProductWRTBase_SumFacKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &base2, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, Array< OneD, NekDouble > &wsp, bool doCheckCollDir0, bool doCheckCollDir1, bool doCheckCollDir2)=0
void PhysTensorDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray_d1, Array< OneD, NekDouble > &outarray_d2, Array< OneD, NekDouble > &outarray_d3)
Calculate the 3D derivative in the local tensor/collapsed coordinate at the physical points.
The base class for all shapes.
Definition: StdExpansion.h:71
Array< OneD, LibUtilities::BasisSharedPtr > m_base
LibUtilities::BasisKey EvaluateTriFaceBasisKey(const int facedir, const LibUtilities::BasisType faceDirBasisType, const int numpoints, const int nummodes)
LibUtilities::BasisKey EvaluateQuadFaceBasisKey(const int facedir, const LibUtilities::BasisType faceDirBasisType, const int numpoints, const int nummodes)
std::shared_ptr< StdExpansion3D > StdExpansion3DSharedPtr
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