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
42namespace Nektar::SolverUtils
43{
44/// Base class for unsteady solvers.
46{
47public:
48 /// Destructor
50
51 /// Calculate the larger time-step mantaining the problem stable.
54 {
55 return v_GetTimeStep(inarray);
56 }
57
59 {
61 }
62
64 {
66 }
67
70 {
71 v_SteadyStateResidual(step, L2);
72 }
73
76
79
80 static std::string cmdSetStartTime;
81 static std::string cmdSetStartChkNum;
82
83protected:
84 /// Wrapper to the time integration scheme.
86
87 /// The time integration scheme operators to use.
89
90 /// Storage for previous solution for steady-state check.
92
93 std::vector<int> m_intVariables;
94
95 /// CFL safety factor (comprise between 0 to 1).
97 /// CFL growth rate.
99 /// Maximun cfl in cfl growth.
101
102 /// Number of steps between checks for abort conditions.
104
105 /// Indicates if explicit or implicit treatment of diffusion is used.
107 /// Indicates if explicit or implicit treatment of advection is used.
109 /// Indicates if explicit or implicit treatment of reaction is used.
111
112 /// Check for steady state at step interval.
114 /// Tolerance to which steady state should be evaluated at.
116
117 /// Number of time steps between outputting filters information.
119 std::vector<std::pair<std::string, FilterSharedPtr>> m_filters;
120
121 /// Flag to determine if simulation should start in homogeneous
122 /// forward transformed state.
124
125 // Steady-state residual file
126 std::ofstream m_errFile;
127
128 /// Diffusion coefficient.
130
131 /// Initialises UnsteadySystem class members.
135
136 /// Init object for UnsteadySystem class.
137 SOLVER_UTILS_EXPORT void v_InitObject(bool DeclareField = true) override;
138
139 /// Solves an unsteady problem.
140 SOLVER_UTILS_EXPORT void v_DoSolve() override;
141
142 /// Print Status Information
144 const int step, const NekDouble cpuTime);
145
146 /// Print Summary Statistics
148 const NekDouble intTime);
149
150 /// Sets up initial conditions.
152 bool dumpInitialConditions = true) override;
153
154 /// Print a summary of time stepping parameters.
156
158 const Array<OneD, const Array<OneD, NekDouble>> &inarray);
159
160 SOLVER_UTILS_EXPORT virtual bool v_PreIntegrate(int step);
161
162 SOLVER_UTILS_EXPORT virtual bool v_PostIntegrate(int step);
163
165
167 int step, Array<OneD, NekDouble> &L2);
168
170
171 /// Get the maximum timestep estimator for cfl control.
173
175
176 /// \brief Evaluate the SVV diffusion coefficient
177 /// according to Moura's paper where it should
178 /// proportional to h time velocity
181 StdRegions::VarCoeffMap &varCoeffMap);
182
183 /// Perform dummy projection
185 const Array<OneD, const Array<OneD, NekDouble>> &inarray,
186 Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble time);
187
188private:
189 /// Print the solution at each solution point in a txt file
191
193
194 bool CheckSteadyState(int step, const NekDouble &totCPUTime = 0.0);
195};
196
197} // namespace Nektar::SolverUtils
198
199#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()
SOLVER_UTILS_EXPORT void SetTimeStep(const NekDouble timestep)
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.
SOLVER_UTILS_EXPORT void v_DoInitialise(bool dumpInitialConditions=true) override
Sets up initial conditions.
virtual SOLVER_UTILS_EXPORT bool v_UpdateTimeStepCheck()
std::vector< std::pair< std::string, FilterSharedPtr > > m_filters
NekDouble m_cflSafetyFactor
CFL safety factor (comprise between 0 to 1).
NekDouble m_epsilon
Diffusion coefficient.
LibUtilities::TimeIntegrationSchemeSharedPtr m_intScheme
Wrapper to the time integration scheme.
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.
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.
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 bool v_PostIntegrate(int step)
NekDouble m_CFLEnd
Maximun cfl in cfl growth.
SOLVER_UTILS_EXPORT ~UnsteadySystem() override
Destructor.
virtual SOLVER_UTILS_EXPORT void v_PrintSummaryStatistics(const NekDouble intTime)
Print Summary Statistics.
virtual SOLVER_UTILS_EXPORT void v_PrintStatusInformation(const int step, const NekDouble cpuTime)
Print Status Information.
bool CheckSteadyState(int step, const NekDouble &totCPUTime=0.0)
Calculate whether the system has reached a steady state by observing residuals to a user-defined tole...
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.
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)
SOLVER_UTILS_EXPORT void AppendOutput1D(void)
Print the solution at each solution point in a txt file.
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.
virtual SOLVER_UTILS_EXPORT bool v_RequireFwdTrans()
SOLVER_UTILS_EXPORT void SteadyStateResidual(int step, Array< OneD, NekDouble > &L2)
SOLVER_UTILS_EXPORT void v_InitObject(bool DeclareField=true) override
Init object for UnsteadySystem class.
SOLVER_UTILS_EXPORT LibUtilities::TimeIntegrationSchemeOperators & GetTimeIntegrationSchemeOperators()
Returns the time integration scheme operators.
SOLVER_UTILS_EXPORT NekDouble GetTimeStep(const Array< OneD, const Array< OneD, NekDouble > > &inarray)
Calculate the larger time-step mantaining the problem stable.
int m_steadyStateSteps
Check for steady state at step interval.
SOLVER_UTILS_EXPORT LibUtilities::TimeIntegrationSchemeSharedPtr & GetTimeIntegrationScheme()
Returns the time integration scheme.
int m_filtersInfosteps
Number of time steps between outputting filters information.
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...
bool m_homoInitialFwd
Flag to determine if simulation should start in homogeneous forward transformed state.
SOLVER_UTILS_EXPORT NekDouble GetTimeStep()
SOLVER_UTILS_EXPORT void SetTimeStep(const NekDouble timestep)
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:46
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Definition: StdRegions.hpp:346
double NekDouble