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 
59  int step,
61  {
62  v_SteadyStateResidual(step,L2);
63  }
64 
65  /// CFL safety factor (comprise between 0 to 1).
68  /// CFL growth rate
70  /// maximun cfl in cfl growth
72 
73 protected:
74  /// Number of time steps between outputting status information.
76  /// Number of steps between checks for abort conditions.
78  /// Number of time steps between outputting filters information.
81  /// Wrapper to the time integration scheme
83  /// The time integration scheme operators to use.
85  ///
87  /// Indicates if explicit or implicit treatment of diffusion is used.
89  /// Indicates if explicit or implicit treatment of advection is used.
91  /// Indicates if explicit or implicit treatment of reaction is used.
93  /// Flag to determine if simulation should start in homogeneous
94  /// forward transformed state.
96 
97  /// Tolerance to which steady state should be evaluated at
99  /// Check for steady state at step interval
103 
104  /// Storage for previous solution for steady-state check
106  // Steady-state residual file
107  std::ofstream m_errFile;
108 
109  std::vector<int> m_intVariables;
110 
111  std::vector<std::pair<std::string, FilterSharedPtr>> m_filters;
112 
113  /// Number of time steps between outputting status information.
115 
116  /// coefff of spacial derivatives(rhs or m_F in GLM) in calculating the 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 
140  int m_TotLinIts =0;
142 
143  /// flag to update artificial viscosity
144  bool m_CalcPhysicalAV = true;
145 
146 
147  /// Initialises UnsteadySystem class members.
149  const LibUtilities::SessionReaderSharedPtr &pSession,
150  const SpatialDomains::MeshGraphSharedPtr &pGraph);
151 
152  /// Init object for UnsteadySystem class.
153  SOLVER_UTILS_EXPORT virtual void v_InitObject();
154 
155  /// Get the maximum timestep estimator for cfl control.
157 
158  /// Solves an unsteady problem.
159  SOLVER_UTILS_EXPORT virtual void v_DoSolve();
160 
161  /// Sets up initial conditions.
162  SOLVER_UTILS_EXPORT virtual void v_DoInitialise();
163 
164  /// Print a summary of time stepping parameters.
166 
167  /// Print the solution at each solution point in a txt file
169  Array<OneD, Array<OneD, NekDouble>> &solution1D);
170 
172  const Array<OneD, const Array<OneD, NekDouble>> &inarray);
173 
174  SOLVER_UTILS_EXPORT virtual bool v_PreIntegrate(int step);
175  SOLVER_UTILS_EXPORT virtual bool v_PostIntegrate(int step);
176 
178  {
179  return true;
180  }
181 
183  int step,
185 
186 
187  SOLVER_UTILS_EXPORT void CheckForRestartTime(NekDouble &time, int &nchk);
188 
189  /// \brief Evaluate the SVV diffusion coefficient
190  /// according to Moura's paper where it should
191  /// proportional to h time velocity
193  const Array<OneD, Array<OneD, NekDouble>> vel,
194  StdRegions::VarCoeffMap &varCoeffMap);
195 
197 
198 private:
199  void InitializeSteadyState();
200 
201  bool CheckSteadyState(int step);
202  bool CheckSteadyState(int step, NekDouble totCPUTime);
203 };
204 
206  {
207  return true;
208  }
209 
210 } // namespace SolverUtils
211 } // namespace Nektar
212 
213 #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.
virtual SOLVER_UTILS_EXPORT void v_DoInitialise()
Sets up initial conditions.
Array< OneD, Array< OneD, NekDouble > > m_previousSolution
Storage for previous solution for steady-state check.
virtual SOLVER_UTILS_EXPORT void v_DoSolve()
Solves an unsteady problem.
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()
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)
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.
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()
Init object for UnsteadySystem class.
int m_steadyStateSteps
Check for steady state at step interval.
virtual SOLVER_UTILS_EXPORT bool UpdateTimeStepCheck()
int m_filtersInfosteps
Number of time steps between outputting filters information.
virtual SOLVER_UTILS_EXPORT void v_AppendOutput1D(Array< OneD, Array< OneD, NekDouble >> &solution1D)
Print the solution at each solution point in a txt file.
int m_infosteps
Number of time steps between outputting status information.
bool m_homoInitialFwd
Flag to determine if simulation should start in homogeneous forward transformed state.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< TimeIntegrationScheme > TimeIntegrationSchemeSharedPtr
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:46
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:272
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble