Nektar++
Loading...
Searching...
No Matches
StdNodalTetExp.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: StdNodalTetExp.cpp
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: Nodal tetrahedral routines built upon StdExpansion3D
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#include <LibUtilities/Foundations/ManagerAccess.h> // for PointsManager, etc
37
38namespace Nektar::StdRegions
39{
40
42 const LibUtilities::BasisKey &Bb,
43 const LibUtilities::BasisKey &Bc,
45 : StdExpansion(LibUtilities::StdTetData::getNumberOfCoefficients(
46 Ba.GetNumModes(), Bb.GetNumModes(), Bc.GetNumModes()),
47 3, Ba, Bb, Bc),
48 StdExpansion3D(LibUtilities::StdTetData::getNumberOfCoefficients(
49 Ba.GetNumModes(), Bb.GetNumModes(), Bc.GetNumModes()),
50 Ba, Bb, Bc),
51 StdTetExp(Ba, Bb, Bc), m_nodalPointsKey(Ba.GetNumModes(), Ntype)
52{
53 ASSERTL0(Ba.GetNumModes() <= Bb.GetNumModes(),
54 "order in 'a' direction is higher than order "
55 "in 'b' direction");
56 ASSERTL0(Ba.GetNumModes() <= Bc.GetNumModes(),
57 "order in 'a' direction is higher than order "
58 "in 'c' direction");
59 ASSERTL0(Bb.GetNumModes() <= Bc.GetNumModes(),
60 "order in 'b' direction is higher than order "
61 "in 'c' direction");
62}
63
65{
66 return true;
67}
68
69//-------------------------------
70// Nodal basis specific routines
71//-------------------------------
72
85
86// Operate with transpose of NodalToModal transformation
100
102 Array<OneD, NekDouble> &outarray)
103{
107 DNekMatSharedPtr vdm = GetStdMatrix(Nkey);
108
109 // Multiply out matrix
110 NekVector<NekDouble> modal(m_ncoeffs, inarray, eWrapper);
111 NekVector<NekDouble> nodal(m_ncoeffs, outarray, eWrapper);
112 nodal = (*vdm) * modal;
113}
114
121
123{
124 int i, j;
128
130 GetNodalPoints(r, s, t);
131
132 // Store the values of m_phys in a temporary array
133 int nqtot = GetTotPoints();
134 Array<OneD, NekDouble> tmp_phys(nqtot);
135
136 for (i = 0; i < m_ncoeffs; ++i)
137 {
138 // fill physical space with mode i
139 StdTetExp::v_FillMode(i, tmp_phys);
140
141 // interpolate mode i to the Nodal points 'j' and
142 // store in outarray
143 for (j = 0; j < m_ncoeffs; ++j)
144 {
145 c[0] = r[j];
146 c[1] = s[j];
147 c[2] = t[j];
148 (*Mat)(j, i) = StdExpansion3D::v_PhysEvaluate(c, tmp_phys);
149 }
150 }
151
152 return Mat;
153}
154
155//---------------------------------------
156// Transforms
157//---------------------------------------
158
160 Array<OneD, NekDouble> &outarray)
161{
163 NodalToModal(inarray, tmp);
164 StdTetExp::v_BwdTrans(tmp, outarray);
165}
166
167//---------------------------------------
168// Inner product functions
169//---------------------------------------
170
172 const Array<OneD, const NekDouble> &inarray,
173 Array<OneD, NekDouble> &outarray)
174{
175 StdTetExp::v_IProductWRTBase(inarray, outarray);
176 NodalToModalTranspose(outarray, outarray);
177}
178
180 const int dir, const Array<OneD, const NekDouble> &inarray,
181 Array<OneD, NekDouble> &outarray)
182{
183 StdTetExp::v_IProductWRTDerivBase(dir, inarray, outarray);
184 NodalToModalTranspose(outarray, outarray);
185}
186
187//---------------------------------------
188// Evaluation functions
189//---------------------------------------
190
191void StdNodalTetExp::v_FillMode(const int mode,
192 Array<OneD, NekDouble> &outarray)
193{
194 ASSERTL2(mode >= m_ncoeffs,
195 "calling argument mode is larger than total expansion order");
196
197 Vmath::Zero(m_ncoeffs, outarray, 1);
198 outarray[mode] = 1.0;
199 v_BwdTrans(outarray, outarray);
200}
201
202//---------------------------
203// Helper functions
204//---------------------------
205
210
211//---------------------------------------
212// Mapping functions
213//---------------------------------------
214
215int StdNodalTetExp::v_GetVertexMap(const int localVertexId,
216 [[maybe_unused]] bool useCoeffPacking)
217{
218 ASSERTL0(localVertexId >= 0 && localVertexId <= 3,
219 "Local Vertex ID must be between 0 and 3");
220 return localVertexId;
221}
222
224{
225 unsigned int i;
226 const unsigned int nBndryCoeff = NumBndryCoeffs();
227
228 if (outarray.size() != nBndryCoeff)
229 {
230 outarray = Array<OneD, unsigned int>(nBndryCoeff);
231 }
232
233 for (i = 0; i < nBndryCoeff; i++)
234 {
235 outarray[i] = i;
236 }
237}
238
240{
241 unsigned int i;
242 const unsigned int nBndryCoeff = NumBndryCoeffs();
243
244 if (outarray.size() != m_ncoeffs - nBndryCoeff)
245 {
246 outarray = Array<OneD, unsigned int>(m_ncoeffs - nBndryCoeff);
247 }
248
249 for (i = nBndryCoeff; i < m_ncoeffs; i++)
250 {
251 outarray[i - nBndryCoeff] = i;
252 }
253}
254
255//---------------------------------------
256// Wrapper functions
257//---------------------------------------
258
260{
262
263 switch (mkey.GetMatrixType())
264 {
265 case eNBasisTrans:
266 Mat = GenNBasisTransMatrix();
267 break;
268 default:
270 break;
271 }
272
273 return Mat;
274}
275
280} // namespace Nektar::StdRegions
#define ASSERTL0(condition, msg)
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed to...
Describes the specification for a Basis.
Definition Basis.h:45
int GetNumModes() const
Returns the order of the basis.
Definition Basis.h:74
PointsType GetPointsType() const
Definition Points.h:90
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
The base class for all shapes.
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
DNekMatSharedPtr GetStdMatrix(const StdMatrixKey &mkey)
virtual NekDouble v_PhysEvaluate(const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &physvals)
DNekMatSharedPtr CreateGeneralMatrix(const StdMatrixKey &mkey)
this function generates the mass matrix
LibUtilities::ShapeType DetShapeType() const
This function returns the shape of the expansion domain.
virtual void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)=0
Calculates the inner product of a given function f with the different modes of the expansion.
MatrixType GetMatrixType() const
void NodalToModalTranspose(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
void v_GetBoundaryMap(Array< OneD, unsigned int > &outarray) override
int v_GetVertexMap(const int localVertexId, bool useCoeffPacking=false) override
void NodalToModal(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
void ModalToNodal(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
void GetNodalPoints(Array< OneD, const NekDouble > &x, Array< OneD, const NekDouble > &y, Array< OneD, const NekDouble > &z)
void v_FillMode(const int mode, Array< OneD, NekDouble > &outarray) override
DNekMatSharedPtr v_GenMatrix(const StdMatrixKey &mkey) override
void v_GetInteriorMap(Array< OneD, unsigned int > &outarray) override
void v_IProductWRTDerivBase(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
DNekMatSharedPtr v_CreateStdMatrix(const StdMatrixKey &mkey) override
void v_BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
LibUtilities::ShapeType v_DetShapeType() const override
StdNodalTetExp(const LibUtilities::BasisKey &Ba, const LibUtilities::BasisKey &Bb, const LibUtilities::BasisKey &Bc, const LibUtilities::PointsType Ntype)
LibUtilities::PointsKey m_nodalPointsKey
void v_FillMode(const int mode, Array< OneD, NekDouble > &outarray) override
void v_BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
void v_IProductWRTDerivBase(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
PointsManagerT & PointsManager(void)
static VarFactorsMap NullVarFactorsMap
static ConstFactorMap NullConstFactorMap
static VarCoeffMap NullVarCoeffMap
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
std::shared_ptr< DNekMat > DNekMatSharedPtr
void Zero(int n, T *x, const int incx)
Zero vector.
Definition Vmath.hpp:273