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
43namespace Nektar::SolverUtils
44{
45/// Base class for unsteady solvers.
47{
48public:
49 /// Destructor
51
52 /// Calculate the larger time-step mantaining the problem stable.
55 {
56 return v_GetTimeStep(inarray);
57 }
58
60 {
62 }
63
65 {
67 }
68
71 {
72 v_SteadyStateResidual(step, L2);
73 }
74
77
80
81 static std::string cmdSetStartTime;
82 static std::string cmdSetStartChkNum;
83
84protected:
85 /// Wrapper to the time integration scheme.
87
88 /// The time integration scheme operators to use.
90
91 /// Storage for previous solution for steady-state check.
93
94 std::vector<int> m_intVariables;
95
96 /// CFL safety factor (comprise between 0 to 1).
98 /// CFL growth rate.
100 /// Maximun cfl in cfl growth.
102
103 /// Number of steps between checks for abort conditions.
105
106 /// Indicates if explicit or implicit treatment of diffusion is used.
108 /// Indicates if explicit or implicit treatment of advection is used.
110 /// Indicates if explicit or implicit treatment of reaction is used.
112
113 /// Check for steady state at step interval.
115 /// Tolerance to which steady state should be evaluated at.
117
118 /// Number of time steps between outputting filters information.
120 std::vector<std::pair<std::string, FilterSharedPtr>> m_filters;
121
122 /// Flag to determine if simulation should start in homogeneous
123 /// forward transformed state.
125
126 // Steady-state residual file
127 std::ofstream m_errFile;
128
129 /// Diffusion coefficient.
131
132 /// Initialises UnsteadySystem class members.
136
137 /// Init object for UnsteadySystem class.
138 SOLVER_UTILS_EXPORT void v_InitObject(bool DeclareField = true) override;
139
140 /// Solves an unsteady problem.
141 SOLVER_UTILS_EXPORT void v_DoSolve() override;
142
143 /// Print Status Information
145 const int step, const NekDouble cpuTime);
146
147 /// Print Summary Statistics
149 const NekDouble intTime);
150
151 /// Sets up initial conditions.
153 bool dumpInitialConditions = true) override;
154
155 /// Print a summary of time stepping parameters.
157
159 const Array<OneD, const Array<OneD, NekDouble>> &inarray);
160
161 SOLVER_UTILS_EXPORT virtual bool v_PreIntegrate(int step);
162
163 SOLVER_UTILS_EXPORT virtual bool v_PostIntegrate(int step);
164
166
168 int step, Array<OneD, NekDouble> &L2);
169
171
172 /// Get the maximum timestep estimator for cfl control.
174
176
177 /// \brief Evaluate the SVV diffusion coefficient
178 /// according to Moura's paper where it should
179 /// proportional to h time velocity
182 StdRegions::VarCoeffMap &varCoeffMap);
183
184 /// Perform dummy projection
186 const Array<OneD, const Array<OneD, NekDouble>> &inarray,
187 Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble time);
188
189private:
190 /// Print the solution at each solution point in a txt file
192
194
195 bool CheckSteadyState(int step, const NekDouble &totCPUTime = 0.0);
196};
197
198} // namespace Nektar::SolverUtils
199
200#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:375
double NekDouble