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 
41 
42 namespace Nektar
43 {
44 namespace SolverUtils
45 {
46 /// Base class for unsteady solvers.
48 {
49 public:
50  /// Destructor
52 
53  /// Calculate the larger time-step mantaining the problem stable.
55  GetTimeStep(const Array<OneD, const Array<OneD, NekDouble>> &inarray);
56 
57  /// CFL safety factor (comprise between 0 to 1).
59 
60 protected:
61  /// Number of time steps between outputting status information.
63  /// Number of steps between checks for abort conditions.
65  /// Number of time steps between outputting filters information.
68  /// Wrapper to the time integration scheme
70  /// The time integration scheme operators to use.
72  ///
74  ///
76  /// Indicates if explicit or implicit treatment of diffusion is used.
78  /// Indicates if explicit or implicit treatment of advection is used.
80  /// Indicates if explicit or implicit treatment of reaction is used.
82  /// Flag to determine if simulation should start in homogeneous
83  /// forward transformed state.
85 
86  /// Tolerance to which steady state should be evaluated at
88  /// Check for steady state at step interval
90  /// Storage for previous solution for steady-state check
92  // Steady-state residual file
93  std::ofstream m_errFile;
94 
95  std::vector<int> m_intVariables;
96 
97  std::vector<std::pair<std::string, FilterSharedPtr>> m_filters;
98 
99  /// Number of time steps between outputting status information.
101 
102  /// Initialises UnsteadySystem class members.
104  const LibUtilities::SessionReaderSharedPtr &pSession,
105  const SpatialDomains::MeshGraphSharedPtr &pGraph);
106 
107  /// Init object for UnsteadySystem class.
108  SOLVER_UTILS_EXPORT virtual void v_InitObject();
109 
110  /// Get the maximum timestep estimator for cfl control.
112 
113  /// Solves an unsteady problem.
114  SOLVER_UTILS_EXPORT virtual void v_DoSolve();
115 
116  /// Sets up initial conditions.
117  SOLVER_UTILS_EXPORT virtual void v_DoInitialise();
118 
119  /// Print a summary of time stepping parameters.
121 
122  /// Print the solution at each solution point in a txt file
124  Array<OneD, Array<OneD, NekDouble>> &solution1D);
125 
127  const Array<OneD, const Array<OneD, NekDouble>> &inarray);
128 
129  SOLVER_UTILS_EXPORT virtual bool v_PreIntegrate(int step);
130  SOLVER_UTILS_EXPORT virtual bool v_PostIntegrate(int step);
131 
133  {
134  return true;
135  }
136 
137  SOLVER_UTILS_EXPORT void CheckForRestartTime(NekDouble &time, int &nchk);
138 
139  /// \brief Evaluate the SVV diffusion coefficient
140  /// according to Moura's paper where it should
141  /// proportional to h time velocity
143  const Array<OneD, Array<OneD, NekDouble>> vel,
144  StdRegions::VarCoeffMap &varCoeffMap);
145 
146 private:
147  void InitializeSteadyState();
148 
149  bool CheckSteadyState(int step);
150 };
151 
152 } // namespace SolverUtils
153 } // namespace Nektar
154 
155 #endif
virtual SOLVER_UTILS_EXPORT void v_DoSolve()
Solves an unsteady problem.
NekDouble m_filterTimeWarning
Number of time steps between outputting status information.
bool m_explicitReaction
Indicates if explicit or implicit treatment of reaction is used.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:163
virtual SOLVER_UTILS_EXPORT bool v_PreIntegrate(int step)
Array< OneD, Array< OneD, NekDouble > > m_previousSolution
Storage for previous solution for steady-state check.
A base class for describing how to solve specific equations.
bool m_homoInitialFwd
Flag to determine if simulation should start in homogeneous forward transformed state.
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
int m_abortSteps
Number of steps between checks for abort conditions.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:46
std::vector< std::pair< std::string, FilterSharedPtr > > m_filters
virtual SOLVER_UTILS_EXPORT void v_AppendOutput1D(Array< OneD, Array< OneD, NekDouble >> &solution1D)
Print the solution at each solution point in a txt file.
virtual SOLVER_UTILS_EXPORT bool v_RequireFwdTrans()
SOLVER_UTILS_EXPORT void CheckForRestartTime(NekDouble &time, int &nchk)
SOLVER_UTILS_EXPORT NekDouble MaxTimeStepEstimator()
Get the maximum timestep estimator for cfl control.
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.
NekDouble m_steadyStateTol
Tolerance to which steady state should be evaluated at.
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s)
Print a summary of time stepping parameters.
std::shared_ptr< TimeIntegrationWrapper > TimeIntegrationWrapperSharedPtr
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
virtual SOLVER_UTILS_EXPORT ~UnsteadySystem()
Destructor.
virtual SOLVER_UTILS_EXPORT bool v_PostIntegrate(int step)
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:264
Base class for unsteady solvers.
double NekDouble
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Init object for UnsteadySystem class.
SOLVER_UTILS_EXPORT NekDouble GetTimeStep()
NekDouble m_cflSafetyFactor
CFL safety factor (comprise between 0 to 1).
int m_filtersInfosteps
Number of time steps between outputting filters information.
int m_steadyStateSteps
Check for steady state at step interval.
#define SOLVER_UTILS_EXPORT
SOLVER_UTILS_EXPORT UnsteadySystem(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Initialises UnsteadySystem class members.
LibUtilities::TimeIntegrationWrapperSharedPtr m_intScheme
Wrapper to the time integration scheme.
bool CheckSteadyState(int step)
Calculate whether the system has reached a steady state by observing residuals to a user-defined tole...
int m_infosteps
Number of time steps between outputting status information.
SOLVER_UTILS_EXPORT void SVVVarDiffCoeff(const Array< OneD, Array< OneD, NekDouble >> vel, StdRegions::VarCoeffMap &varCoeffMap)
Evaluate the SVV diffusion coefficient according to Moura&#39;s paper where it should proportional to h t...
std::shared_ptr< TimeIntegrationSolution > TimeIntegrationSolutionSharedPtr
LibUtilities::TimeIntegrationSolutionSharedPtr m_intSoln
std::shared_ptr< SessionReader > SessionReaderSharedPtr
virtual SOLVER_UTILS_EXPORT void v_DoInitialise()
Sets up initial conditions.