Nektar++
Loading...
Searching...
No Matches
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
63 const Array<OneD, const NekDouble> &inarray,
65 const bool Deformed, [[maybe_unused]] bool CollDir0 = false,
66 [[maybe_unused]] bool CollDir1 = false,
67 [[maybe_unused]] bool CollDir2 = false);
68
69 /** \brief return the number of edges in 3D expansion
70 */
71 int GetNedges() const
72 {
73 return v_GetNedges();
74 }
75
76 /** \brief This function returns the number of expansion coefficients
77 * belonging to the \a i-th edge
78 *
79 * This function is a wrapper around the virtual function
80 * \a v_GetEdgeNcoeffs()
81 *
82 * \param i specifies which edge
83 * \return returns the number of expansion coefficients belonging to
84 * the \a i-th edge
85 */
86 int GetEdgeNcoeffs(const int i) const
87 {
88 return v_GetEdgeNcoeffs(i);
89 }
90
91 void GetEdgeInteriorToElementMap(const int tid,
93 Array<OneD, int> &signarray,
94 Orientation traceOrient = eForwards)
95 {
96 v_GetEdgeInteriorToElementMap(tid, maparray, signarray, traceOrient);
97 }
98
99protected:
100 /** \brief Calculate the 3D derivative in the local
101 * tensor/collapsed coordinate at the physical points
102 *
103 * This function is independent of the expansion basis and can
104 * therefore be defined for all tensor product distribution of
105 * quadrature points in a generic manner. The key operations are:
106 *
107 * - \f$ \frac{d}{d\eta_1} \rightarrow {\bf D^T_0 u } \f$ \n
108 * - \f$ \frac{d}{d\eta_2} \rightarrow {\bf D_1 u } \f$
109 * - \f$ \frac{d}{d\eta_3} \rightarrow {\bf D_2 u } \f$
110 *
111 * \param inarray array of physical points to be differentiated
112 * \param out_d0 the resulting array of derivative in the
113 * \f$\eta_1\f$ direction will be stored in out_d0 as output
114 * of the function
115 * \param out_d1 the resulting array of derivative in the
116 * \f$\eta_2\f$ direction will be stored in out_d1 as output
117 * of the function
118 * \param out_d2 the resulting array of derivative in the
119 * \f$\eta_3\f$ direction will be stored in out_d2 as output
120 * of the function
121 *
122 * Recall that:
123 * \f$
124 * \hspace{1cm} \begin{array}{llll}
125 * \mbox{Shape} & \mbox{Cartesian coordinate range} &
126 * \mbox{Collapsed coord.} &
127 * \mbox{Collapsed coordinate definition}\\
128 * \mbox{Hexahedral} & -1 \leq \xi_1,\xi_2, \xi_3 \leq 1
129 * & -1 \leq \eta_1,\eta_2, \eta_3 \leq 1
130 * & \eta_1 = \xi_1, \eta_2 = \xi_2, \eta_3 = \xi_3 \\
131 * \mbox{Tetrahedral} & -1 \leq \xi_1,\xi_2,\xi_3; \xi_1+\xi_2 +\xi_3 \leq
132 * -1 & -1 \leq \eta_1,\eta_2, \eta_3 \leq 1
133 * & \eta_1 = \frac{2(1+\xi_1)}{-\xi_2 -\xi_3}-1, \eta_2 =
134 * \frac{2(1+\xi_2)}{1 - \xi_3}-1, \eta_3 = \xi_3 \\ \end{array} \f$
135 */
137 const Array<OneD, const NekDouble> &inarray,
139 Array<OneD, NekDouble> &out_d2);
141 const int dir, const Array<OneD, const NekDouble> &inarray,
142 Array<OneD, NekDouble> &outarray) override;
144
145 /** \brief This function evaluates the expansion at a single
146 * (arbitrary) point of the domain
147 *
148 *
149 * Based on the value of the expansion at the quadrature points,
150 * this function calculates the value of the expansion at an
151 * arbitrary single points (with coordinates \f$ \mathbf{x_c}\f$
152 * given by the pointer \a coords). This operation, equivalent to
153 * \f[ u(\mathbf{x_c}) = \sum_p \phi_p(\mathbf{x_c}) \hat{u}_p \f]
154 * is evaluated using Lagrangian interpolants through the quadrature
155 * points:
156 * \f[ u(\mathbf{x_c}) = \sum_p h_p(\mathbf{x_c}) u_p\f]
157 *
158 * This function requires that the physical value array
159 * \f$\mathbf{u}\f$ (implemented as the attribute #phys)
160 * is set.
161 *
162 * \param coords the coordinates of the single point
163 * \return returns the value of the expansion at the single point
164 */
167 const Array<OneD, const NekDouble> &physvals) override;
168
171 const Array<OneD, const NekDouble> &physvals) override;
172
174 const Array<OneD, const NekDouble> &inarray,
175 Array<OneD, NekDouble> &outarray) override;
176
178 const Array<OneD, const NekDouble> &base0,
179 const Array<OneD, const NekDouble> &base1,
180 const Array<OneD, const NekDouble> &base2,
181 const Array<OneD, const NekDouble> &inarray,
183 const bool Deformed, [[maybe_unused]] bool CollDir0 = false,
184 [[maybe_unused]] bool CollDir1 = false,
185 [[maybe_unused]] bool CollDir2 = false) = 0;
186
188 const Array<OneD, const NekDouble> &inarray,
189 Array<OneD, NekDouble> &outarray) override;
190
192 const Array<OneD, const NekDouble> &inarray,
193 Array<OneD, NekDouble> &outarray,
194 const StdRegions::StdMatrixKey &mkey) override;
195
197 const Array<OneD, const NekDouble> &inarray,
198 Array<OneD, NekDouble> &outarray,
199 const StdRegions::StdMatrixKey &mkey) override;
200 STD_REGIONS_EXPORT virtual int v_GetNedges(void) const;
201 STD_REGIONS_EXPORT virtual int v_GetEdgeNcoeffs(const int i) const;
202
203 /**
204 * Performs tensor product evaluation in 3D to evaluate the physical
205 * and derivative values in each direction at input coordinate
206 * @param coord using input physical values at quadrature points
207 * @param inarray. Returns via reference the derivatives.
208
209 * @param coord Global coordinate
210 * @param inarray Phys values
211 * @param out_d0 Return by reference parameter for 0th derivative
212 * @param out_d1 Return by reference parameter for 1st derivative
213 * @param out_d2 Return by reference parameter for 2nd derivative
214 * @return Physical value at @param coord
215 */
217 const Array<OneD, NekDouble> &coord,
218 const Array<OneD, const NekDouble> &inarray,
219 std::array<NekDouble, 3> &firstOrderDerivs)
220 {
221 const int nq0 = m_base[0]->GetNumPoints();
222 const int nq1 = m_base[1]->GetNumPoints();
223 const int nq2 = m_base[2]->GetNumPoints();
224
225 const NekDouble *ptr = &inarray[0];
226 Array<OneD, NekDouble> deriv0(nq1 * nq2, 0.0);
227 Array<OneD, NekDouble> phys0(nq1 * nq2, 0.0);
228 Array<OneD, NekDouble> deriv0phys1(nq1, 0.0);
229 Array<OneD, NekDouble> phys0deriv1(nq1, 0.0);
230 Array<OneD, NekDouble> phys0phys1(nq1, 0.0);
231
232 for (int j = 0; j < nq1 * nq2; ++j, ptr += nq0)
233 {
234 phys0[j] =
235 StdExpansion::BaryEvaluate<0, true>(coord[0], ptr, deriv0[j]);
236 }
237
238 for (int j = 0; j < nq2; ++j)
239 {
240 deriv0phys1[j] = StdExpansion::BaryEvaluate<1, false>(
241 coord[1], &deriv0[j * nq1]);
242 }
243 firstOrderDerivs[0] =
244 StdExpansion::BaryEvaluate<2, false>(coord[2], &deriv0phys1[0]);
245
246 for (int j = 0; j < nq2; ++j)
247 {
248 phys0phys1[j] = StdExpansion::BaryEvaluate<1, true>(
249 coord[1], &phys0[j * nq1], phys0deriv1[j]);
250 }
251 firstOrderDerivs[1] =
252 StdExpansion::BaryEvaluate<2, false>(coord[2], &phys0deriv1[0]);
253
254 return StdExpansion::BaryEvaluate<2, true>(coord[2], &phys0phys1[0],
255 firstOrderDerivs[2]);
256 }
257
259 const int tid, Array<OneD, unsigned int> &maparray,
260 Array<OneD, int> &signarray, Orientation traceOrient = eForwards);
261
263 const int tid, Array<OneD, unsigned int> &maparray,
264 Array<OneD, int> &signarray, Orientation traceOrient, int P,
265 int Q) override;
266
267 STD_REGIONS_EXPORT void v_GenStdMatBwdDeriv(const int dir,
268 DNekMatSharedPtr &mat) override;
269
271 std::shared_ptr<StdExpansion> fromExp,
272 const Array<OneD, const NekDouble> &fromData,
273 Array<OneD, NekDouble> &toData, bool Transpose) override;
274
276 const StdRegions::Orientation orient, Array<OneD, int> &idmap,
277 const int nq0, const int nq1, bool Forwards) override;
278
279 int v_GetShapeDimension() const final
280 {
281 return 3;
282 }
283 bool v_IsCollocatedBasis() const final
284 {
285 return ((m_base[0]->Collocation()) && (m_base[1]->Collocation()) &&
286 (m_base[2]->Collocation()));
287 }
288};
289
291 const int facedir, const LibUtilities::BasisSharedPtr &faceDirBasis,
292 bool UseGLL = false);
293
295 const int facedir, const LibUtilities::BasisSharedPtr &faceDirBasis);
296} // namespace Nektar::StdRegions
297
298#endif // STDEXP3D_H
#define STD_REGIONS_EXPORT
Describes the specification for a Basis.
Definition Basis.h:45
void IProductWRTBaseKernel(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, const Array< OneD, NekDouble > &jac, const bool Deformed, bool CollDir0=false, bool CollDir1=false, bool CollDir2=false)
void v_ReOrientTracePhysMap(const StdRegions::Orientation orient, Array< OneD, int > &idmap, const int nq0, const int nq1, bool Forwards) override
This method produces a mapping.
virtual int v_GetNedges(void) const
virtual void v_GetEdgeInteriorToElementMap(const int tid, Array< OneD, unsigned int > &maparray, Array< OneD, int > &signarray, Orientation traceOrient=eForwards)
int GetEdgeNcoeffs(const int i) const
This function returns the number of expansion coefficients belonging to the i-th edge.
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
void v_MultiplyByStdQuadratureMetric(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
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
void v_PhysInterp(std::shared_ptr< StdExpansion > fromExp, const Array< OneD, const NekDouble > &fromData, Array< OneD, NekDouble > &toData, bool Transpose) override
NekDouble v_PhysEvaluateInterp(const Array< OneD, DNekMatSharedPtr > &I, const Array< OneD, const NekDouble > &physvals) override
virtual void v_IProductWRTBaseKernel(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, const Array< OneD, NekDouble > &jac, const bool Deformed, bool CollDir0=false, bool CollDir1=false, bool CollDir2=false)=0
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
~StdExpansion3D() override=default
NekDouble v_StdPhysEvaluate(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.
StdExpansion3D(const StdExpansion3D &T)=default
void PhysTensorDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_d0, Array< OneD, NekDouble > &out_d1, Array< OneD, NekDouble > &out_d2)
Calculate the 3D derivative in the local tensor/collapsed coordinate at the physical points.
void v_PhysDeriv(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Calculate the derivative of the physical points in a given direction.
The base class for all shapes.
Array< OneD, LibUtilities::BasisSharedPtr > m_base
virtual void v_PhysDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_d1, Array< OneD, NekDouble > &out_d2, Array< OneD, NekDouble > &out_d3)
Calculate the derivative of the physical points.
std::shared_ptr< Basis > BasisSharedPtr
LibUtilities::BasisKey EvaluateQuadFaceBasisKey(const int facedir, const LibUtilities::BasisSharedPtr &faceDirBasis)
LibUtilities::BasisKey EvaluateTriFaceBasisKey(const int facedir, const LibUtilities::BasisSharedPtr &faceDirBasis, bool UseGLL)
std::shared_ptr< StdExpansion3D > StdExpansion3DSharedPtr
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
std::shared_ptr< DNekMat > DNekMatSharedPtr