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