Nektar++
Loading...
Searching...
No Matches
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
41
42namespace Nektar::StdRegions
43{
44class StdExpansion2D : virtual public StdExpansion
45{
46public:
48 const LibUtilities::BasisKey &Ba,
49 const LibUtilities::BasisKey &Bb);
52 STD_REGIONS_EXPORT ~StdExpansion2D() override = default;
53
54 // Generic operations in different element
55 // find derivative of u (inarray) at all coords points
57 const Array<OneD, NekDouble> &coord,
58 const Array<OneD, const NekDouble> &inarray,
59 std::array<NekDouble, 3> &firstOrderDerivs)
60 {
61 const int nq0 = m_base[0]->GetNumPoints();
62 const int nq1 = m_base[1]->GetNumPoints();
63
64 const NekDouble *ptr = &inarray[0];
65 Array<OneD, NekDouble> deriv0(nq1, 0.0);
66 Array<OneD, NekDouble> phys0(nq1, 0.0);
67
68 for (int j = 0; j < nq1; ++j, ptr += nq0)
69 {
70 phys0[j] =
71 StdExpansion::BaryEvaluate<0, true>(coord[0], ptr, deriv0[j]);
72 }
73 firstOrderDerivs[0] =
74 StdExpansion::BaryEvaluate<1, false>(coord[1], &deriv0[0]);
75
76 return StdExpansion::BaryEvaluate<1, true>(coord[1], &phys0[0],
77 firstOrderDerivs[1]);
78 }
79
83 const Array<OneD, const NekDouble> &inarray,
85 const bool Deformed, [[maybe_unused]] bool CollDir0 = false,
86 [[maybe_unused]] bool CollDir1 = false);
87
88protected:
89 /** \brief Calculate the 2D derivative in the local
90 * tensor/collapsed coordinate at the physical points
91 *
92 * This function is independent of the expansion basis and can
93 * therefore be defined for all tensor product distribution of
94 * quadrature points in a generic manner. The key operations are:
95 *
96 * - \f$ \frac{d}{d\eta_1} \rightarrow {\bf D^T_0 u } \f$ \n
97 * - \f$ \frac{d}{d\eta_2} \rightarrow {\bf D_1 u } \f$
98 *
99 * \param inarray array of physical points to be differentiated
100 * \param outarray_d0 the resulting array of derivative in the
101 * \f$\eta_1\f$ direction will be stored in outarray_d0 as output
102 * of the function
103 * \param outarray_d1 the resulting array of derivative in the
104 * \f$\eta_2\f$ direction will be stored in outarray_d1 as output
105 * of the function
106 *
107 * Recall that:
108 * \f$
109 * \hspace{1cm} \begin{array}{llll}
110 * \mbox{Shape} & \mbox{Cartesian coordinate range} &
111 * \mbox{Collapsed coord.} &
112 * \mbox{Collapsed coordinate definition}\\
113 * \mbox{Quadrilateral} & -1 \leq \xi_1,\xi_2 \leq 1
114 * & -1 \leq \eta_1,\eta_2 \leq 1
115 * & \eta_1 = \xi_1, \eta_2 = \xi_2\\
116 * \mbox{Triangle} & -1 \leq \xi_1,\xi_2; \xi_1+\xi_2 \leq 0
117 * & -1 \leq \eta_1,\eta_2 \leq 1
118 * & \eta_1 = \frac{2(1+\xi_1)}{(1-\xi_2)}-1, \eta_2 = \xi_2 \\
119 * \end{array} \f$
120 */
122 const Array<OneD, const NekDouble> &inarray,
123 Array<OneD, NekDouble> &outarray_d0,
124 Array<OneD, NekDouble> &outarray_d1);
126 const int dir, const Array<OneD, const NekDouble> &inarray,
127 Array<OneD, NekDouble> &outarray) override;
129
130 /** \brief This function evaluates the expansion at a single
131 * (arbitrary) point of the domain
132 *
133 * This function is a wrapper around the virtual function
134 * \a v_PhysEvaluate()
135 *
136 * Based on the value of the expansion at the quadrature points,
137 * this function calculates the value of the expansion at an
138 * arbitrary single points (with coordinates \f$ \mathbf{x_c}\f$
139 * given by the pointer \a coords). This operation, equivalent to
140 * \f[ u(\mathbf{x_c}) = \sum_p \phi_p(\mathbf{x_c}) \hat{u}_p \f]
141 * is evaluated using Lagrangian interpolants through the quadrature
142 * points:
143 * \f[ u(\mathbf{x_c}) = \sum_p h_p(\mathbf{x_c}) u_p\f]
144 *
145 * This function requires that the physical value array
146 * \f$\mathbf{u}\f$ (implemented as the attribute #m_phys)
147 * is set.
148 *
149 * \param coords the coordinates of the single point
150 * \return returns the value of the expansion at the single point
151 */
154 const Array<OneD, const NekDouble> &physvals) override;
155
158 const Array<OneD, const NekDouble> &physvals) override;
159
161 const Array<OneD, const NekDouble> &inarray,
162 Array<OneD, NekDouble> &outarray) override;
164 const Array<OneD, const NekDouble> &base0,
165 const Array<OneD, const NekDouble> &base1,
166 const Array<OneD, const NekDouble> &inarray,
168 const bool Deformed, [[maybe_unused]] bool CollDir0 = false,
169 [[maybe_unused]] bool CollDir1 = false) = 0;
170
172 const Array<OneD, const NekDouble> &inarray,
173 Array<OneD, NekDouble> &outarray) override;
174
176 const Array<OneD, const NekDouble> &inarray,
177 Array<OneD, NekDouble> &outarray,
178 const StdRegions::StdMatrixKey &mkey) override;
180 const Array<OneD, const NekDouble> &inarray,
181 Array<OneD, NekDouble> &outarray,
182 const StdRegions::StdMatrixKey &mkey) override;
183
185 const unsigned int traceid,
186 Array<OneD, unsigned int> &maparray) override;
187
189 const unsigned int eid, Array<OneD, unsigned int> &maparray,
190 Array<OneD, int> &signarray, Orientation edgeOrient, int P,
191 int Q) override;
192
194 const int eid, Array<OneD, unsigned int> &maparray,
195 Array<OneD, int> &signarray, Orientation edgeOrient = eForwards,
196 int P = -1, int Q = -1) override;
197
198 STD_REGIONS_EXPORT void v_GenStdMatBwdDeriv(const int dir,
199 DNekMatSharedPtr &mat) override;
200
202 std::shared_ptr<StdExpansion> fromExp,
203 const Array<OneD, const NekDouble> &fromData,
204 Array<OneD, NekDouble> &toData, bool Transpose) override;
205
207 const StdRegions::Orientation orient, Array<OneD, int> &idmap,
208 const int nq0, const int nq1, bool Forwards) override;
209
210 int v_GetShapeDimension() const final
211 {
212 return 2;
213 }
214 bool v_IsCollocatedBasis() const final
215 {
216 return ((m_base[0]->Collocation()) && (m_base[1]->Collocation()));
217 }
218};
219
220typedef std::shared_ptr<StdExpansion2D> StdExpansion2DSharedPtr;
221
222} // namespace Nektar::StdRegions
223
224#endif // STDEXP2D_H
#define STD_REGIONS_EXPORT
Describes the specification for a Basis.
Definition Basis.h:45
virtual void v_IProductWRTBaseKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const Array< OneD, NekDouble > &jac, const bool Deformed, bool CollDir0=false, bool CollDir1=false)=0
void v_GenStdMatBwdDeriv(const int dir, DNekMatSharedPtr &mat) override
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.
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.
~StdExpansion2D() override=default
void v_HelmholtzMatrixOp_MatFree(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::StdMatrixKey &mkey) override
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
void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Calculate the inner product of inarray with respect to the basis B=base0*base1 and put into outarray.
NekDouble v_PhysEvaluateInterp(const Array< OneD, DNekMatSharedPtr > &I, const Array< OneD, const NekDouble > &physvals) override
void IProductWRTBaseKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const Array< OneD, NekDouble > &jac, const bool Deformed, bool CollDir0=false, bool CollDir1=false)
NekDouble BaryTensorDeriv(const Array< OneD, NekDouble > &coord, const Array< OneD, const NekDouble > &inarray, std::array< NekDouble, 3 > &firstOrderDerivs)
void v_GetTraceCoeffMap(const unsigned int traceid, Array< OneD, unsigned int > &maparray) override
void v_ReOrientTracePhysMap(const StdRegions::Orientation orient, Array< OneD, int > &idmap, const int nq0, const int nq1, bool Forwards) override
void v_LaplacianMatrixOp_MatFree(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::StdMatrixKey &mkey) override
void v_MultiplyByStdQuadratureMetric(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
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.
StdExpansion2D(const StdExpansion2D &T)=default
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...
void v_PhysInterp(std::shared_ptr< StdExpansion > fromExp, const Array< OneD, const NekDouble > &fromData, Array< OneD, NekDouble > &toData, bool Transpose) override
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< StdExpansion2D > StdExpansion2DSharedPtr
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
std::shared_ptr< DNekMat > DNekMatSharedPtr