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
43{
44namespace SolverUtils
45{
46/// Base class for unsteady solvers.
48{
49public:
50 /// Destructor
52
53 /// Calculate the larger time-step mantaining the problem stable.
56 {
57 return v_GetTimeStep(inarray);
58 }
59
62 {
63 v_SteadyStateResidual(step, L2);
64 }
65
66 static std::string cmdSetStartTime;
67 static std::string cmdSetStartChkNum;
68
71
74
75protected:
76 /// Wrapper to the time integration scheme.
78 /// The time integration scheme operators to use.
80
81 /// Storage for previous solution for steady-state check.
83
84 std::vector<int> m_intVariables;
85
86 /// CFL safety factor (comprise between 0 to 1).
88 /// CFL growth rate.
90 /// Maximun cfl in cfl growth.
92
93 /// Number of steps between checks for abort conditions.
95
96 /// Indicates if explicit or implicit treatment of diffusion is used.
98 /// Indicates if explicit or implicit treatment of advection is used.
100 /// Indicates if explicit or implicit treatment of reaction is used.
102
103 /// Check for steady state at step interval.
105 /// Tolerance to which steady state should be evaluated at.
107
108 /// Number of time steps between outputting filters information.
110 std::vector<std::pair<std::string, FilterSharedPtr>> m_filters;
111
112 /// Flag to determine if simulation should start in homogeneous
113 /// forward transformed state.
115
116 // Steady-state residual file
117 std::ofstream m_errFile;
118
119 /// Diffusion coefficient.
121
122 /// Initialises UnsteadySystem class members.
126
127 /// Init object for UnsteadySystem class.
129 bool DeclareField = true) override;
130
131 /// Solves an unsteady problem.
132 SOLVER_UTILS_EXPORT virtual void v_DoSolve() override;
133
134 /// Print Status Information
136 const int step, const NekDouble cpuTime);
137
138 /// Print Summary Statistics
140 const NekDouble intTime);
141
142 /// Sets up initial conditions.
144 bool dumpInitialConditions = true) override;
145
146 /// Print a summary of time stepping parameters.
147 SOLVER_UTILS_EXPORT virtual void v_GenerateSummary(SummaryList &s) override;
148
150 const Array<OneD, const Array<OneD, NekDouble>> &inarray);
151
152 SOLVER_UTILS_EXPORT virtual bool v_PreIntegrate(int step);
153
154 SOLVER_UTILS_EXPORT virtual bool v_PostIntegrate(int step);
155
157
159 int step, Array<OneD, NekDouble> &L2);
160
162
163 /// Get the maximum timestep estimator for cfl control.
165
167
168 /// \brief Evaluate the SVV diffusion coefficient
169 /// according to Moura's paper where it should
170 /// proportional to h time velocity
173 StdRegions::VarCoeffMap &varCoeffMap);
174
175 /// Perform dummy projection
177 const Array<OneD, const Array<OneD, NekDouble>> &inarray,
178 Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble time);
179
180private:
181 /// Print the solution at each solution point in a txt file
183
185
186 bool CheckSteadyState(int step, const NekDouble &totCPUTime = 0.0);
187};
188
189} // namespace SolverUtils
190} // namespace Nektar
191
192#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.
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 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.
virtual SOLVER_UTILS_EXPORT ~UnsteadySystem()
Destructor.
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.
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.
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)
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)
virtual 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.
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:176
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Definition: StdRegions.hpp:352
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble