Nektar++
CoupledLinearNS.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File CoupledLinearNS.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: Coupled Stokes solver scheme header
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_SOLVERS_COUPLEDSTOKESSCHEME_H
36 #define NEKTAR_SOLVERS_COUPLEDSTOKESSCHEME_H
37 
43 //#include <MultiRegions/GlobalLinSysDirectStaticCond.h>
44 
45 namespace Nektar
46 {
47 
48 typedef struct coupledSolverMatrices
49 {
50  /** \brief Boundary-interior Laplacian plus linearised convective
51  * terms pre-multiplying Cinv:
52  * \f$ m\_BCinv[n,m] = (\nabla \phi^b_n, \nu \nabla
53  * \phi^i_j) + (\phi^b_n,{\bf U \cdot \nabla} \phi^i_j) +
54  * (\phi^b_n \nabla^T {\bf U} \phi^i_j) m_Cinv[j,m]\f$
55  */
57 
58  /** \brief Interior-boundary Laplacian plus linearised convective terms
59  * \f$ m\_Btilde^T[n,m] = (\nabla \phi^i_n, \nu \nabla \phi^b_m) +
60  * (\phi^i_n,{\bf U \cdot \nabla} \phi^b_m) + (\phi^i_n \nabla^T
61  * {\bf U} \phi^b_m) \f$ */
63 
64  /** \brief Interior-Interior Laplaican plus linearised convective
65  * terms inverted, i.e. the inverse of
66  * \f$ m\_C[n,m] = (\nabla \phi^i_n, \nu \nabla
67  * \phi^i_m) + (\phi^i_n,{\bf U \cdot \nabla} \phi^i_m) +
68  * (\phi^i_n \nabla^T {\bf U} \phi^i_m),\f$ */
70 
71  /** \brief Inner product of pressure system with divergence of the
72  * boundary velocity space
73  * \f$ m\_D\_{bnd}[n,m] = (\psi_n,\nabla \phi^b_m),\f$
74  */
76 
77  /** \brief Inner product of pressure system with divergence of the
78  * interior velocity space
79  * \f$ m\_D\_{int}[n,m] = (\psi_j,\nabla \phi^i_m) \f$
80  */
82 
85 
87 {
88 public:
89  friend class MemoryManager<CoupledLinearNS>;
90 
91  /// Creates an instance of this class
95  {
98  p->InitObject();
99  return p;
100  }
101  /// Name of class
102  static std::string className;
103 
104  /**
105  * Generate the linearised Navier Stokes solver based on the
106  * static condensation of the interior velocity space and
107  * pressure modes.
108  */
109  void SetUpCoupledMatrix(const NekDouble lambda = 0.0,
111  &Advfield = NullNekDoubleArrayOfArray,
112  bool IsLinearNSEquation = true);
113 
115  const SpatialDomains::ExpansionInfoMap &VelExp);
116 
117  void Solve(void);
118 
119  /**
120  * Solve the coupled linear Navier-Stokes solve using matrix
121  * systems set up at construction. The solution is stored
122  * in #m_velocity and #m_pressure.
123  */
124  void SolveLinearNS(const Array<OneD, Array<OneD, NekDouble>> &forcing);
125 
129  const int HomogeneousMode = 0);
130 
132  const Array<OneD, const Array<OneD, NekDouble>> &inarray,
133  Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble time,
134  const NekDouble a_iixDt);
135 
136  void EvaluateAdvection(
137  const Array<OneD, const Array<OneD, NekDouble>> &inarray,
138  Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble time);
139 
140  void SolveSteadyNavierStokes(void);
141 
142  void Continuation(void);
143 
144  /*void EvaluateNewtonRHS(Array<OneD, Array<OneD, NekDouble> > &Velocity,
145  * Array<OneD,
146  *Array<OneD, NekDouble> > &PreviousForcing, Array<OneD, Array<OneD,
147  *NekDouble> > &outarray);*/
148 
150  Array<OneD, Array<OneD, NekDouble>> &outarray);
151 
152  void InfNorm(Array<OneD, Array<OneD, NekDouble>> &inarray,
153  Array<OneD, NekDouble> &outarray);
154 
155  void L2Norm(Array<OneD, Array<OneD, NekDouble>> &inarray,
156  Array<OneD, NekDouble> &outarray);
157 
158  void DefineForcingTerm(void);
161 
163 
164 protected:
166  const SpatialDomains::MeshGraphSharedPtr &pGraph);
167 
168  virtual void v_InitObject(bool DeclareField = true);
169 
170 private:
171  /// Id to identify when single mode is mean mode (i.e. beta=0);
173 
176  NekDouble m_tol; // Tolerence
177  int m_maxIt; // Max number of iteration
178  int m_Restart; // 0=Stokes solution as init guess; 1=Restart.cont as init
179  // guess
184 
186 
187  /**
188  * Generate the linearised Navier Stokes solver based on the
189  * static condensation of the interior velocity space and
190  * pressure modes. This call also allows for a Fourier mode
191  * to be specified, however if HomogeneneousMode= 0 then can
192  * be used for a standared 2D and hopefully 3D (in the
193  * future).
194  */
195  void SetUpCoupledMatrix(
196  const NekDouble lambda,
197  const Array<OneD, Array<OneD, NekDouble>> &Advfield,
198  bool IsLinearNSEquation, const int HomogeneousMode,
201  const NekDouble lambda_imag = NekConstants::kNekUnsetDouble);
202 
204 
205  virtual void v_DoInitialise(void);
206 
207  virtual void v_DoSolve(void);
208 
209  virtual bool v_NegatedOp(void);
210 
211  virtual void v_TransCoeffToPhys(void);
212 
213  virtual void v_TransPhysToCoeff(void);
214 
215  virtual void v_Output(void);
216 
217  virtual int v_GetForceDimension(void);
218 };
219 
220 } // namespace Nektar
221 
222 #endif // COUPLEDSTOKESSCHEME_H
CoupledLinearNS(const LibUtilities::SessionReaderSharedPtr &pSesssion, const SpatialDomains::MeshGraphSharedPtr &pGraph)
virtual void v_TransPhysToCoeff(void)
Virtual function for transformation to coefficient space.
Array< OneD, CoupledLocalToGlobalC0ContMapSharedPtr > m_locToGloMap
virtual void v_Output(void)
void EvaluateNewtonRHS(Array< OneD, Array< OneD, NekDouble >> &Velocity, Array< OneD, Array< OneD, NekDouble >> &outarray)
void SetUpCoupledMatrix(const NekDouble lambda=0.0, const Array< OneD, Array< OneD, NekDouble >> &Advfield=NullNekDoubleArrayOfArray, bool IsLinearNSEquation=true)
const SpatialDomains::ExpansionInfoMap & GenPressureExp(const SpatialDomains::ExpansionInfoMap &VelExp)
virtual void v_DoSolve(void)
Solves an unsteady problem.
void EvaluateAdvection(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
void InfNorm(Array< OneD, Array< OneD, NekDouble >> &inarray, Array< OneD, NekDouble > &outarray)
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
virtual bool v_NegatedOp(void)
static std::string className
Name of class.
void SolveUnsteadyStokesSystem(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time, const NekDouble a_iixDt)
void SolveLinearNS(const Array< OneD, Array< OneD, NekDouble >> &forcing)
virtual int v_GetForceDimension(void)
bool m_zeroMode
Id to identify when single mode is mean mode (i.e. beta=0);.
Array< OneD, Array< OneD, NekDouble > > m_ForcingTerm_Coeffs
void L2Norm(Array< OneD, Array< OneD, NekDouble >> &inarray, Array< OneD, NekDouble > &outarray)
Array< OneD, Array< OneD, NekDouble > > m_ForcingTerm
virtual void v_InitObject(bool DeclareField=true)
Init object for UnsteadySystem class.
virtual void v_DoInitialise(void)
Sets up initial conditions.
Array< OneD, CoupledSolverMatrices > m_mat
virtual void v_TransCoeffToPhys(void)
Virtual function for transformation to physical space.
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print a summary of time stepping parameters.
This class is the base class for Navier Stokes problems.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:50
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
static const NekDouble kNekUnsetDouble
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:48
std::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:172
std::map< int, ExpansionInfoShPtr > ExpansionInfoMap
Definition: MeshGraph.h:143
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
struct Nektar::coupledSolverMatrices CoupledSolverMatrices
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:79
std::shared_ptr< CoupledLocalToGlobalC0ContMap > CoupledLocalToGlobalC0ContMapSharedPtr
double NekDouble
DNekScalBlkMatSharedPtr m_D_int
Inner product of pressure system with divergence of the interior velocity space .
DNekScalBlkMatSharedPtr m_D_bnd
Inner product of pressure system with divergence of the boundary velocity space .
DNekScalBlkMatSharedPtr m_Cinv
Interior-Interior Laplaican plus linearised convective terms inverted, i.e. the inverse of .
DNekScalBlkMatSharedPtr m_Btilde
Interior-boundary Laplacian plus linearised convective terms .
DNekScalBlkMatSharedPtr m_BCinv
Boundary-interior Laplacian plus linearised convective terms pre-multiplying Cinv: .
MultiRegions::GlobalLinSysSharedPtr m_CoupledBndSys