MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
ode.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2026, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#ifndef MFEM_ODE
13#define MFEM_ODE
14
16#include "../config/config.hpp"
17#include "operator.hpp"
18#include <vector>
19#include <memory>
20
21namespace mfem
22{
23
24/// An interface for storing state of previous timesteps
26{
27public:
28 /// Get the maximum number of stored stages
29 virtual int MaxSize() const = 0;
30
31 /// Get the current number of stored stages
32 virtual int Size() const = 0;
33
34 /// Get the ith state vector
35 virtual const Vector &Get(int i) const = 0;
36
37 /// Get the ith state vector - non-const version
38 virtual Vector &Get(int i) = 0;
39
40 /// Get the ith state vector - with a copy
41 virtual void Get(int i, Vector &vec) const = 0;
42
43 /// Set the ith state vector
44 virtual void Set(int i, Vector &state) = 0;
45
46 /// Add state vector and increment state size
47 virtual void Append(Vector &state) = 0;
48
49 /// Virtual destructor
50 virtual ~ODEStateData() = default;
51};
52
53/// An implementation of ODEStateData that stores states in an std::vector<Vector>
55{
56private:
57 MemoryType mem_type;
58 int ss, smax;
59 std::vector<Vector> data;
60 Array<int> idx;
61
62public:
63 ODEStateDataVector (int smax): smax(smax)
64 {
65 data.resize(smax);
66 idx.SetSize(smax);
67 ss = 0;
68 };
69
70 /// Set the number of stages and the size of the vectors
71 void SetSize(int vsize, MemoryType mem_type);
72
73 /// Shift the stage counter for the next timestep
74 inline void ShiftStages()
75 {
76 for (int i = 0; i < smax; i++) { idx[i] = (++idx[i])%smax; }
77 };
78
79 /// Increment the stage counter
80 void Increment() { ss++; ss = std::min(ss,smax); };
81
82 /// Reset the stage counter
83 void Reset() { ss = 0; };
84
85 /// Reference access to the ith vector.
86 inline Vector & operator[](int i) { return data[idx[i]]; };
87
88 /// Const reference access to the ith vector.
89 inline const Vector &operator[](int i) const { return data[idx[i]]; };
90
91 /// Print state data
92 void Print(std::ostream &os = mfem::out) const ;
93
94 int MaxSize() const override { return smax; };
95
96 int Size() const override { return ss; };
97
98 const Vector &Get(int i) const override;
99 Vector &Get(int i) override;
100 void Get(int i, Vector &vec) const override;
101
102 void Set(int i, Vector &state) override;
103
104 void Append(Vector &state) override;
105};
106
107
108/// Abstract class for solving systems of ODEs: dx/dt = f(x,t)
109/** For systems of split ODEs:
110 $$ M dx/dt = f_1(x,t) + f_2(x,t) $$
111 where $ M^{-1} f_1 $ and $ M^{-1} f_2 $ are treated differently (e.g.,
112 explicitly and implicitly), the solver class expects a
113 TimeDependentOperator with split functionality. Setting
114 TimeDependentOperator::EvalMode = TimeDependentOperator::ADDITIVE_TERM_1
115 and calling TimeDependentOperator::Mult() should return
116 $ k_1=M^{-1} f_1(x,t) $. Setting TimeDependentOperator::EvalMode =
117 TimeDependentOperator::ADDITIVE_TERM_2 and calling
118 TimeDependentOperator::ImplicitSolve() should solve
119 $ M k_2 = f_2(x+\gamma k_2,t) $. */
121{
122protected:
124 /// Pointer to the associated TimeDependentOperator.
125 TimeDependentOperator *f; // f(.,t) : R^n --> R^n
127
128public:
130
131 /// Associate a TimeDependentOperator with the ODE solver.
132 /** This method has to be called:
133 - Before the first call to Step().
134 - When the dimensions of the associated TimeDependentOperator change.
135 - When a time stepping sequence has to be restarted.
136 - To change the associated TimeDependentOperator. */
137 virtual void Init(TimeDependentOperator &f_);
138
139 /** @brief Perform a time step from time @a t [in] to time @a t [out] based
140 on the requested step size @a dt [in]. */
141 /** @param[in,out] x Approximate solution.
142 @param[in,out] t Time associated with the approximate solution @a x.
143 @param[in,out] dt Time step size.
144
145 The following rules describe the common behavior of the method:
146 - The input @a x [in] is the approximate solution for the input time
147 @a t [in].
148 - The input @a dt [in] is the desired time step size, defining the desired
149 target time: t [target] = @a t [in] + @a dt [in].
150 - The output @a x [out] is the approximate solution for the output time
151 @a t [out].
152 - The output @a dt [out] is the last time step taken by the method which
153 may be smaller or larger than the input @a dt [in] value, e.g. because
154 of time step control.
155 - The method may perform more than one time step internally; in this case
156 @a dt [out] is the last internal time step size.
157 - The output value of @a t [out] may be smaller or larger than
158 t [target], however, it is not smaller than @a t [in] + @a dt [out], if
159 at least one internal time step was performed.
160 - The value @a x [out] may be obtained by interpolation using internally
161 stored data.
162 - In some cases, the contents of @a x [in] may not be used, e.g. when
163 @a x [out] from a previous Step() call was obtained by interpolation.
164 - In consecutive calls to this method, the output @a t [out] of one
165 Step() call has to be the same as the input @a t [in] to the next
166 Step() call.
167 - If the previous rule has to be broken, e.g. to restart a time stepping
168 sequence, then the ODE solver must be re-initialized by calling Init()
169 between the two Step() calls. */
170 virtual void Step(Vector &x, real_t &t, real_t &dt) = 0;
171
172 /// Perform time integration from time @a t [in] to time @a tf [in].
173 /** @param[in,out] x Approximate solution.
174 @param[in,out] t Time associated with the approximate solution @a x.
175 @param[in,out] dt Time step size.
176 @param[in] tf Requested final time.
177
178 The default implementation makes consecutive calls to Step() until
179 reaching @a tf.
180 The following rules describe the common behavior of the method:
181 - The input @a x [in] is the approximate solution for the input time
182 @a t [in].
183 - The input @a dt [in] is the initial time step size.
184 - The output @a dt [out] is the last time step taken by the method which
185 may be smaller or larger than the input @a dt [in] value, e.g. because
186 of time step control.
187 - The output value of @a t [out] is not smaller than @a tf [in]. */
188 virtual void Run(Vector &x, real_t &t, real_t &dt, real_t tf)
189 {
190 while (t < tf) { Step(x, t, dt); }
191 }
192
193 /// Returns how many State vectors the ODE requires
194 virtual int GetStateSize() { return 0; };
195
196 ///@brief Returns @a true if the ODESolver supports the given
197 /// #ImplicitVariableType, @a var, and returns @a false otherwise.
198 /// Default implementation returns @a true if @a var is
199 /// ImplicitVariableType::SLOPE and @a false otherwise.
200 ///@warning Should be overridden in ODESolver that calls TimeDependentOperator::ImplicitSolve().
202 { return (var == ImplicitVariableType::SLOPE); };
203
204 /** @brief Sets the #ImplicitVariableType for the TimeDependentOperator, if supported.
205 @note This should be called after Init().
206 */
208 {
209 if (!f)
210 {
211 MFEM_ABORT("TimeDependentOperator is not set. Call Init() first.");
212 }
213 if (!SupportsImplicitVariableType(variable_type))
214 {
215 MFEM_ABORT("The ODE solver does not support the implicit variable type.");
216 }
217 f->SetImplicitVariableType(variable_type);
218 }
219
220
221 /** @brief Compute the finite-difference slope, @a $\frac{du}{dt} \approx \frac{u(t+dt)-u(t)}{dt}$,
222 * and store it in @a k.
223 * @param [in] dt Finite difference step size.
224 * @param [in] u state vector, @a u(t).
225 * @param [in,out] k On input, @a k contains the state vector, @a u( @a t+ @a dt).
226 * On output, @a k contains the computed slope, @a du/dt.
227 * */
228 virtual void ComputeSlopeFromState(const real_t dt, const Vector &u,
229 Vector &k);
230
231 // Help info for ODESolver options
232 static MFEM_EXPORT std::string ExplicitTypes;
233 static MFEM_EXPORT std::string ImplicitTypes;
234 static MFEM_EXPORT std::string IMEXTypes;
235 static MFEM_EXPORT std::string Types;
236
237 /// Function for selecting the desired ODESolver (Explicit and Implicit)
238 /// Returns an ODESolver pointer based on an type
239 /// Caller gets ownership of the object and is responsible for its deletion
240 static MFEM_EXPORT std::unique_ptr<ODESolver> Select(const int ode_solver_type);
241
242 /// Function for selecting the desired Explicit ODESolver
243 /// Returns an ODESolver pointer based on an type
244 /// Caller gets ownership of the object and is responsible for its deletion
245 static MFEM_EXPORT std::unique_ptr<ODESolver> SelectExplicit(
246 const int ode_solver_type);
247
248 /// Function for selecting the desired Implicit ODESolver
249 /// Returns an ODESolver pointer based on an type
250 /// Caller gets ownership of the object and is responsible for its deletion
251 static MFEM_EXPORT std::unique_ptr<ODESolver> SelectImplicit(
252 const int ode_solver_type);
253
254
255 /// Function for selecting the desired IMEX ODESolver
256 /// Returns an ODESolver pointer based on an type
257 /// Caller gets ownership of the object and is responsible for its deletion
258 static MFEM_EXPORT std::unique_ptr<ODESolver> SelectIMEX(
259 const int ode_solver_type);
260
261 virtual ~ODESolver() { }
262};
263
264/// Abstract class for an ODESolver that has state history implemented as ODEStateData
266{
267public:
268 /// Returns the StateData
269 virtual ODEStateData& GetState() = 0;
270
271 /// Returns the StateData
272 virtual const ODEStateData& GetState() const = 0;
273
274 /// Returns how many State vectors the ODE requires
275 virtual int GetStateSize() { return GetState().MaxSize(); };
276};
277
278
279/// The classical forward Euler method
281{
282private:
283 Vector dxdt;
284
285public:
286 void Init(TimeDependentOperator &f_) override;
287
288 void Step(Vector &x, real_t &t, real_t &dt) override;
289};
290
291
292/** A family of explicit second-order RK2 methods. Some choices for the
293 parameter 'a' are:
294 a = 1/2 - the midpoint method
295 a = 1 - Heun's method
296 a = 2/3 - default, has minimal truncation error. */
297class RK2Solver : public ODESolver
298{
299private:
300 real_t a;
301 Vector dxdt, x1;
302
303public:
304 RK2Solver(const real_t a_ = 2./3.) : a(a_) { }
305
306 void Init(TimeDependentOperator &f_) override;
307
308 void Step(Vector &x, real_t &t, real_t &dt) override;
309};
310
311
312/// Third-order, strong stability preserving (SSP) Runge-Kutta method
314{
315private:
316 Vector y, k;
317
318public:
319 void Init(TimeDependentOperator &f_) override;
320
321 void Step(Vector &x, real_t &t, real_t &dt) override;
322};
323
324
325/// The classical explicit fourth-order Runge-Kutta method, RK4
326class RK4Solver : public ODESolver
327{
328private:
329 Vector y, k, z;
330
331public:
332 void Init(TimeDependentOperator &f_) override;
333
334 void Step(Vector &x, real_t &t, real_t &dt) override;
335};
336
337
338/** An explicit Runge-Kutta method corresponding to a general Butcher tableau
339 +--------+----------------------+
340 | c[0] | a[0] |
341 | c[1] | a[1] a[2] |
342 | ... | ... |
343 | c[s-2] | ... a[s(s-1)/2-1] |
344 +--------+----------------------+
345 | | b[0] b[1] ... b[s-1] |
346 +--------+----------------------+ */
348{
349private:
350 int s;
351 const real_t *a, *b, *c;
352 Vector y, *k;
353
354public:
355 ExplicitRKSolver(int s_, const real_t *a_, const real_t *b_,
356 const real_t *c_);
357
358 void Init(TimeDependentOperator &f_) override;
359
360 void Step(Vector &x, real_t &t, real_t &dt) override;
361
362 virtual ~ExplicitRKSolver();
363};
364
365
366/** An 8-stage, 6th order RK method. From Verner's "efficient" 9-stage 6(5)
367 pair. */
369{
370private:
371 static MFEM_EXPORT const real_t a[28], b[8], c[7];
372
373public:
375};
376
377
378/** A 12-stage, 8th order RK method. From Verner's "efficient" 13-stage 8(7)
379 pair. */
381{
382private:
383 static MFEM_EXPORT const real_t a[66], b[12], c[11];
384
385public:
386 RK8Solver() : ExplicitRKSolver(12, a, b, c) { }
387};
388
389
390/// Backward Euler ODE solver. L-stable.
392{
393protected:
395
396public:
397 void Init(TimeDependentOperator &f_) override;
398
399 void Step(Vector &x, real_t &t, real_t &dt) override;
400
402 {
403 return (var == ImplicitVariableType::STATE ||
404 var == ImplicitVariableType::SLOPE);
405 }
406};
407
408
409/// Implicit midpoint method. A-stable, not L-stable.
411{
412protected:
414
415public:
416 void Init(TimeDependentOperator &f_) override;
417
418 void Step(Vector &x, real_t &t, real_t &dt) override;
419
421 {
422 return (var == ImplicitVariableType::STATE ||
423 var == ImplicitVariableType::SLOPE);
424 }
425};
426
427
428/** Two stage, singly diagonal implicit Runge-Kutta (SDIRK) methods;
429 the choices for gamma_opt are:
430 0 - 3rd order method, not A-stable
431 1 - 3rd order method, A-stable, not L-stable (default)
432 2 - 2nd order method, L-stable
433 3 - 2nd order method, L-stable (has solves outside [t,t+dt]). */
435{
436protected:
439
440public:
441 SDIRK23Solver(int gamma_opt = 1);
442
443 void Init(TimeDependentOperator &f_) override;
444
445 void Step(Vector &x, real_t &t, real_t &dt) override;
446
448 {
449 return (var == ImplicitVariableType::STATE ||
450 var == ImplicitVariableType::SLOPE);
451 }
452};
453
454
455/** Three stage, singly diagonal implicit Runge-Kutta (SDIRK) method of
456 order 4. A-stable, not L-stable. */
458{
459protected:
461
462public:
463 void Init(TimeDependentOperator &f_) override;
464
465 void Step(Vector &x, real_t &t, real_t &dt) override;
466
468 {
469 return (var == ImplicitVariableType::STATE ||
470 var == ImplicitVariableType::SLOPE);
471 }
472};
473
474
475/** Three stage, singly diagonal implicit Runge-Kutta (SDIRK) method of
476 order 3. L-stable. */
478{
479protected:
481
482public:
483 void Init(TimeDependentOperator &f_) override;
484
485 void Step(Vector &x, real_t &t, real_t &dt) override;
486
488 {
489 return (var == ImplicitVariableType::STATE ||
490 var == ImplicitVariableType::SLOPE);
491 }
492};
493
494
495/** Two stage, explicit singly diagonal implicit Runge-Kutta (ESDIRK) method
496 of order 2. A-stable. */
498{
499protected:
501
502public:
503 void Init(TimeDependentOperator &f_) override;
504
505 void Step(Vector &x, real_t &t, real_t &dt) override;
506
508 {
509 return (var == ImplicitVariableType::STATE ||
510 var == ImplicitVariableType::SLOPE);
511 }
512};
513
514
515/** Three stage, explicit singly diagonal implicit Runge-Kutta (ESDIRK) method
516 of order 2. L-stable. */
518{
519protected:
521
522public:
523 void Init(TimeDependentOperator &f_) override;
524
525 void Step(Vector &x, real_t &t, real_t &dt) override;
526
528 {
529 return (var == ImplicitVariableType::STATE ||
530 var == ImplicitVariableType::SLOPE);
531 }
532};
533
534
535/** Three stage, explicit singly diagonal implicit Runge-Kutta (ESDIRK) method
536 of order 3. A-stable. */
538{
539protected:
541
542public:
543 void Init(TimeDependentOperator &f_) override;
544
545 void Step(Vector &x, real_t &t, real_t &dt) override;
546
548 {
549 return (var == ImplicitVariableType::STATE ||
550 var == ImplicitVariableType::SLOPE);
551 }
552};
553
554
555/// Generalized-alpha ODE solver from "A generalized-α method for integrating
556/// the filtered Navier-Stokes equations with a stabilized finite element
557/// method" by K.E. Jansen, C.H. Whiting and G.M. Hulbert.
559{
560 ODEStateDataVector state;
561
562protected:
563
564 mutable Vector k,y;
566
567 void SetRhoInf(real_t rho_inf);
568 void PrintProperties(std::ostream &os = mfem::out);
569public:
570
571 GeneralizedAlphaSolver(real_t rho = 1.0) : state(1) { SetRhoInf(rho); };
572 void Init(TimeDependentOperator &f_) override;
573 void Step(Vector &x, real_t &t, real_t &dt) override;
574
575 ODEStateData& GetState() override { return state; }
576 const ODEStateData& GetState() const override { return state; }
577
579 {
580 return (var == ImplicitVariableType::STATE ||
581 var == ImplicitVariableType::SLOPE);
582 }
583};
584
585
586/** An explicit Adams-Bashforth method. */
588{
589private:
590 const real_t *a;
591 const int stages;
592 real_t dt_;
593 ODEStateDataVector state;
594
595protected:
596 std::unique_ptr<ODESolver> RKsolver;
597
598 inline bool print()
599 {
600#ifdef MFEM_USE_MPI
601 return Mpi::IsInitialized() ? Mpi::Root() : true;
602#else
603 return true;
604#endif
605 }
606
607 void CheckTimestep(real_t dt);
608
609public:
610 AdamsBashforthSolver(int s_, const real_t *a_);
611 void Init(TimeDependentOperator &f_) override;
612 void Step(Vector &x, real_t &t, real_t &dt) override;
613
614 ODEStateData& GetState() override { return state; }
615 const ODEStateData& GetState() const override { return state; }
616};
617
618/** A 1-stage, 1st order AB method. */
620{
621private:
622 static MFEM_EXPORT const real_t a[1];
623
624public:
626};
627
628/** A 2-stage, 2nd order AB method. */
630{
631private:
632 static MFEM_EXPORT const real_t a[2];
633
634public:
636};
637
638/** A 3-stage, 3rd order AB method. */
640{
641private:
642 static MFEM_EXPORT const real_t a[3];
643
644public:
646};
647
648/** A 4-stage, 4th order AB method. */
650{
651private:
652 static MFEM_EXPORT const real_t a[4];
653
654public:
656};
657
658/** A 5-stage, 5th order AB method. */
660{
661private:
662 static MFEM_EXPORT const real_t a[5];
663
664public:
666};
667
668
669/** An implicit Adams-Moulton method. */
671{
672private:
673 const real_t *a;
674 const int stages;
675 real_t dt_;
676 ODEStateDataVector state;
677
678protected:
679 std::unique_ptr<ODESolver> RKsolver;
680
681 inline bool print()
682 {
683#ifdef MFEM_USE_MPI
684 return Mpi::IsInitialized() ? Mpi::Root() : true;
685#else
686 return true;
687#endif
688 }
689
691
692public:
693 AdamsMoultonSolver(int s_, const real_t *a_);
694 void Init(TimeDependentOperator &f_) override;
695 void Step(Vector &x, real_t &t, real_t &dt) override;
696
697 ODEStateData& GetState() override { return state; }
698 const ODEStateData& GetState() const override { return state; }
700 {
701 return (var == ImplicitVariableType::STATE ||
702 var == ImplicitVariableType::SLOPE);
703 }
704};
705
706/** A 1-stage, 2nd order AM method. */
708{
709private:
710 static MFEM_EXPORT const real_t a[2];
711
712public:
714};
715
716/** A 2-stage, 3rd order AM method. */
718{
719private:
720 static MFEM_EXPORT const real_t a[3];
721
722public:
724};
725
726/** A 3-stage, 4th order AM method. */
728{
729private:
730 static MFEM_EXPORT const real_t a[4];
731
732public:
734};
735
736/** A 4-stage, 5th order AM method. */
738{
739private:
740 static MFEM_EXPORT const real_t a[5];
741
742public:
744};
745
746/// The SIASolver class is based on the Symplectic Integration Algorithm
747/// described in "A Symplectic Integration Algorithm for Separable Hamiltonian
748/// Functions" by J. Candy and W. Rozmus, Journal of Computational Physics,
749/// Vol. 92, pages 230-256 (1991).
750
751/** The Symplectic Integration Algorithm (SIA) is designed for systems of first
752 order ODEs derived from a Hamiltonian.
753 H(q,p,t) = T(p) + V(q,t)
754 Which leads to the equations:
755 dq/dt = dT/dp
756 dp/dt = -dV/dq
757 In the integrator the operators P and F are defined to be:
758 P = dT/dp
759 F = -dV/dq
760 */
762{
763public:
764 SIASolver() : F_(NULL), P_(NULL) {}
765
766 virtual void Init(Operator &P, TimeDependentOperator & F);
767
768 virtual void Step(Vector &q, Vector &p, real_t &t, real_t &dt) = 0;
769
770 virtual void Run(Vector &q, Vector &p, real_t &t, real_t &dt, real_t tf)
771 {
772 while (t < tf) { Step(q, p, t, dt); }
773 }
774
775 virtual ~SIASolver() {}
776
777protected:
778 TimeDependentOperator * F_; // p_{i+1} = p_{i} + dt F(q_{i})
779 Operator * P_; // q_{i+1} = q_{i} + dt P(p_{i+1})
780
781 mutable Vector dp_;
782 mutable Vector dq_;
783};
784
785/// First Order Symplectic Integration Algorithm
786class SIA1Solver : public SIASolver
787{
788public:
790 void Step(Vector &q, Vector &p, real_t &t, real_t &dt) override;
791};
792
793/// Second Order Symplectic Integration Algorithm
794class SIA2Solver : public SIASolver
795{
796public:
798 void Step(Vector &q, Vector &p, real_t &t, real_t &dt) override;
799};
800
801/// Variable order Symplectic Integration Algorithm (orders 1-4)
802class SIAVSolver : public SIASolver
803{
804public:
805 SIAVSolver(int order);
806 void Step(Vector &q, Vector &p, real_t &t, real_t &dt) override;
807
808private:
809 int order_;
810
811 Array<real_t> a_;
812 Array<real_t> b_;
813};
814
815
816
817/// Abstract class for solving systems of ODEs: d2x/dt2 = f(x,dx/dt,t)
819{
820protected:
821 /// Pointer to the associated TimeDependentOperator.
822 SecondOrderTimeDependentOperator *f; // f(.,.,t) : R^n x R^n --> R^n
825
826public:
828
829 /// Associate a TimeDependentOperator with the ODE solver.
830 /** This method has to be called:
831 - Before the first call to Step().
832 - When the dimensions of the associated TimeDependentOperator change.
833 - When a time stepping sequence has to be restarted.
834 - To change the associated TimeDependentOperator. */
836
837 /** @brief Perform a time step from time @a t [in] to time @a t [out] based
838 on the requested step size @a dt [in]. */
839 /** @param[in,out] x Approximate solution.
840 @param[in,out] dxdt Approximate rate.
841 @param[in,out] t Time associated with the
842 approximate solution @a x and rate @ dxdt
843 @param[in,out] dt Time step size.
844
845 The following rules describe the common behavior of the method:
846 - The input @a x [in] is the approximate solution for the input time
847 @a t [in].
848 - The input @a dxdt [in] is the approximate rate for the input time
849 @a t [in].
850 - The input @a dt [in] is the desired time step size, defining the desired
851 target time: t [target] = @a t [in] + @a dt [in].
852 - The output @a x [out] is the approximate solution for the output time
853 @a t [out].
854 - The output @a dxdt [out] is the approximate rate for the output time
855 @a t [out].
856 - The output @a dt [out] is the last time step taken by the method which
857 may be smaller or larger than the input @a dt [in] value, e.g. because
858 of time step control.
859 - The method may perform more than one time step internally; in this case
860 @a dt [out] is the last internal time step size.
861 - The output value of @a t [out] may be smaller or larger than
862 t [target], however, it is not smaller than @a t [in] + @a dt [out], if
863 at least one internal time step was performed.
864 - The value @a x [out] may be obtained by interpolation using internally
865 stored data.
866 - In some cases, the contents of @a x [in] may not be used, e.g. when
867 @a x [out] from a previous Step() call was obtained by interpolation.
868 - In consecutive calls to this method, the output @a t [out] of one
869 Step() call has to be the same as the input @a t [in] to the next
870 Step() call.
871 - If the previous rule has to be broken, e.g. to restart a time stepping
872 sequence, then the ODE solver must be re-initialized by calling Init()
873 between the two Step() calls. */
874 virtual void Step(Vector &x, Vector &dxdt, real_t &t, real_t &dt) = 0;
875 void EulerStep(Vector &x, Vector &dxdt, real_t &t, real_t &dt);
876 void MidPointStep(Vector &x, Vector &dxdt, real_t &t, real_t &dt);
877
878 /// Perform time integration from time @a t [in] to time @a tf [in].
879 /** @param[in,out] x Approximate solution.
880 @param[in,out] dxdt Approximate rate.
881 @param[in,out] t Time associated with the approximate solution @a x.
882 @param[in,out] dt Time step size.
883 @param[in] tf Requested final time.
884
885 The default implementation makes consecutive calls to Step() until
886 reaching @a tf.
887 The following rules describe the common behavior of the method:
888 - The input @a x [in] is the approximate solution for the input time
889 @a t [in].
890 - The input @a dxdt [in] is the approximate rate for the input time
891 @a t [in].
892 - The input @a dt [in] is the initial time step size.
893 - The output @a dt [out] is the last time step taken by the method which
894 may be smaller or larger than the input @a dt [in] value, e.g. because
895 of time step control.
896 - The output value of @a t [out] is not smaller than @a tf [in]. */
897 virtual void Run(Vector &x, Vector &dxdt, real_t &t, real_t &dt, real_t tf)
898 {
899 while (t < tf) { Step(x, dxdt, t, dt); }
900 }
901
902 /// Functions for getting the state vectors
904 const ODEStateData& GetState() const { return state; }
905
906 /// Returns how many State vectors the ODE requires
907 int GetStateSize() { return GetState().MaxSize(); };
908
909 /// Help info for SecondOrderODESolver options
910 static MFEM_EXPORT std::string Types;
911
912 /// Function selecting the desired SecondOrderODESolver
913 static MFEM_EXPORT SecondOrderODESolver *Select(const int ode_solver_type);
914
916};
917
918/// The classical newmark method.
919/// Newmark, N. M. (1959) A method of computation for structural dynamics.
920/// Journal of Engineering Mechanics, ASCE, 85 (EM3) 67-94.
922{
923private:
924 real_t beta, gamma;
925 bool no_mult;
926
927public:
928 NewmarkSolver(real_t beta_ = 0.25, real_t gamma_ = 0.5, bool no_mult_ = false)
929 {
930 beta = beta_;
931 gamma = gamma_;
932 no_mult = no_mult_;
933 };
934
935 void PrintProperties(std::ostream &os = mfem::out);
936
937 void Step(Vector &x, Vector &dxdt, real_t &t, real_t &dt) override;
938};
939
941{
942public:
944};
945
947{
948public:
950};
951
953{
954public:
955 FoxGoodwinSolver() : NewmarkSolver(1.0/12.0, 0.5) { };
956};
957
958/// Generalized-alpha ODE solver
959/// A Time Integration Algorithm for Structural Dynamics With Improved
960/// Numerical Dissipation: The Generalized-α Method
961/// J.Chung and G.M. Hulbert, J. Appl. Mech 60(2), 371-375, 1993
962/// https://doi.org/10.1115/1.2900803
963/// rho_inf in [0,1]
965{
966protected:
970
971public:
972 GeneralizedAlpha2Solver(real_t rho_inf = 1.0, bool no_mult_ = false)
973 {
974 no_mult = no_mult_;
975 rho_inf = (rho_inf > 1.0) ? 1.0 : rho_inf;
976 rho_inf = (rho_inf < 0.0) ? 0.0 : rho_inf;
977
978 alpha_m = (2.0 - rho_inf)/(1.0 + rho_inf);
979 alpha_f = 1.0/(1.0 + rho_inf);
980 beta = 0.25*pow(1.0 + alpha_m - alpha_f,2);
981 gamma = 0.5 + alpha_m - alpha_f;
982 };
983
984 void PrintProperties(std::ostream &os = mfem::out);
985
986 void Init(SecondOrderTimeDependentOperator &f_) override;
987
988 void Step(Vector &x, Vector &dxdt, real_t &t, real_t &dt) override;
989
990};
991
992/// The classical midpoint method.
994{
995public:
997 {
998 alpha_m = 0.5;
999 alpha_f = 0.5;
1000 beta = 0.25;
1001 gamma = 0.5;
1002 };
1003};
1004
1005/// HHT-alpha ODE solver
1006/// Improved numerical dissipation for time integration algorithms
1007/// in structural dynamics
1008/// H.M. Hilber, T.J.R. Hughes and R.L. Taylor 1977
1009/// https://doi.org/10.1002/eqe.4290050306
1010/// alpha in [2/3,1] --> Defined differently than in paper.
1012{
1013public:
1015 {
1016 alpha = (alpha > 1.0) ? 1.0 : alpha;
1017 alpha = (alpha < 2.0/3.0) ? 2.0/3.0 : alpha;
1018
1019 alpha_m = 1.0;
1020 alpha_f = alpha;
1021 beta = (2-alpha)*(2-alpha)/4;
1022 gamma = 0.5 + alpha_m - alpha_f;
1023 };
1024
1025};
1026
1027/// WBZ-alpha ODE solver
1028/// An alpha modification of Newmark's method
1029/// W.L. Wood, M. Bossak and O.C. Zienkiewicz 1980
1030/// https://doi.org/10.1002/nme.1620151011
1031/// rho_inf in [0,1]
1033{
1034public:
1035 WBZAlphaSolver(real_t rho_inf = 1.0)
1036 {
1037 rho_inf = (rho_inf > 1.0) ? 1.0 : rho_inf;
1038 rho_inf = (rho_inf < 0.0) ? 0.0 : rho_inf;
1039
1040 alpha_f = 1.0;
1041 alpha_m = 2.0/(1.0 + rho_inf);
1042 beta = 0.25*pow(1.0 + alpha_m - alpha_f,2);
1043 gamma = 0.5 + alpha_m - alpha_f;
1044 };
1045
1046};
1047
1048/// Forward-backward Euler method
1050{
1051private:
1052 Vector k1; Vector k2;
1053public:
1054 void Init(TimeDependentOperator &f_) override;
1055
1056 void Step(Vector &x, real_t &t, real_t &dt) override;
1057
1059 { return (var == ImplicitVariableType::SLOPE); };
1060};
1061
1062/// Second order, two-stage implicit-explicit (IMEX) Runge-Kutta (RK) method
1063/** L-stable IMEX RK2 method adopted from "On the Stability of IMEX Upwind gSBP
1064 Schemes for 1D Linear Advection‑Diffusion Equations" by Sigrun Ortleb. Same
1065 as (2,2,2) from "Implicit-explicit Runge-Kutta methods for time-dependent
1066 partial differential equations" by Ascher, Ruuth and Spiteri, Applied
1067 Numerical Mathematics (1997). */
1068class IMEXRK2 : public ODESolver
1069{
1070private:
1071 Vector k1_exp; Vector k2_exp; Vector k_imp;
1072 //helper vector
1073 Vector y;
1074public:
1075 void Init(TimeDependentOperator &f_) override;
1076
1077 void Step(Vector &x, real_t &t, real_t &dt) override;
1078
1080 { return (var == ImplicitVariableType::SLOPE); };
1081};
1082
1083/// Second order, 2/3-stage implicit-explicit (IMEX) Runge-Kutta (RK) method
1084/** L-stable method (2,3,2) from "Implicit-explicit Runge-Kutta methods for
1085 time-dependent partial differential equations" by Ascher, Ruuth and
1086 Spiteri, Applied Numerical Mathematics (1997). */
1088{
1089private:
1090 Vector k1_exp; Vector k2_exp; Vector k3_exp;
1091 Vector k_imp;
1092 //helper vectors
1093 Vector y;
1094public:
1095 void Init(TimeDependentOperator &f_) override;
1096
1097 void Step(Vector &x, real_t &t, real_t &dt) override;
1098
1100 { return (var == ImplicitVariableType::SLOPE); };
1101};
1102
1103/// Third order, 3/4-stage implicit-explicit (IMEX) Runge-Kutta (RK) method
1104/** L-stable method (3,4,3) from "Implicit-explicit Runge-Kutta methods for
1105 time-dependent partial differential equations" by Ascher, Ruuth and
1106 Spiteri, Applied Numerical Mathematics (1997). */
1108{
1109private:
1110 Vector k1_exp; Vector k2_exp; Vector k3_exp; Vector k4_exp;
1111 Vector k2_imp; Vector k3_imp;
1112 //helper vectors
1113 Vector y;
1114public:
1115 void Init(TimeDependentOperator &f_) override;
1116
1117 void Step(Vector &x, real_t &t, real_t &dt) override;
1118
1120 { return (var == ImplicitVariableType::SLOPE); };
1121};
1122
1123
1124}
1125
1126#endif
ODEStateData & GetState() override
Returns the StateData.
Definition ode.hpp:614
const ODEStateData & GetState() const override
Returns the StateData.
Definition ode.hpp:615
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:540
void CheckTimestep(real_t dt)
Definition ode.cpp:573
AdamsBashforthSolver(int s_, const real_t *a_)
Definition ode.cpp:534
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].
Definition ode.cpp:548
std::unique_ptr< ODESolver > RKsolver
Definition ode.hpp:596
const ODEStateData & GetState() const override
Returns the StateData.
Definition ode.hpp:698
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:699
std::unique_ptr< ODESolver > RKsolver
Definition ode.hpp:679
ODEStateData & GetState() override
Returns the StateData.
Definition ode.hpp:697
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].
Definition ode.cpp:621
AdamsMoultonSolver(int s_, const real_t *a_)
Definition ode.cpp:607
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:613
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
Definition array.hpp:869
The classical midpoint method.
Definition ode.hpp:994
Backward Euler ODE solver. L-stable.
Definition ode.hpp:392
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:682
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].
Definition ode.cpp:688
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:401
static MemoryType GetHostMemoryType()
Get the current Host MemoryType. This is the MemoryType used by most MFEM classes when allocating mem...
Definition device.hpp:289
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:527
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:906
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].
Definition ode.cpp:914
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:949
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].
Definition ode.cpp:957
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:547
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].
Definition ode.cpp:346
virtual ~ExplicitRKSolver()
Definition ode.cpp:376
ExplicitRKSolver(int s_, const real_t *a_, const real_t *b_, const real_t *c_)
Definition ode.cpp:325
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:335
The classical forward Euler method.
Definition ode.hpp:281
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].
Definition ode.cpp:217
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:211
void PrintProperties(std::ostream &os=mfem::out)
Definition ode.cpp:1320
void Init(SecondOrderTimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:1312
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].
Definition ode.cpp:1350
GeneralizedAlpha2Solver(real_t rho_inf=1.0, bool no_mult_=false)
Definition ode.hpp:972
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:994
void SetRhoInf(real_t rho_inf)
Definition ode.cpp:1002
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].
Definition ode.cpp:1040
GeneralizedAlphaSolver(real_t rho=1.0)
Definition ode.hpp:571
ODEStateData & GetState() override
Returns the StateData.
Definition ode.hpp:575
void PrintProperties(std::ostream &os=mfem::out)
Definition ode.cpp:1013
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:578
const ODEStateData & GetState() const override
Returns the StateData.
Definition ode.hpp:576
HHTAlphaSolver(real_t alpha=1.0)
Definition ode.hpp:1014
Forward-backward Euler method.
Definition ode.hpp:1050
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:1401
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:1058
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].
Definition ode.cpp:1409
Second order, 2/3-stage implicit-explicit (IMEX) Runge-Kutta (RK) method.
Definition ode.hpp:1088
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:1475
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].
Definition ode.cpp:1486
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:1099
Second order, two-stage implicit-explicit (IMEX) Runge-Kutta (RK) method.
Definition ode.hpp:1069
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:1079
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:1425
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].
Definition ode.cpp:1435
Third order, 3/4-stage implicit-explicit (IMEX) Runge-Kutta (RK) method.
Definition ode.hpp:1108
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:1532
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:1119
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].
Definition ode.cpp:1545
Implicit midpoint method. A-stable, not L-stable.
Definition ode.hpp:411
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].
Definition ode.cpp:711
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:705
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:420
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)
Definition ode.hpp:928
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].
Definition ode.cpp:1277
void PrintProperties(std::ostream &os=mfem::out)
Definition ode.cpp:1247
Abstract class for an ODESolver that has state history implemented as ODEStateData.
Definition ode.hpp:266
virtual const ODEStateData & GetState() const =0
Returns the StateData.
virtual int GetStateSize()
Returns how many State vectors the ODE requires.
Definition ode.hpp:275
virtual ODEStateData & GetState()=0
Returns the StateData.
Abstract class for solving systems of ODEs: dx/dt = f(x,t)
Definition ode.hpp:121
TimeDependentOperator * f
Pointer to the associated TimeDependentOperator.
Definition ode.hpp:125
virtual void Init(TimeDependentOperator &f_)
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:182
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].
virtual ~ODESolver()
Definition ode.hpp:261
void SetImplicitVariableType(const ImplicitVariableType variable_type)
Sets the ImplicitVariableType for the TimeDependentOperator, if supported.
Definition ode.hpp:207
static MFEM_EXPORT std::unique_ptr< ODESolver > SelectImplicit(const int ode_solver_type)
Definition ode.cpp:77
static MFEM_EXPORT std::string Types
Definition ode.hpp:235
static MFEM_EXPORT std::unique_ptr< ODESolver > Select(const int ode_solver_type)
Definition ode.cpp:41
virtual void ComputeSlopeFromState(const real_t dt, const Vector &u, Vector &k)
Compute the finite-difference slope, , and store it in k.
Definition ode.cpp:194
MemoryType mem_type
Definition ode.hpp:126
virtual bool SupportsImplicitVariableType(ImplicitVariableType var) const
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:201
static MFEM_EXPORT std::string ImplicitTypes
Definition ode.hpp:233
static MFEM_EXPORT std::unique_ptr< ODESolver > SelectIMEX(const int ode_solver_type)
Definition ode.cpp:116
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].
Definition ode.hpp:188
static MFEM_EXPORT std::string ExplicitTypes
Definition ode.hpp:232
virtual int GetStateSize()
Returns how many State vectors the ODE requires.
Definition ode.hpp:194
static MFEM_EXPORT std::unique_ptr< ODESolver > SelectExplicit(const int ode_solver_type)
Definition ode.cpp:53
static MFEM_EXPORT std::string IMEXTypes
Definition ode.hpp:234
An implementation of ODEStateData that stores states in an std::vector<Vector>
Definition ode.hpp:55
void Increment()
Increment the stage counter.
Definition ode.hpp:80
const Vector & Get(int i) const override
Get the ith state vector.
Definition ode.cpp:143
void Set(int i, Vector &state) override
Set the ith state vector.
Definition ode.cpp:161
void SetSize(int vsize, MemoryType mem_type)
Set the number of stages and the size of the vectors.
Definition ode.cpp:131
ODEStateDataVector(int smax)
Definition ode.hpp:63
void Append(Vector &state) override
Add state vector and increment state size.
Definition ode.cpp:167
void ShiftStages()
Shift the stage counter for the next timestep.
Definition ode.hpp:74
void Print(std::ostream &os=mfem::out) const
Print state data.
Definition ode.cpp:174
Vector & operator[](int i)
Reference access to the ith vector.
Definition ode.hpp:86
const Vector & operator[](int i) const
Const reference access to the ith vector.
Definition ode.hpp:89
int Size() const override
Get the current number of stored stages.
Definition ode.hpp:96
int MaxSize() const override
Get the maximum number of stored stages.
Definition ode.hpp:94
void Reset()
Reset the stage counter.
Definition ode.hpp:83
An interface for storing state of previous timesteps.
Definition ode.hpp:26
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.
Abstract operator.
Definition operator.hpp:27
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:226
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].
Definition ode.cpp:234
RK2Solver(const real_t a_=2./3.)
Definition ode.hpp:304
Third-order, strong stability preserving (SSP) Runge-Kutta method.
Definition ode.hpp:314
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:255
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].
Definition ode.cpp:263
The classical explicit fourth-order Runge-Kutta method, RK4.
Definition ode.hpp:327
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:287
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].
Definition ode.cpp:296
SDIRK23Solver(int gamma_opt=1)
Definition ode.cpp:729
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].
Definition ode.cpp:756
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:447
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:749
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].
Definition ode.cpp:840
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:833
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:487
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].
Definition ode.cpp:792
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:784
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:467
First Order Symplectic Integration Algorithm.
Definition ode.hpp:787
void Step(Vector &q, Vector &p, real_t &t, real_t &dt) override
Definition ode.cpp:1081
Second Order Symplectic Integration Algorithm.
Definition ode.hpp:795
void Step(Vector &q, Vector &p, real_t &t, real_t &dt) override
Definition ode.cpp:1094
TimeDependentOperator * F_
Definition ode.hpp:778
Vector dq_
Definition ode.hpp:782
Vector dp_
Definition ode.hpp:781
virtual void Init(Operator &P, TimeDependentOperator &F)
Definition ode.cpp:1072
virtual void Step(Vector &q, Vector &p, real_t &t, real_t &dt)=0
virtual ~SIASolver()
Definition ode.hpp:775
virtual void Run(Vector &q, Vector &p, real_t &t, real_t &dt, real_t tf)
Definition ode.hpp:770
Operator * P_
Definition ode.hpp:779
Variable order Symplectic Integration Algorithm (orders 1-4)
Definition ode.hpp:803
void Step(Vector &q, Vector &p, real_t &t, real_t &dt) override
Definition ode.cpp:1151
SIAVSolver(int order)
Definition ode.cpp:1109
Abstract class for solving systems of ODEs: d2x/dt2 = f(x,dx/dt,t)
Definition ode.hpp:819
SecondOrderTimeDependentOperator * f
Pointer to the associated TimeDependentOperator.
Definition ode.hpp:822
ODEStateData & GetState()
Functions for getting the state vectors.
Definition ode.hpp:903
void MidPointStep(Vector &x, Vector &dxdt, real_t &t, real_t &dt)
Definition ode.cpp:1226
virtual ~SecondOrderODESolver()
Definition ode.hpp:915
const ODEStateData & GetState() const
Definition ode.hpp:904
ODEStateDataVector state
Definition ode.hpp:824
int GetStateSize()
Returns how many State vectors the ODE requires.
Definition ode.hpp:907
static MFEM_EXPORT std::string Types
Help info for SecondOrderODESolver options.
Definition ode.hpp:910
void EulerStep(Vector &x, Vector &dxdt, real_t &t, real_t &dt)
Definition ode.cpp:1212
static MFEM_EXPORT SecondOrderODESolver * Select(const int ode_solver_type)
Function selecting the desired SecondOrderODESolver.
Definition ode.cpp:1182
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].
Definition ode.hpp:897
virtual void Init(SecondOrderTimeDependentOperator &f)
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:1240
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.
Definition operator.hpp:807
Base abstract class for first order time dependent operators.
Definition operator.hpp:367
virtual void SetImplicitVariableType(const ImplicitVariableType variable_type)
Sets the ImplicitVariableType for ImplicitSolve(). This is called by the ODESolver after confirming t...
Definition operator.hpp:474
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].
Definition ode.cpp:885
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
Definition ode.cpp:878
bool SupportsImplicitVariableType(ImplicitVariableType var) const override
Returns true if the ODESolver supports the given ImplicitVariableType, var, and returns false otherwi...
Definition ode.hpp:507
Vector data type.
Definition vector.hpp:82
WBZAlphaSolver(real_t rho_inf=1.0)
Definition ode.hpp:1035
Vector beta_
const real_t alpha
Definition ex15.cpp:369
real_t b
Definition lissajous.cpp:42
real_t a
Definition lissajous.cpp:41
real_t u(const Vector &xvec)
Definition lor_mms.hpp:22
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Definition globals.hpp:66
float real_t
Definition config.hpp:46
MemoryType
Memory types supported by MFEM.
@ HOST
Host memory; using new[] and delete[].
real_t p(const Vector &x, real_t t)