32 virtual int Size()
const = 0;
59 std::vector<Vector> data;
76 for (
int i = 0; i < smax; i++) { idx[i] = (++idx[i])%smax; }
94 int MaxSize()
const override {
return smax; };
96 int Size()
const override {
return ss; };
100 void Get(
int i,
Vector &vec)
const override;
190 while (t < tf) {
Step(x, t, dt); }
202 {
return (var == ImplicitVariableType::SLOPE); };
211 MFEM_ABORT(
"TimeDependentOperator is not set. Call Init() first.");
215 MFEM_ABORT(
"The ODE solver does not support the implicit variable type.");
235 static MFEM_EXPORT std::string
Types;
240 static MFEM_EXPORT std::unique_ptr<ODESolver>
Select(
const int ode_solver_type);
246 const int ode_solver_type);
252 const int ode_solver_type);
258 static MFEM_EXPORT std::unique_ptr<ODESolver>
SelectIMEX(
259 const int ode_solver_type);
371 static MFEM_EXPORT
const real_t a[28], b[8], c[7];
383 static MFEM_EXPORT
const real_t a[66], b[12], c[11];
403 return (var == ImplicitVariableType::STATE ||
404 var == ImplicitVariableType::SLOPE);
422 return (var == ImplicitVariableType::STATE ||
423 var == ImplicitVariableType::SLOPE);
449 return (var == ImplicitVariableType::STATE ||
450 var == ImplicitVariableType::SLOPE);
469 return (var == ImplicitVariableType::STATE ||
470 var == ImplicitVariableType::SLOPE);
489 return (var == ImplicitVariableType::STATE ||
490 var == ImplicitVariableType::SLOPE);
509 return (var == ImplicitVariableType::STATE ||
510 var == ImplicitVariableType::SLOPE);
529 return (var == ImplicitVariableType::STATE ||
530 var == ImplicitVariableType::SLOPE);
549 return (var == ImplicitVariableType::STATE ||
550 var == ImplicitVariableType::SLOPE);
580 return (var == ImplicitVariableType::STATE ||
581 var == ImplicitVariableType::SLOPE);
622 static MFEM_EXPORT
const real_t a[1];
632 static MFEM_EXPORT
const real_t a[2];
642 static MFEM_EXPORT
const real_t a[3];
652 static MFEM_EXPORT
const real_t a[4];
662 static MFEM_EXPORT
const real_t a[5];
701 return (var == ImplicitVariableType::STATE ||
702 var == ImplicitVariableType::SLOPE);
710 static MFEM_EXPORT
const real_t a[2];
720 static MFEM_EXPORT
const real_t a[3];
730 static MFEM_EXPORT
const real_t a[4];
740 static MFEM_EXPORT
const real_t a[5];
772 while (t < tf) {
Step(q,
p, t, dt); }
899 while (t < tf) {
Step(x, dxdt, t, dt); }
910 static MFEM_EXPORT std::string
Types;
975 rho_inf = (rho_inf > 1.0) ? 1.0 : rho_inf;
976 rho_inf = (rho_inf < 0.0) ? 0.0 : rho_inf;
978 alpha_m = (2.0 - rho_inf)/(1.0 + rho_inf);
1037 rho_inf = (rho_inf > 1.0) ? 1.0 : rho_inf;
1038 rho_inf = (rho_inf < 0.0) ? 0.0 : rho_inf;
1041 alpha_m = 2.0/(1.0 + rho_inf);
1059 {
return (var == ImplicitVariableType::SLOPE); };
1080 {
return (var == ImplicitVariableType::SLOPE); };
1100 {
return (var == ImplicitVariableType::SLOPE); };
1120 {
return (var == ImplicitVariableType::SLOPE); };
ODEStateData & GetState() override
Returns the StateData.
const ODEStateData & GetState() const override
Returns the StateData.
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void CheckTimestep(real_t dt)
AdamsBashforthSolver(int s_, const real_t *a_)
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
std::unique_ptr< ODESolver > RKsolver
const ODEStateData & GetState() const override
Returns the StateData.
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
std::unique_ptr< ODESolver > RKsolver
ODEStateData & GetState() override
Returns the StateData.
void CheckTimestep(real_t dt)
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
AdamsMoultonSolver(int s_, const real_t *a_)
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
The classical midpoint method.
AverageAccelerationSolver()
Backward Euler ODE solver. L-stable.
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
CentralDifferenceSolver()
static MemoryType GetHostMemoryType()
Get the current Host MemoryType. This is the MemoryType used by most MFEM classes when allocating mem...
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
virtual ~ExplicitRKSolver()
ExplicitRKSolver(int s_, const real_t *a_, const real_t *b_, const real_t *c_)
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
The classical forward Euler method.
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void PrintProperties(std::ostream &os=mfem::out)
void Init(SecondOrderTimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void Step(Vector &x, Vector &dxdt, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
GeneralizedAlpha2Solver(real_t rho_inf=1.0, bool no_mult_=false)
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void SetRhoInf(real_t rho_inf)
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
GeneralizedAlphaSolver(real_t rho=1.0)
ODEStateData & GetState() override
Returns the StateData.
void PrintProperties(std::ostream &os=mfem::out)
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
const ODEStateData & GetState() const override
Returns the StateData.
HHTAlphaSolver(real_t alpha=1.0)
Forward-backward Euler method.
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
Second order, 2/3-stage implicit-explicit (IMEX) Runge-Kutta (RK) method.
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Second order, two-stage implicit-explicit (IMEX) Runge-Kutta (RK) method.
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
Third order, 3/4-stage implicit-explicit (IMEX) Runge-Kutta (RK) method.
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
Implicit midpoint method. A-stable, not L-stable.
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
LinearAccelerationSolver()
static bool Root()
Return true if the rank in MPI_COMM_WORLD is zero.
static bool IsInitialized()
Return true if MPI has been initialized.
NewmarkSolver(real_t beta_=0.25, real_t gamma_=0.5, bool no_mult_=false)
void Step(Vector &x, Vector &dxdt, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
void PrintProperties(std::ostream &os=mfem::out)
Abstract class for an ODESolver that has state history implemented as ODEStateData.
virtual const ODEStateData & GetState() const =0
Returns the StateData.
virtual int GetStateSize()
Returns how many State vectors the ODE requires.
virtual ODEStateData & GetState()=0
Returns the StateData.
Abstract class for solving systems of ODEs: dx/dt = f(x,t)
TimeDependentOperator * f
Pointer to the associated TimeDependentOperator.
virtual void Init(TimeDependentOperator &f_)
Associate a TimeDependentOperator with the ODE solver.
virtual void Step(Vector &x, real_t &t, real_t &dt)=0
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
void SetImplicitVariableType(const ImplicitVariableType variable_type)
Sets the ImplicitVariableType for the TimeDependentOperator, if supported.
static MFEM_EXPORT std::unique_ptr< ODESolver > SelectImplicit(const int ode_solver_type)
static MFEM_EXPORT std::string Types
static MFEM_EXPORT std::unique_ptr< ODESolver > Select(const int ode_solver_type)
virtual void ComputeSlopeFromState(const real_t dt, const Vector &u, Vector &k)
Compute the finite-difference slope, , and store it in k.
virtual bool SupportsImplicitVariableType(ImplicitVariableType var) const
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
static MFEM_EXPORT std::string ImplicitTypes
static MFEM_EXPORT std::unique_ptr< ODESolver > SelectIMEX(const int ode_solver_type)
virtual void Run(Vector &x, real_t &t, real_t &dt, real_t tf)
Perform time integration from time t [in] to time tf [in].
static MFEM_EXPORT std::string ExplicitTypes
virtual int GetStateSize()
Returns how many State vectors the ODE requires.
static MFEM_EXPORT std::unique_ptr< ODESolver > SelectExplicit(const int ode_solver_type)
static MFEM_EXPORT std::string IMEXTypes
An implementation of ODEStateData that stores states in an std::vector<Vector>
void Increment()
Increment the stage counter.
const Vector & Get(int i) const override
Get the ith state vector.
void Set(int i, Vector &state) override
Set the ith state vector.
void SetSize(int vsize, MemoryType mem_type)
Set the number of stages and the size of the vectors.
ODEStateDataVector(int smax)
void Append(Vector &state) override
Add state vector and increment state size.
void ShiftStages()
Shift the stage counter for the next timestep.
void Print(std::ostream &os=mfem::out) const
Print state data.
Vector & operator[](int i)
Reference access to the ith vector.
const Vector & operator[](int i) const
Const reference access to the ith vector.
int Size() const override
Get the current number of stored stages.
int MaxSize() const override
Get the maximum number of stored stages.
void Reset()
Reset the stage counter.
An interface for storing state of previous timesteps.
virtual void Get(int i, Vector &vec) const =0
Get the ith state vector - with a copy.
virtual int MaxSize() const =0
Get the maximum number of stored stages.
virtual Vector & Get(int i)=0
Get the ith state vector - non-const version.
virtual const Vector & Get(int i) const =0
Get the ith state vector.
virtual void Set(int i, Vector &state)=0
Set the ith state vector.
virtual void Append(Vector &state)=0
Add state vector and increment state size.
virtual int Size() const =0
Get the current number of stored stages.
virtual ~ODEStateData()=default
Virtual destructor.
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
RK2Solver(const real_t a_=2./3.)
Third-order, strong stability preserving (SSP) Runge-Kutta method.
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
The classical explicit fourth-order Runge-Kutta method, RK4.
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
SDIRK23Solver(int gamma_opt=1)
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
First Order Symplectic Integration Algorithm.
void Step(Vector &q, Vector &p, real_t &t, real_t &dt) override
Second Order Symplectic Integration Algorithm.
void Step(Vector &q, Vector &p, real_t &t, real_t &dt) override
TimeDependentOperator * F_
virtual void Init(Operator &P, TimeDependentOperator &F)
virtual void Step(Vector &q, Vector &p, real_t &t, real_t &dt)=0
virtual void Run(Vector &q, Vector &p, real_t &t, real_t &dt, real_t tf)
Variable order Symplectic Integration Algorithm (orders 1-4)
void Step(Vector &q, Vector &p, real_t &t, real_t &dt) override
Abstract class for solving systems of ODEs: d2x/dt2 = f(x,dx/dt,t)
SecondOrderTimeDependentOperator * f
Pointer to the associated TimeDependentOperator.
ODEStateData & GetState()
Functions for getting the state vectors.
void MidPointStep(Vector &x, Vector &dxdt, real_t &t, real_t &dt)
virtual ~SecondOrderODESolver()
const ODEStateData & GetState() const
int GetStateSize()
Returns how many State vectors the ODE requires.
static MFEM_EXPORT std::string Types
Help info for SecondOrderODESolver options.
void EulerStep(Vector &x, Vector &dxdt, real_t &t, real_t &dt)
static MFEM_EXPORT SecondOrderODESolver * Select(const int ode_solver_type)
Function selecting the desired SecondOrderODESolver.
virtual void Run(Vector &x, Vector &dxdt, real_t &t, real_t &dt, real_t tf)
Perform time integration from time t [in] to time tf [in].
virtual void Init(SecondOrderTimeDependentOperator &f)
Associate a TimeDependentOperator with the ODE solver.
virtual void Step(Vector &x, Vector &dxdt, real_t &t, real_t &dt)=0
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
Base abstract class for second order time dependent operators.
Base abstract class for first order time dependent operators.
virtual void SetImplicitVariableType(const ImplicitVariableType variable_type)
Sets the ImplicitVariableType for ImplicitSolve(). This is called by the ODESolver after confirming t...
void Step(Vector &x, real_t &t, real_t &dt) override
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
WBZAlphaSolver(real_t rho_inf=1.0)
real_t u(const Vector &xvec)
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
MemoryType
Memory types supported by MFEM.
@ HOST
Host memory; using new[] and delete[].
real_t p(const Vector &x, real_t t)