Nektar++
Loading...
Searching...
No Matches
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
49{
50
51/// This class is the abstraction of a global continuous two-
52/// dimensional spectral/hp element expansion which approximates the
53/// solution of a set of partial differential equations.
54class ContField : public DisContField
55{
56public:
57 /// The default constructor.
59
60 /// This constructor sets up global continuous field based on an
61 /// input mesh and boundary conditions.
65 const std::string &variable = "DefaultVar",
66 const bool DeclareCoeffPhysArrays = true,
67 const bool CheckIfSingularSystem = false,
70
71 /// Construct a global continuous field with solution type based on
72 /// another field but using a separate input mesh and boundary
73 /// conditions.
75 const ContField &In, const SpatialDomains::MeshGraphSharedPtr &graph2D,
76 const std::string &variable, const bool DeclareCoeffPhysArrays = true,
77 const bool CheckIfSingularSystem = false);
78
79 /// The copy constructor.
81 bool DeclareCoeffPhysArrays = true);
82
83 /// Copy constructor.
86 const ExpList &In);
87
88 /// The default destructor.
90
91 /// Assembles the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
92 /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
93 inline void Assemble();
94
95 /// Assembles the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
96 /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
97 inline void Assemble(const Array<OneD, const NekDouble> &inarray,
98 Array<OneD, NekDouble> &outarray) const;
99
100 /// Returns the map from local to global level.
101 inline const AssemblyMapCGSharedPtr &GetLocalToGlobalMap() const;
102
103 /// Solves the two-dimensional Laplace equation, subject to the
104 /// boundary conditions specified.
106 const Array<OneD, const NekDouble> &inarray,
107 Array<OneD, NekDouble> &outarray,
109 const Array<OneD, Array<OneD, NekDouble>> &variablecoeffs =
111 NekDouble time = 0.0);
112
113 /// Compute the eigenvalues of the linear advection operator.
115 const NekDouble ax, const NekDouble ay, Array<OneD, NekDouble> &Real,
118
119 inline int GetGlobalMatrixNnz(const GlobalMatrixKey &gkey);
120
121 /// Solves the linear system specified by the key \a key.
123 const GlobalLinSysKey &key, const Array<OneD, const NekDouble> &rhs,
126
135
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
183 /// Add Neumann Boundary Conditions forcing to outarray
185 Array<OneD, NekDouble> &outarray) override;
186
187 /// Add Robin Boundary Conditions forcing to outarray
189 Array<OneD, NekDouble> &outarray) override;
190
192 const Array<OneD, NekDouble> coeffs) override;
193
195 const int nreg, const Array<OneD, NekDouble> coeffs) override;
196
197 /// Assembly and average of the global coefficients
198 /// \f$\boldsymbol{\hat{u}}_g\f$ from the local coefficients
199 /// \f$\boldsymbol{\hat{u}}_l\f$.
201 const Array<OneD, const NekDouble> &inarray,
202 Array<OneD, NekDouble> &outarray, bool useComm) override;
203
204 MULTI_REGIONS_EXPORT void v_AvgAssemble(bool useComm) override;
205
206 /// Gathers the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
207 /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
209 const Array<OneD, const NekDouble> &inarray,
210 Array<OneD, NekDouble> &outarray, bool useComm) override;
211
212 MULTI_REGIONS_EXPORT void v_LocalToGlobal(bool useComm) override;
213
214 /// Scatters from the global coefficients
215 /// \f$\boldsymbol{\hat{u}}_g\f$ to the local coefficients
216 /// \f$\boldsymbol{\hat{u}}_l\f$.
218 const Array<OneD, const NekDouble> &inarray,
219 Array<OneD, NekDouble> &outarray) override;
220
221 MULTI_REGIONS_EXPORT void v_GlobalToLocal(void) override;
222
223 /// Template method virtual forwarder for FwdTrans().
225 const Array<OneD, const NekDouble> &inarray,
226 Array<OneD, NekDouble> &outarray) override;
227
228 /// Template method virtual forwarded for SmoothField().
230 Array<OneD, NekDouble> &field) override;
231
232 /// Template method virtual forwarder for MultiplyByInvMassMatrix().
234 const Array<OneD, const NekDouble> &inarray,
235 Array<OneD, NekDouble> &outarray) override;
236
237 /// Solves the two-dimensional Helmholtz equation, subject to the
238 /// boundary conditions specified.
241 Array<OneD, NekDouble> &outarray,
242 const StdRegions::ConstFactorMap &factors,
243 const StdRegions::VarCoeffMap &varcoeff,
244 const StdRegions::VarFactorsMap &varfactors,
245 const Array<OneD, const NekDouble> &dirForcing,
246 const bool PhysSpaceForcing) override;
247
248 // Solve the linear advection problem assuming that m_coeffs
249 // vector contains an intial estimate for solution
252 const Array<OneD, const NekDouble> &inarray,
253 Array<OneD, NekDouble> &outarray,
254 const StdRegions::ConstFactorMap &factors,
255 const StdRegions::VarCoeffMap &varcoeff,
256 const StdRegions::VarFactorsMap &varfactors,
257 const Array<OneD, const NekDouble> &dirForcing,
258 const bool PhysSpaceForcing) override;
259
260 // Solve the linear advection problem assuming that m_coeff
261 // vector contains an intial estimate for solution
263 const Array<OneD, const NekDouble> &inarray,
264 Array<OneD, NekDouble> &outarray,
265 const StdRegions::ConstFactorMap &factors,
266 const StdRegions::VarCoeffMap &varcoeff,
267 const StdRegions::VarFactorsMap &varfactors,
268 const Array<OneD, const NekDouble> &dirForcing,
269 const bool PhysSpaceForcing) override;
270
271 /// Returns the boundary conditions expansion.
273 v_GetBndCondExpansions() override;
274
275 /// Template method virtual forwarder for GetBndConditions().
277 OneD, const SpatialDomains ::BoundaryConditionShPtr> &
278 v_GetBndConditions() override;
280
281 // Get manager pool count; intended for unit tests
282 MULTI_REGIONS_EXPORT int v_GetPoolCount(std::string) override;
283
284 // Remove GlobalLinSys, StaticCond Blocks and LocalMatrix Blocks
286 bool) override;
287
289 v_GetGJPData(void) override
290 {
291 return m_GJPData;
292 }
293};
294
295typedef std::shared_ptr<ContField> ContFieldSharedPtr;
296
297/**
298 * This operation is evaluated as:
299 * \f{tabbing}
300 * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
301 * > > Do \= $i=$ $0,N_m^e-1$ \\
302 * > > > $\boldsymbol{\hat{u}}_g[\mbox{map}[e][i]] =
303 * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]+\mbox{sign}[e][i] \cdot
304 * \boldsymbol{\hat{u}}^{e}[i]$\\
305 * > > continue\\
306 * > continue
307 * \f}
308 * where \a map\f$[e][i]\f$ is the mapping array and \a
309 * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
310 * correct modal connectivity between the different elements (both
311 * these arrays are contained in the data member #m_locToGloMap). This
312 * operation is equivalent to the gather operation
313 * \f$\boldsymbol{\hat{u}}_g=\mathcal{A}^{T}\boldsymbol{\hat{u}}_l\f$,
314 * where \f$\mathcal{A}\f$ is the
315 * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
316 *
317 * @note The array #m_coeffs should be filled with the local
318 * coefficients \f$\boldsymbol{\hat{u}}_l\f$ and that the
319 * resulting global coefficients \f$\boldsymbol{\hat{u}}_g\f$
320 * will be stored in #m_coeffs.
321 */
323{
324 m_locToGloMap->Assemble(m_coeffs, m_coeffs);
325}
326
327/**
328 * This operation is evaluated as:
329 * \f{tabbing}
330 * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
331 * > > Do \= $i=$ $0,N_m^e-1$ \\
332 * > > > $\boldsymbol{\hat{u}}_g[\mbox{map}[e][i]] =
333 * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]+\mbox{sign}[e][i] \cdot
334 * \boldsymbol{\hat{u}}^{e}[i]$\\
335 * > > continue\\
336 * > continue
337 * \f}
338 * where \a map\f$[e][i]\f$ is the mapping array and \a
339 * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
340 * correct modal connectivity between the different elements (both
341 * these arrays are contained in the data member #m_locToGloMap). This
342 * operation is equivalent to the gather operation
343 * \f$\boldsymbol{\hat{u}}_g=\mathcal{A}^{T}\boldsymbol{\hat{u}}_l\f$,
344 * where \f$\mathcal{A}\f$ is the
345 * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
346 *
347 * @param inarray An array of size \f$N_\mathrm{eof}\f$
348 * containing the local degrees of freedom
349 * \f$\boldsymbol{x}_l\f$.
350 * @param outarray The resulting global degrees of freedom
351 * \f$\boldsymbol{x}_g\f$ will be stored in this
352 * array of size \f$N_\mathrm{dof}\f$.
353 */
355 Array<OneD, NekDouble> &outarray) const
356{
357 m_locToGloMap->Assemble(inarray, outarray);
358}
359
361{
362 return m_locToGloMap;
363}
364
370
376
378{
380 "To use method must have a AssemblyMap "
381 "attached to key");
382
383 auto matrixIter = m_globalMat->find(gkey);
384
385 if (matrixIter == m_globalMat->end())
386 {
387 return 0;
388 }
389 else
390 {
391 return matrixIter->second->GetNumNonZeroEntries();
392 }
393
394 return 0;
395}
396
397} // namespace Nektar::MultiRegions
398
399#endif // MULTIERGIONS_CONTFIELD2D_H
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#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:55
~ContField() override
The default destructor.
void v_FillBndCondFromField(const Array< OneD, NekDouble > coeffs) override
const GJPStabilisationSharedPtr v_GetGJPData(void) override
Definition ContField.h:289
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 v_ImposeRobinConditions(Array< OneD, NekDouble > &outarray) override
Add Robin Boundary Conditions forcing to outarray.
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.
GlobalLinSysKey v_LinearAdvectionDiffusionReactionSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::ConstFactorMap &factors, const StdRegions::VarCoeffMap &varcoeff, const StdRegions::VarFactorsMap &varfactors, const Array< OneD, const NekDouble > &dirForcing, const bool PhysSpaceForcing) override
GlobalLinSysSharedPtr GenGlobalLinSys(const GlobalLinSysKey &mkey)
AssemblyMapCGSharedPtr m_locToGloMap
(A shared pointer to) the object which contains all the required information for the transformation f...
Definition ContField.h:152
void v_FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Template method virtual forwarder for FwdTrans().
int v_GetPoolCount(std::string) override
void v_SmoothField(Array< OneD, NekDouble > &field) override
Template method virtual forwarded for SmoothField().
const Array< OneD, const SpatialDomains ::BoundaryConditionShPtr > & v_GetBndConditions() override
Template method virtual forwarder for GetBndConditions().
Definition ContField.h:372
GlobalLinSysKey v_HelmSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::ConstFactorMap &factors, const StdRegions::VarCoeffMap &varcoeff, const StdRegions::VarFactorsMap &varfactors, const Array< OneD, const NekDouble > &dirForcing, const bool PhysSpaceForcing) override
Solves the two-dimensional Helmholtz equation, subject to the boundary conditions specified.
void v_ClearGlobalLinSysManager(void) override
void v_GlobalToLocal(void) override
const AssemblyMapCGSharedPtr & GetLocalToGlobalMap() const
Returns the map from local to global level.
Definition ContField.h:360
void v_UnsetGlobalLinSys(GlobalLinSysKey, bool) override
int GetGlobalMatrixNnz(const GlobalMatrixKey &gkey)
Definition ContField.h:377
void v_LocalToGlobal(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool useComm) override
Gathers the global coefficients from the local coefficients .
GlobalLinSysKey v_LinearAdvectionReactionSolve(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::ConstFactorMap &factors, const StdRegions::VarCoeffMap &varcoeff, const StdRegions::VarFactorsMap &varfactors, const Array< OneD, const NekDouble > &dirForcing, const bool PhysSpaceForcing) override
void SetGJPData(const GJPStabilisationSharedPtr &GJPData)
Definition ContField.h:141
void v_ImposeNeumannConditions(Array< OneD, NekDouble > &outarray) override
Add Neumann Boundary Conditions forcing to outarray.
const GJPStabilisationSharedPtr GetGJPData()
Definition ContField.h:136
GlobalMatrixMapShPtr m_globalMat
(A shared pointer to) a list which collects all the global matrices being assembled,...
Definition ContField.h:157
void v_AvgAssemble(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool useComm) override
Assembly and average of the global coefficients from the local coefficients .
GlobalLinSysSharedPtr GetGlobalLinSys(const GlobalLinSysKey &mkey)
Returns the linear system specified by the key mkey.
void v_ImposeDirichletConditions(Array< OneD, NekDouble > &outarray) override
Impose the Dirichlet Boundary Conditions on outarray.
const Array< OneD, const MultiRegions::ExpListSharedPtr > & v_GetBndCondExpansions() override
Returns the boundary conditions expansion.
Definition ContField.h:366
void v_MultiplyByInvMassMatrix(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Template method virtual forwarder for MultiplyByInvMassMatrix().
GlobalMatrixSharedPtr GetGlobalMatrix(const GlobalMatrixKey &mkey)
Returns the global matrix specified by mkey.
ContField()
The default constructor.
Definition ContField.cpp:87
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.
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.
void Assemble()
Assembles the global coefficients from the local coefficients .
Definition ContField.h:322
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...
Array< OneD, SpatialDomains::BoundaryConditionShPtr > m_bndConditions
An array which contains the information about the boundary condition structure definition on the diff...
Array< OneD, MultiRegions::ExpListSharedPtr > m_bndCondExpansions
An object which contains the discretised boundary conditions.
Base class for all multi-elemental spectral/hp expansions.
Definition ExpList.h:98
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
Definition ExpList.h:1149
std::shared_ptr< ExpList > GetSharedThisPtr()
Returns a shared pointer to the current object.
Definition ExpList.h:985
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
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
std::shared_ptr< GlobalMatrix > GlobalMatrixSharedPtr
Shared pointer to a GlobalMatrix object.
std::shared_ptr< GlobalMatrixMap > GlobalMatrixMapShPtr
Shared pointer to a global matrix map.
std::shared_ptr< GJPStabilisation > GJPStabilisationSharedPtr
std::shared_ptr< ContField > ContFieldSharedPtr
Definition ContField.h:295
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition MeshGraph.h:224
std::map< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap
std::map< ConstFactorType, NekDouble > ConstFactorMap
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray
static Array< OneD, NekDouble > NullNekDouble1DArray