Nektar++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ContField.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: ContField.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: Field definition in tow-dimensions
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#ifndef NEKTAR_LIBS_MULTIREGIONS_CONTFIELD2D_H
36#define NEKTAR_LIBS_MULTIREGIONS_CONTFIELD2D_H
37
47
48namespace Nektar
49{
50namespace MultiRegions
51{
52
53/// This class is the abstraction of a global continuous two-
54/// dimensional spectral/hp element expansion which approximates the
55/// solution of a set of partial differential equations.
56class ContField : public DisContField
57{
58public:
59 /// The default constructor.
61
62 /// This constructor sets up global continuous field based on an
63 /// input mesh and boundary conditions.
67 const std::string &variable = "DefaultVar",
68 const bool DeclareCoeffPhysArrays = true,
69 const bool CheckIfSingularSystem = false,
72
73 /// Construct a global continuous field with solution type based on
74 /// another field but using a separate input mesh and boundary
75 /// conditions.
77 const ContField &In, const SpatialDomains::MeshGraphSharedPtr &graph2D,
78 const std::string &variable, const bool DeclareCoeffPhysArrays = true,
79 const bool CheckIfSingularSystem = false);
80
81 /// The copy constructor.
83 bool DeclareCoeffPhysArrays = true);
84
85 /// Copy constructor.
88 const ExpList &In);
89
90 /// The default destructor.
92
93 /// Assembles the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
94 /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
95 inline void Assemble();
96
97 /// Assembles the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
98 /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
99 inline void Assemble(const Array<OneD, const NekDouble> &inarray,
100 Array<OneD, NekDouble> &outarray) const;
101
102 /// Returns the map from local to global level.
103 inline const AssemblyMapCGSharedPtr &GetLocalToGlobalMap() const;
104
105 /// Solves the two-dimensional Laplace equation, subject to the
106 /// boundary conditions specified.
108 const Array<OneD, const NekDouble> &inarray,
109 Array<OneD, NekDouble> &outarray,
111 const Array<OneD, Array<OneD, NekDouble>> &variablecoeffs =
113 NekDouble time = 0.0);
114
115 /// Compute the eigenvalues of the linear advection operator.
117 const NekDouble ax, const NekDouble ay, Array<OneD, NekDouble> &Real,
120
121 inline int GetGlobalMatrixNnz(const GlobalMatrixKey &gkey);
122
123 /// Solves the linear system specified by the key \a key.
125 const GlobalLinSysKey &key, const Array<OneD, const NekDouble> &rhs,
128
130 {
131 // initialize if required
132 if (!m_GJPData)
133 {
136 }
137
138 return m_GJPData;
139 }
140
142 const GJPStabilisationSharedPtr &GJPData)
143 {
144 m_GJPData = GJPData;
145 }
146
147protected:
148 // private:
149 /// (A shared pointer to) the object which contains all the
150 /// required information for the transformation from local to
151 /// global degrees of freedom.
153
154 /// (A shared pointer to) a list which collects all the global
155 /// matrices being assembled, such that they should be constructed
156 /// only once.
158
159 /// A manager which collects all the global
160 /// linear systems being assembled, such that they should be
161 /// constructed only once.
164
165 /// Data for Gradient Jump Penalisation (GJP) stabilisaiton
167
168 /// Returns the global matrix specified by \a mkey.
170 GetGlobalMatrix(const GlobalMatrixKey &mkey);
171
172 /// Returns the linear system specified by the key \a mkey.
174 GetGlobalLinSys(const GlobalLinSysKey &mkey);
175
177 GenGlobalLinSys(const GlobalLinSysKey &mkey);
178
179 /// Impose the Dirichlet Boundary Conditions on outarray
181 Array<OneD, NekDouble> &outarray) override;
182
184 const Array<OneD, NekDouble> coeffs) override;
185
187 const int nreg, const Array<OneD, NekDouble> coeffs) override;
188
189 /// Gathers the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
190 /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
192 const Array<OneD, const NekDouble> &inarray,
193 Array<OneD, NekDouble> &outarray, bool useComm) override;
194
195 MULTI_REGIONS_EXPORT virtual void v_LocalToGlobal(bool useComm) override;
196
197 /// Scatters from the global coefficients
198 /// \f$\boldsymbol{\hat{u}}_g\f$ to the local coefficients
199 /// \f$\boldsymbol{\hat{u}}_l\f$.
201 const Array<OneD, const NekDouble> &inarray,
202 Array<OneD, NekDouble> &outarray) override;
203
204 MULTI_REGIONS_EXPORT virtual void v_GlobalToLocal(void) override;
205
206 /// Template method virtual forwarder for FwdTrans().
207 MULTI_REGIONS_EXPORT virtual void v_FwdTrans(
208 const Array<OneD, const NekDouble> &inarray,
209 Array<OneD, NekDouble> &outarray) override;
210
211 /// Template method virtual forwarded for SmoothField().
213 Array<OneD, NekDouble> &field) override;
214
215 /// Template method virtual forwarder for MultiplyByInvMassMatrix().
217 const Array<OneD, const NekDouble> &inarray,
218 Array<OneD, NekDouble> &outarray) override;
219
220 /// Solves the two-dimensional Helmholtz equation, subject to the
221 /// boundary conditions specified.
223 const Array<OneD, const NekDouble> &inarray,
224 Array<OneD, NekDouble> &outarray,
226 const StdRegions::VarCoeffMap &varcoeff,
227 const MultiRegions::VarFactorsMap &varfactors,
228 const Array<OneD, const NekDouble> &dirForcing,
229 const bool PhysSpaceForcing) override;
230
231 // Solve the linear advection problem assuming that m_coeffs
232 // vector contains an intial estimate for solution
235 const Array<OneD, const NekDouble> &inarray,
236 Array<OneD, NekDouble> &outarray,
238 const StdRegions::VarCoeffMap &varcoeff,
239 const MultiRegions::VarFactorsMap &varfactors,
240 const Array<OneD, const NekDouble> &dirForcing,
241 const bool PhysSpaceForcing) override;
242
243 // Solve the linear advection problem assuming that m_coeff
244 // vector contains an intial estimate for solution
246 const Array<OneD, Array<OneD, NekDouble>> &velocity,
247 const Array<OneD, const NekDouble> &inarray,
248 Array<OneD, NekDouble> &outarray, const NekDouble lambda,
249 const Array<OneD, const NekDouble> &dirForcing =
250 NullNekDouble1DArray) override;
251
252 /// Returns the boundary conditions expansion.
254 &v_GetBndCondExpansions() override;
255
256 /// Template method virtual forwarder for GetBndConditions().
257 MULTI_REGIONS_EXPORT virtual const Array<
259 &v_GetBndConditions() override;
260 MULTI_REGIONS_EXPORT virtual void v_ClearGlobalLinSysManager(void) override;
261
262 // Get manager pool count; intended for unit tests
263 MULTI_REGIONS_EXPORT int v_GetPoolCount(std::string) override;
264
265 // Remove GlobalLinSys, StaticCond Blocks and LocalMatrix Blocks
267 bool) override;
268};
269
270typedef std::shared_ptr<ContField> ContFieldSharedPtr;
271
272/**
273 * This operation is evaluated as:
274 * \f{tabbing}
275 * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
276 * > > Do \= $i=$ $0,N_m^e-1$ \\
277 * > > > $\boldsymbol{\hat{u}}_g[\mbox{map}[e][i]] =
278 * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]+\mbox{sign}[e][i] \cdot
279 * \boldsymbol{\hat{u}}^{e}[i]$\\
280 * > > continue\\
281 * > continue
282 * \f}
283 * where \a map\f$[e][i]\f$ is the mapping array and \a
284 * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
285 * correct modal connectivity between the different elements (both
286 * these arrays are contained in the data member #m_locToGloMap). This
287 * operation is equivalent to the gather operation
288 * \f$\boldsymbol{\hat{u}}_g=\mathcal{A}^{T}\boldsymbol{\hat{u}}_l\f$,
289 * where \f$\mathcal{A}\f$ is the
290 * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
291 *
292 * @note The array #m_coeffs should be filled with the local
293 * coefficients \f$\boldsymbol{\hat{u}}_l\f$ and that the
294 * resulting global coefficients \f$\boldsymbol{\hat{u}}_g\f$
295 * will be stored in #m_coeffs.
296 */
298{
299 m_locToGloMap->Assemble(m_coeffs, m_coeffs);
300}
301
302/**
303 * This operation is evaluated as:
304 * \f{tabbing}
305 * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
306 * > > Do \= $i=$ $0,N_m^e-1$ \\
307 * > > > $\boldsymbol{\hat{u}}_g[\mbox{map}[e][i]] =
308 * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]+\mbox{sign}[e][i] \cdot
309 * \boldsymbol{\hat{u}}^{e}[i]$\\
310 * > > continue\\
311 * > continue
312 * \f}
313 * where \a map\f$[e][i]\f$ is the mapping array and \a
314 * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
315 * correct modal connectivity between the different elements (both
316 * these arrays are contained in the data member #m_locToGloMap). This
317 * operation is equivalent to the gather operation
318 * \f$\boldsymbol{\hat{u}}_g=\mathcal{A}^{T}\boldsymbol{\hat{u}}_l\f$,
319 * where \f$\mathcal{A}\f$ is the
320 * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
321 *
322 * @param inarray An array of size \f$N_\mathrm{eof}\f$
323 * containing the local degrees of freedom
324 * \f$\boldsymbol{x}_l\f$.
325 * @param outarray The resulting global degrees of freedom
326 * \f$\boldsymbol{x}_g\f$ will be stored in this
327 * array of size \f$N_\mathrm{dof}\f$.
328 */
330 Array<OneD, NekDouble> &outarray) const
331{
332 m_locToGloMap->Assemble(inarray, outarray);
333}
334
336{
337 return m_locToGloMap;
338}
339
342{
343 return m_bndCondExpansions;
344}
345
348{
349 return m_bndConditions;
350}
351
353{
355 "To use method must have a AssemblyMap "
356 "attached to key");
357
358 auto matrixIter = m_globalMat->find(gkey);
359
360 if (matrixIter == m_globalMat->end())
361 {
362 return 0;
363 }
364 else
365 {
366 return matrixIter->second->GetNumNonZeroEntries();
367 }
368
369 return 0;
370}
371
372} // namespace MultiRegions
373} // namespace Nektar
374
375#endif // MULTIERGIONS_CONTFIELD2D_H
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
#define MULTI_REGIONS_EXPORT
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
This class is the abstraction of a global continuous two- dimensional spectral/hp element expansion w...
Definition: ContField.h:57
virtual void v_FillBndCondFromField(const Array< OneD, NekDouble > coeffs) override
Definition: ContField.cpp:618
virtual ~ContField()
The default destructor.
Definition: ContField.cpp:227
LibUtilities::NekManager< GlobalLinSysKey, GlobalLinSys > m_globalLinSysManager
A manager which collects all the global linear systems being assembled, such that they should be cons...
Definition: ContField.h:163
void LaplaceSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray, const Array< OneD, Array< OneD, NekDouble > > &variablecoeffs=NullNekDoubleArrayOfArray, NekDouble time=0.0)
Solves the two-dimensional Laplace equation, subject to the boundary conditions specified.
Definition: ContField.cpp:338
GlobalLinSysSharedPtr GenGlobalLinSys(const GlobalLinSysKey &mkey)
Definition: ContField.cpp:550
virtual GlobalLinSysKey v_HelmSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::ConstFactorMap &factors, const StdRegions::VarCoeffMap &varcoeff, const MultiRegions::VarFactorsMap &varfactors, const Array< OneD, const NekDouble > &dirForcing, const bool PhysSpaceForcing) override
Solves the two-dimensional Helmholtz equation, subject to the boundary conditions specified.
Definition: ContField.cpp:774
const GJPStabilisationSharedPtr GetGJPForcing()
Definition: ContField.h:129
AssemblyMapCGSharedPtr m_locToGloMap
(A shared pointer to) the object which contains all the required information for the transformation f...
Definition: ContField.h:152
virtual void v_FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Template method virtual forwarder for FwdTrans().
Definition: ContField.cpp:244
int v_GetPoolCount(std::string) override
Definition: ContField.cpp:1034
virtual void v_SmoothField(Array< OneD, NekDouble > &field) override
Template method virtual forwarded for SmoothField().
Definition: ContField.cpp:261
virtual const Array< OneD, const SpatialDomains ::BoundaryConditionShPtr > & v_GetBndConditions() override
Template method virtual forwarder for GetBndConditions().
Definition: ContField.h:347
virtual void v_ClearGlobalLinSysManager(void) override
Definition: ContField.cpp:1026
virtual void v_GlobalToLocal(void) override
Definition: ContField.cpp:715
const AssemblyMapCGSharedPtr & GetLocalToGlobalMap() const
Returns the map from local to global level.
Definition: ContField.h:335
void v_UnsetGlobalLinSys(GlobalLinSysKey, bool) override
Definition: ContField.cpp:1044
int GetGlobalMatrixNnz(const GlobalMatrixKey &gkey)
Definition: ContField.h:352
virtual void v_LocalToGlobal(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool useComm) override
Gathers the global coefficients from the local coefficients .
Definition: ContField.cpp:741
void SetGJPForcing(const GJPStabilisationSharedPtr &GJPData)
Definition: ContField.h:141
GlobalMatrixMapShPtr m_globalMat
(A shared pointer to) a list which collects all the global matrices being assembled,...
Definition: ContField.h:157
virtual void v_LinearAdvectionReactionSolve(const Array< OneD, Array< OneD, NekDouble > > &velocity, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const NekDouble lambda, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray) override
Definition: ContField.cpp:1001
GlobalLinSysSharedPtr GetGlobalLinSys(const GlobalLinSysKey &mkey)
Returns the linear system specified by the key mkey.
Definition: ContField.cpp:545
virtual void v_ImposeDirichletConditions(Array< OneD, NekDouble > &outarray) override
Impose the Dirichlet Boundary Conditions on outarray.
Definition: ContField.cpp:558
const Array< OneD, const MultiRegions::ExpListSharedPtr > & v_GetBndCondExpansions() override
Returns the boundary conditions expansion.
Definition: ContField.h:341
virtual void v_MultiplyByInvMassMatrix(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Template method virtual forwarder for MultiplyByInvMassMatrix().
Definition: ContField.cpp:279
GlobalMatrixSharedPtr GetGlobalMatrix(const GlobalMatrixKey &mkey)
Returns the global matrix specified by mkey.
Definition: ContField.cpp:515
ContField()
The default constructor.
Definition: ContField.cpp:89
void LinearAdvectionEigs(const NekDouble ax, const NekDouble ay, Array< OneD, NekDouble > &Real, Array< OneD, NekDouble > &Imag, Array< OneD, NekDouble > &Evecs=NullNekDouble1DArray)
Compute the eigenvalues of the linear advection operator.
Definition: ContField.cpp:416
virtual GlobalLinSysKey v_LinearAdvectionDiffusionReactionSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::ConstFactorMap &factors, const StdRegions::VarCoeffMap &varcoeff, const MultiRegions::VarFactorsMap &varfactors, const Array< OneD, const NekDouble > &dirForcing, const bool PhysSpaceForcing) override
Definition: ContField.cpp:885
void GlobalSolve(const GlobalLinSysKey &key, const Array< OneD, const NekDouble > &rhs, Array< OneD, NekDouble > &inout, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray)
Solves the linear system specified by the key key.
Definition: ContField.cpp:488
void Assemble()
Assembles the global coefficients from the local coefficients .
Definition: ContField.h:297
GJPStabilisationSharedPtr m_GJPData
Data for Gradient Jump Penalisation (GJP) stabilisaiton.
Definition: ContField.h:166
This class is the abstractio n of a global discontinuous two- dimensional spectral/hp element expansi...
Definition: DisContField.h:58
Array< OneD, SpatialDomains::BoundaryConditionShPtr > m_bndConditions
An array which contains the information about the boundary condition structure definition on the diff...
Definition: DisContField.h:137
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
An object which contains the discretised boundary conditions.
Definition: DisContField.h:150
Base class for all multi-elemental spectral/hp expansions.
Definition: ExpList.h:102
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
Definition: ExpList.h:1092
std::shared_ptr< ExpList > GetSharedThisPtr()
Returns a shared pointer to the current object.
Definition: ExpList.h:966
Describes a matrix with ordering defined by a local to global map.
bool LocToGloMapIsDefined() const
Returns true if a local to global map is defined.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< AssemblyMapCG > AssemblyMapCGSharedPtr
Definition: AssemblyMapCG.h:52
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:53
std::shared_ptr< GlobalMatrix > GlobalMatrixSharedPtr
Shared pointer to a GlobalMatrix object.
Definition: GlobalMatrix.h:86
std::shared_ptr< GlobalMatrixMap > GlobalMatrixMapShPtr
Shared pointer to a global matrix map.
Definition: GlobalMatrix.h:90
std::map< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap
std::shared_ptr< GJPStabilisation > GJPStabilisationSharedPtr
std::shared_ptr< ContField > ContFieldSharedPtr
Definition: ContField.h:270
std::shared_ptr< BoundaryConditionBase > BoundaryConditionShPtr
Definition: Conditions.h:212
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:176
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:408
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Definition: StdRegions.hpp:352
StdRegions::ConstFactorMap factors
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray
static Array< OneD, NekDouble > NullNekDouble1DArray
double NekDouble