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
128 {
129 // initialize if required
130 if (!m_GJPData)
131 {
134 }
135
136 return m_GJPData;
137 }
138
140 const GJPStabilisationSharedPtr &GJPData)
141 {
142 m_GJPData = GJPData;
143 }
144
145protected:
146 // private:
147 /// (A shared pointer to) the object which contains all the
148 /// required information for the transformation from local to
149 /// global degrees of freedom.
151
152 /// (A shared pointer to) a list which collects all the global
153 /// matrices being assembled, such that they should be constructed
154 /// only once.
156
157 /// A manager which collects all the global
158 /// linear systems being assembled, such that they should be
159 /// constructed only once.
162
163 /// Data for Gradient Jump Penalisation (GJP) stabilisaiton
165
166 /// Returns the global matrix specified by \a mkey.
168 GetGlobalMatrix(const GlobalMatrixKey &mkey);
169
170 /// Returns the linear system specified by the key \a mkey.
172 GetGlobalLinSys(const GlobalLinSysKey &mkey);
173
175 GenGlobalLinSys(const GlobalLinSysKey &mkey);
176
177 /// Impose the Dirichlet Boundary Conditions on outarray
179 Array<OneD, NekDouble> &outarray) override;
180
181 /// Add Neumann Boundary Conditions forcing to outarray
183 Array<OneD, NekDouble> &outarray) override;
184
185 /// Add Robin Boundary Conditions forcing to outarray
187 Array<OneD, NekDouble> &outarray) override;
188
190 const Array<OneD, NekDouble> coeffs) override;
191
193 const int nreg, const Array<OneD, NekDouble> coeffs) override;
194
195 /// Gathers the global coefficients \f$\boldsymbol{\hat{u}}_g\f$
196 /// from the local coefficients \f$\boldsymbol{\hat{u}}_l\f$.
198 const Array<OneD, const NekDouble> &inarray,
199 Array<OneD, NekDouble> &outarray, bool useComm) override;
200
201 MULTI_REGIONS_EXPORT void v_LocalToGlobal(bool useComm) override;
202
203 /// Scatters from the global coefficients
204 /// \f$\boldsymbol{\hat{u}}_g\f$ to the local coefficients
205 /// \f$\boldsymbol{\hat{u}}_l\f$.
207 const Array<OneD, const NekDouble> &inarray,
208 Array<OneD, NekDouble> &outarray) override;
209
210 MULTI_REGIONS_EXPORT void v_GlobalToLocal(void) override;
211
212 /// Template method virtual forwarder for FwdTrans().
214 const Array<OneD, const NekDouble> &inarray,
215 Array<OneD, NekDouble> &outarray) override;
216
217 /// Template method virtual forwarded for SmoothField().
219 Array<OneD, NekDouble> &field) override;
220
221 /// Template method virtual forwarder for MultiplyByInvMassMatrix().
223 const Array<OneD, const NekDouble> &inarray,
224 Array<OneD, NekDouble> &outarray) override;
225
226 /// Solves the two-dimensional Helmholtz equation, subject to the
227 /// boundary conditions specified.
230 Array<OneD, NekDouble> &outarray,
231 const StdRegions::ConstFactorMap &factors,
232 const StdRegions::VarCoeffMap &varcoeff,
233 const MultiRegions::VarFactorsMap &varfactors,
234 const Array<OneD, const NekDouble> &dirForcing,
235 const bool PhysSpaceForcing) override;
236
237 // Solve the linear advection problem assuming that m_coeffs
238 // vector contains an intial estimate for solution
241 const Array<OneD, const NekDouble> &inarray,
242 Array<OneD, NekDouble> &outarray,
243 const StdRegions::ConstFactorMap &factors,
244 const StdRegions::VarCoeffMap &varcoeff,
245 const MultiRegions::VarFactorsMap &varfactors,
246 const Array<OneD, const NekDouble> &dirForcing,
247 const bool PhysSpaceForcing) override;
248
249 // Solve the linear advection problem assuming that m_coeff
250 // 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 MultiRegions::VarFactorsMap &varfactors,
257 const Array<OneD, const NekDouble> &dirForcing,
258 const bool PhysSpaceForcing) override;
259
260 /// Returns the boundary conditions expansion.
262 v_GetBndCondExpansions() override;
263
264 /// Template method virtual forwarder for GetBndConditions().
266 OneD, const SpatialDomains ::BoundaryConditionShPtr> &
267 v_GetBndConditions() override;
269
270 // Get manager pool count; intended for unit tests
271 MULTI_REGIONS_EXPORT int v_GetPoolCount(std::string) override;
272
273 // Remove GlobalLinSys, StaticCond Blocks and LocalMatrix Blocks
275 bool) override;
276};
277
278typedef std::shared_ptr<ContField> ContFieldSharedPtr;
279
280/**
281 * This operation is evaluated as:
282 * \f{tabbing}
283 * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
284 * > > Do \= $i=$ $0,N_m^e-1$ \\
285 * > > > $\boldsymbol{\hat{u}}_g[\mbox{map}[e][i]] =
286 * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]+\mbox{sign}[e][i] \cdot
287 * \boldsymbol{\hat{u}}^{e}[i]$\\
288 * > > continue\\
289 * > continue
290 * \f}
291 * where \a map\f$[e][i]\f$ is the mapping array and \a
292 * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
293 * correct modal connectivity between the different elements (both
294 * these arrays are contained in the data member #m_locToGloMap). This
295 * operation is equivalent to the gather operation
296 * \f$\boldsymbol{\hat{u}}_g=\mathcal{A}^{T}\boldsymbol{\hat{u}}_l\f$,
297 * where \f$\mathcal{A}\f$ is the
298 * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
299 *
300 * @note The array #m_coeffs should be filled with the local
301 * coefficients \f$\boldsymbol{\hat{u}}_l\f$ and that the
302 * resulting global coefficients \f$\boldsymbol{\hat{u}}_g\f$
303 * will be stored in #m_coeffs.
304 */
306{
307 m_locToGloMap->Assemble(m_coeffs, m_coeffs);
308}
309
310/**
311 * This operation is evaluated as:
312 * \f{tabbing}
313 * \hspace{1cm} \= Do \= $e=$ $1, N_{\mathrm{el}}$ \\
314 * > > Do \= $i=$ $0,N_m^e-1$ \\
315 * > > > $\boldsymbol{\hat{u}}_g[\mbox{map}[e][i]] =
316 * \boldsymbol{\hat{u}}_g[\mbox{map}[e][i]]+\mbox{sign}[e][i] \cdot
317 * \boldsymbol{\hat{u}}^{e}[i]$\\
318 * > > continue\\
319 * > continue
320 * \f}
321 * where \a map\f$[e][i]\f$ is the mapping array and \a
322 * sign\f$[e][i]\f$ is an array of similar dimensions ensuring the
323 * correct modal connectivity between the different elements (both
324 * these arrays are contained in the data member #m_locToGloMap). This
325 * operation is equivalent to the gather operation
326 * \f$\boldsymbol{\hat{u}}_g=\mathcal{A}^{T}\boldsymbol{\hat{u}}_l\f$,
327 * where \f$\mathcal{A}\f$ is the
328 * \f$N_{\mathrm{eof}}\times N_{\mathrm{dof}}\f$ permutation matrix.
329 *
330 * @param inarray An array of size \f$N_\mathrm{eof}\f$
331 * containing the local degrees of freedom
332 * \f$\boldsymbol{x}_l\f$.
333 * @param outarray The resulting global degrees of freedom
334 * \f$\boldsymbol{x}_g\f$ will be stored in this
335 * array of size \f$N_\mathrm{dof}\f$.
336 */
338 Array<OneD, NekDouble> &outarray) const
339{
340 m_locToGloMap->Assemble(inarray, outarray);
341}
342
344{
345 return m_locToGloMap;
346}
347
353
359
361{
363 "To use method must have a AssemblyMap "
364 "attached to key");
365
366 auto matrixIter = m_globalMat->find(gkey);
367
368 if (matrixIter == m_globalMat->end())
369 {
370 return 0;
371 }
372 else
373 {
374 return matrixIter->second->GetNumNonZeroEntries();
375 }
376
377 return 0;
378}
379
380} // namespace Nektar::MultiRegions
381
382#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
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:161
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.
GlobalLinSysSharedPtr GenGlobalLinSys(const GlobalLinSysKey &mkey)
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.
const GJPStabilisationSharedPtr GetGJPForcing()
Definition ContField.h:127
AssemblyMapCGSharedPtr m_locToGloMap
(A shared pointer to) the object which contains all the required information for the transformation f...
Definition ContField.h:150
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:355
GlobalLinSysKey v_LinearAdvectionReactionSolve(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
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:343
void v_UnsetGlobalLinSys(GlobalLinSysKey, bool) override
int GetGlobalMatrixNnz(const GlobalMatrixKey &gkey)
Definition ContField.h:360
void v_LocalToGlobal(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool useComm) override
Gathers the global coefficients from the local coefficients .
void SetGJPForcing(const GJPStabilisationSharedPtr &GJPData)
Definition ContField.h:139
void v_ImposeNeumannConditions(Array< OneD, NekDouble > &outarray) override
Add Neumann Boundary Conditions forcing to outarray.
GlobalMatrixMapShPtr m_globalMat
(A shared pointer to) a list which collects all the global matrices being assembled,...
Definition ContField.h:155
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:349
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.
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
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:305
GJPStabilisationSharedPtr m_GJPData
Data for Gradient Jump Penalisation (GJP) stabilisaiton.
Definition ContField.h:164
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:99
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
Definition ExpList.h:1129
std::shared_ptr< ExpList > GetSharedThisPtr()
Returns a shared pointer to the current object.
Definition ExpList.h:976
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::map< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap
std::shared_ptr< GJPStabilisation > GJPStabilisationSharedPtr
std::shared_ptr< ContField > ContFieldSharedPtr
Definition ContField.h:278
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition MeshGraph.h:217
std::map< ConstFactorType, NekDouble > ConstFactorMap
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray
static Array< OneD, NekDouble > NullNekDouble1DArray