Nektar++
UnsteadySystem.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: UnsteadySystem.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: Generic timestepping for Unsteady solvers
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_SOLVERUTILS_UNSTEADYSYSTEM_H
36 #define NEKTAR_SOLVERUTILS_UNSTEADYSYSTEM_H
37 
42 
43 namespace Nektar
44 {
45 namespace SolverUtils
46 {
47 /// Base class for unsteady solvers.
49 {
50 public:
51  /// Destructor
53 
54  /// Calculate the larger time-step mantaining the problem stable.
56  GetTimeStep(const Array<OneD, const Array<OneD, NekDouble>> &inarray);
57 
60  {
61  v_SteadyStateResidual(step, L2);
62  }
63 
64  /// CFL safety factor (comprise between 0 to 1).
67  /// CFL growth rate
69  /// maximun cfl in cfl growth
71  static std::string cmdSetStartTime;
72  static std::string cmdSetStartChkNum;
73 
74 protected:
75  /// Number of steps between checks for abort conditions.
77  /// Number of time steps between outputting filters information.
80  /// Wrapper to the time integration scheme
82  /// The time integration scheme operators to use.
84  ///
86  /// Indicates if explicit or implicit treatment of diffusion is used.
88  /// Indicates if explicit or implicit treatment of advection is used.
90  /// Indicates if explicit or implicit treatment of reaction is used.
92  /// Flag to determine if simulation should start in homogeneous
93  /// forward transformed state.
95 
96  /// Tolerance to which steady state should be evaluated at
98  /// Check for steady state at step interval
102 
103  /// Storage for previous solution for steady-state check
105  // Steady-state residual file
106  std::ofstream m_errFile;
107 
108  std::vector<int> m_intVariables;
109 
110  std::vector<std::pair<std::string, FilterSharedPtr>> m_filters;
111 
112  /// Number of time steps between outputting status information.
114 
115  /// coefff of spacial derivatives(rhs or m_F in GLM) in calculating the
116  /// residual of the whole equation(used in unsteady time integrations)
118 
120  bool m_flagImplicitSolver = false;
121 
122  /// estimate the magnitude of each conserved varibles
124 
125  /// local time step(notice only for jfnk other see m_cflSafetyFactor)
127 
129 
132 
133  // flag to control the update of preconditioning matrix
134  // Currently used to avoid PreconMat from updating in one time step
136 
138 
139  int m_TotNewtonIts = 0;
140  int m_TotLinIts = 0;
141  int m_TotImpStages = 0;
142 
143  /// flag to update artificial viscosity
144  bool m_CalcPhysicalAV = true;
145 
146  /// Initialises UnsteadySystem class members.
148  const LibUtilities::SessionReaderSharedPtr &pSession,
149  const SpatialDomains::MeshGraphSharedPtr &pGraph);
150 
151  /// Init object for UnsteadySystem class.
152  SOLVER_UTILS_EXPORT virtual void v_InitObject(
153  bool DeclareField = true) override;
154 
155  /// Get the maximum timestep estimator for cfl control.
157 
158  /// Solves an unsteady problem.
159  SOLVER_UTILS_EXPORT virtual void v_DoSolve() override;
160 
161  /// Sets up initial conditions.
162  SOLVER_UTILS_EXPORT virtual void v_DoInitialise() override;
163 
164  /// Print a summary of time stepping parameters.
165  SOLVER_UTILS_EXPORT virtual void v_GenerateSummary(SummaryList &s) override;
166 
168  const Array<OneD, const Array<OneD, NekDouble>> &inarray);
169 
170  SOLVER_UTILS_EXPORT virtual bool v_PreIntegrate(int step);
171  SOLVER_UTILS_EXPORT virtual bool v_PostIntegrate(int step);
172 
174  {
175  return true;
176  }
177 
179  int step, Array<OneD, NekDouble> &L2);
180 
181  SOLVER_UTILS_EXPORT void CheckForRestartTime(NekDouble &time, int &nchk);
182 
183  /// \brief Evaluate the SVV diffusion coefficient
184  /// according to Moura's paper where it should
185  /// proportional to h time velocity
187  const Array<OneD, Array<OneD, NekDouble>> vel,
188  StdRegions::VarCoeffMap &varCoeffMap);
189 
191 
192  /// Perform dummy projection
194  const Array<OneD, const Array<OneD, NekDouble>> &inarray,
195  Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble time);
196 
197 private:
198  void InitializeSteadyState();
199 
200  /// Print the solution at each solution point in a txt file
202  Array<OneD, Array<OneD, NekDouble>> &solution1D);
203 
204  bool CheckSteadyState(int step);
205  bool CheckSteadyState(int step, NekDouble totCPUTime);
206 };
207 
209 {
210  return true;
211 }
212 
213 } // namespace SolverUtils
214 } // namespace Nektar
215 
216 #endif
#define SOLVER_UTILS_EXPORT
Binds a set of functions for use by time integration schemes.
A base class for describing how to solve specific equations.
SOLVER_UTILS_EXPORT NekDouble GetTimeStep()
Base class for unsteady solvers.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
NekDouble m_CFLGrowth
CFL growth rate.
bool m_explicitReaction
Indicates if explicit or implicit treatment of reaction is used.
Array< OneD, Array< OneD, NekDouble > > m_previousSolution
Storage for previous solution for steady-state check.
virtual SOLVER_UTILS_EXPORT bool v_UpdateTimeStepCheck()
bool m_CalcPhysicalAV
flag to update artificial viscosity
std::vector< std::pair< std::string, FilterSharedPtr > > m_filters
NekDouble m_cflSafetyFactor
CFL safety factor (comprise between 0 to 1).
LibUtilities::TimeIntegrationSchemeSharedPtr m_intScheme
Wrapper to the time integration scheme.
virtual SOLVER_UTILS_EXPORT ~UnsteadySystem()
Destructor.
NekDouble m_filterTimeWarning
Number of time steps between outputting status information.
NekDouble m_TimeIntegLambda
coefff of spacial derivatives(rhs or m_F in GLM) in calculating the residual of the whole equation(us...
NekDouble m_steadyStateTol
Tolerance to which steady state should be evaluated at.
int m_abortSteps
Number of steps between checks for abort conditions.
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
Array< OneD, NekDouble > m_locTimeStep
local time step(notice only for jfnk other see m_cflSafetyFactor)
SOLVER_UTILS_EXPORT NekDouble MaxTimeStepEstimator()
Get the maximum timestep estimator for cfl control.
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
virtual SOLVER_UTILS_EXPORT NekDouble v_GetTimeStep(const Array< OneD, const Array< OneD, NekDouble >> &inarray)
Return the timestep to be used for the next step in the time-marching loop.
virtual SOLVER_UTILS_EXPORT bool v_RequireFwdTrans()
virtual SOLVER_UTILS_EXPORT void v_DoInitialise() override
Sets up initial conditions.
bool CheckSteadyState(int step)
Calculate whether the system has reached a steady state by observing residuals to a user-defined tole...
virtual SOLVER_UTILS_EXPORT bool v_PostIntegrate(int step)
NekDouble m_CFLEnd
maximun cfl in cfl growth
SOLVER_UTILS_EXPORT void SVVVarDiffCoeff(const Array< OneD, Array< OneD, NekDouble >> vel, StdRegions::VarCoeffMap &varCoeffMap)
Evaluate the SVV diffusion coefficient according to Moura's paper where it should proportional to h t...
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s) override
Print a summary of time stepping parameters.
virtual SOLVER_UTILS_EXPORT void v_SteadyStateResidual(int step, Array< OneD, NekDouble > &L2)
virtual SOLVER_UTILS_EXPORT bool v_PreIntegrate(int step)
SOLVER_UTILS_EXPORT void CheckForRestartTime(NekDouble &time, int &nchk)
SOLVER_UTILS_EXPORT UnsteadySystem(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Initialises UnsteadySystem class members.
SOLVER_UTILS_EXPORT void AppendOutput1D(Array< OneD, Array< OneD, NekDouble >> &solution1D)
Print the solution at each solution point in a txt file.
Array< OneD, NekDouble > m_magnitdEstimat
estimate the magnitude of each conserved varibles
SOLVER_UTILS_EXPORT void SteadyStateResidual(int step, Array< OneD, NekDouble > &L2)
virtual SOLVER_UTILS_EXPORT void v_InitObject(bool DeclareField=true) override
Init object for UnsteadySystem class.
int m_steadyStateSteps
Check for steady state at step interval.
int m_filtersInfosteps
Number of time steps between outputting filters information.
SOLVER_UTILS_EXPORT void DoDummyProjection(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
Perform dummy projection.
bool m_homoInitialFwd
Flag to determine if simulation should start in homogeneous forward transformed state.
virtual SOLVER_UTILS_EXPORT void v_DoSolve() override
Solves an unsteady problem.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< TimeIntegrationScheme > TimeIntegrationSchemeSharedPtr
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:48
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:172
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Definition: StdRegions.hpp:343
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble