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 
42 #include <MultiRegions/ExpList2D.h>
44 //#include <MultiRegions/GlobalLinSysDirectStaticCond.h>
45 
46 namespace Nektar
47 {
48 
49  typedef struct coupledSolverMatrices
50  {
51  /** \brief Boundary-interior Laplacian plus linearised convective
52  * terms pre-multiplying Cinv:
53  * \f$ m\_BCinv[n,m] = (\nabla \phi^b_n, \nu \nabla
54  * \phi^i_j) + (\phi^b_n,{\bf U \cdot \nabla} \phi^i_j) +
55  * (\phi^b_n \nabla^T {\bf U} \phi^i_j) m_Cinv[j,m]\f$
56  */
58 
59  /** \brief Interior-boundary Laplacian plus linearised convective terms
60  * \f$ m\_Btilde^T[n,m] = (\nabla \phi^i_n, \nu \nabla \phi^b_m) +
61  * (\phi^i_n,{\bf U \cdot \nabla} \phi^b_m) + (\phi^i_n \nabla^T
62  * {\bf U} \phi^b_m) \f$ */
64 
65  /** \brief Interior-Interior Laplaican plus linearised convective
66  * terms inverted, i.e. the inverse of
67  * \f$ m\_C[n,m] = (\nabla \phi^i_n, \nu \nabla
68  * \phi^i_m) + (\phi^i_n,{\bf U \cdot \nabla} \phi^i_m) +
69  * (\phi^i_n \nabla^T {\bf U} \phi^i_m),\f$ */
71 
72  /** \brief Inner product of pressure system with divergence of the
73  * boundary velocity space
74  * \f$ m\_D\_{bnd}[n,m] = (\psi_n,\nabla \phi^b_m),\f$
75  */
77 
78  /** \brief Inner product of pressure system with divergence of the
79  * interior velocity space
80  * \f$ m\_D\_{int}[n,m] = (\psi_j,\nabla \phi^i_m) \f$
81  */
83 
86 
88  {
89  public:
91 
92  /// Creates an instance of this class
96  {
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  bool IsLinearNSEquation = true);
112 
113 
114  const SpatialDomains::ExpansionMap &GenPressureExp(const SpatialDomains::ExpansionMap &VelExp);
115 
116  void Solve(void);
117 
118  /**
119  * Solve the coupled linear Navier-Stokes solve using matrix
120  * systems set up at construction. The solution is stored
121  * in #m_velocity and #m_pressure.
122  */
123  void SolveLinearNS(const Array<OneD, Array<OneD, NekDouble> > &forcing);
124 
125  void SolveLinearNS(const Array<OneD, Array<OneD, NekDouble> > &forcing,
128  const int HomogeneousMode = 0);
129 
130  void SolveUnsteadyStokesSystem(const Array<OneD, const Array<OneD, NekDouble> > &inarray,
131  Array<OneD, Array<OneD, NekDouble> > &outarray,
132  const NekDouble time,
133  const NekDouble a_iixDt);
134 
135  void EvaluateAdvection(const Array<OneD, const Array<OneD, NekDouble> > &inarray,
136  Array<OneD, Array<OneD, NekDouble> > &outarray,
137  const NekDouble time);
138 
139  void SolveSteadyNavierStokes(void);
140 
141  void Continuation(void);
142 
143  /*void EvaluateNewtonRHS(Array<OneD, Array<OneD, NekDouble> > &Velocity,
144  * Array<OneD, Array<OneD, NekDouble> > &PreviousForcing,
145  * Array<OneD, Array<OneD, NekDouble> > &outarray);*/
146 
147  void EvaluateNewtonRHS(Array<OneD, Array<OneD, NekDouble> > &Velocity,
148  Array<OneD, Array<OneD, NekDouble> > &outarray);
149 
150  void InfNorm(Array<OneD, Array<OneD, NekDouble> > &inarray,
151  Array<OneD, NekDouble> &outarray);
152 
153  void L2Norm(Array<OneD, Array<OneD, NekDouble> > &inarray,
154  Array<OneD, NekDouble> &outarray);
155 
156  void DefineForcingTerm(void);
159 
161 
162  protected:
164  const SpatialDomains::MeshGraphSharedPtr &pGraph);
165 
166  virtual void v_InitObject();
167 
168  private:
169  /// Id to identify when single mode is mean mode (i.e. beta=0);
171 
174  NekDouble m_tol; // Tolerence
175  int m_maxIt; // Max number of iteration
176  int m_Restart; // 0=Stokes solution as init guess; 1=Restart.cont as init guess
181 
182 
183 
184 
186 
187 
188  /**
189  * Generate the linearised Navier Stokes solver based on the
190  * static condensation of the interior velocity space and
191  * pressure modes. This call also allows for a Fourier mode
192  * to be specified, however if HomogeneneousMode= 0 then can
193  * be used for a standared 2D and hopefully 3D (in the
194  * future).
195  */
196  void SetUpCoupledMatrix(const NekDouble lambda,
197  const Array< OneD, Array<OneD, NekDouble> > &Advfield,
198  bool IsLinearNSEquation,
199  const int HomogeneousMode,
202  const NekDouble lambda_imag = NekConstants::kNekUnsetDouble);
203 
204  virtual void v_GenerateSummary(SolverUtils::SummaryList& s);
205 
206  virtual void v_DoInitialise(void);
207 
208  virtual void v_DoSolve(void);
209 
210  virtual bool v_NegatedOp(void);
211 
212  virtual void v_TransCoeffToPhys(void);
213 
214  virtual void v_TransPhysToCoeff(void);
215 
216  virtual void v_Output(void);
217 
218  virtual int v_GetForceDimension(void);
219  };
220 
221 
222 
223 } //end of namespace
224 
225 #endif //COUPLEDSTOKESSCHEME_H
struct Nektar::coupledSolverMatrices CoupledSolverMatrices
DNekScalBlkMatSharedPtr m_Btilde
Interior-boundary Laplacian plus linearised convective terms .
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:163
DNekScalBlkMatSharedPtr m_D_bnd
Inner product of pressure system with divergence of the boundary velocity space . ...
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:73
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:46
Array< OneD, Array< OneD, NekDouble > > m_ForcingTerm
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
Definition: GlobalLinSys.h:50
Array< OneD, CoupledSolverMatrices > m_mat
static void Solve(Nektar::Array< OneD, NekDouble > pX, struct crs_data *pCrs, Nektar::Array< OneD, NekDouble > pB)
Solve the matrix system for a given input vector b.
Definition: Xxt.hpp:188
DataType L2Norm(const NekVector< DataType > &v)
Definition: NekVector.cpp:912
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
DNekScalBlkMatSharedPtr m_D_int
Inner product of pressure system with divergence of the interior velocity space . ...
Array< OneD, Array< OneD, NekDouble > > m_ForcingTerm_Coeffs
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
double NekDouble
static const NekDouble kNekUnsetDouble
static std::string className
Name of class.
DNekScalBlkMatSharedPtr m_Cinv
Interior-Interior Laplaican plus linearised convective terms inverted, i.e. the inverse of ...
Array< OneD, CoupledLocalToGlobalC0ContMapSharedPtr > m_locToGloMap
bool m_zeroMode
Id to identify when single mode is mean mode (i.e. beta=0);.
This class is the base class for Navier Stokes problems.
std::shared_ptr< CoupledLocalToGlobalC0ContMap > CoupledLocalToGlobalC0ContMapSharedPtr
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayofArray
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::map< int, ExpansionShPtr > ExpansionMap
Definition: MeshGraph.h:152
std::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.
DNekScalBlkMatSharedPtr m_BCinv
Boundary-interior Laplacian plus linearised convective terms pre-multiplying Cinv: ...
MultiRegions::GlobalLinSysSharedPtr m_CoupledBndSys