58 add(x, (1. -
b)*dt, dxdt, x1);
63 add(x1,
b*dt, dxdt, x);
89 add(3./4, x, 1./4, y, y);
95 add(1./3, x, 2./3, y, x);
153 for (
int i = 0; i < s; i++)
171 for (
int l = 0, i = 1; i < s; i++)
173 add(x, a[l++]*dt, k[0], y);
174 for (
int j = 1; j < i; j++)
176 y.
Add(a[l++]*dt, k[j]);
182 for (
int i = 0; i <
s; i++)
184 x.
Add(b[i]*dt, k[i]);
194const real_t RK6Solver::a[] =
197 .1923996296296296296296296296296296296296e-1,
198 .7669337037037037037037037037037037037037e-1,
202 1.318683415233148260919747276431735612861,
204 -5.042058063628562225427761634715637693344,
205 4.220674648395413964508014358283902080483,
206 -41.87259166432751461803757780644346812905,
208 159.4325621631374917700365669070346830453,
209 -122.1192135650100309202516203389242140663,
210 5.531743066200053768252631238332999150076,
211 -54.43015693531650433250642051294142461271,
213 207.0672513650184644273657173866509835987,
214 -158.6108137845899991828742424365058599469,
215 6.991816585950242321992597280791793907096,
216 -.1859723106220323397765171799549294623692e-1,
217 -54.66374178728197680241215648050386959351,
219 207.9528062553893734515824816699834244238,
220 -159.2889574744995071508959805871426654216,
221 7.018743740796944434698170760964252490817,
222 -.1833878590504572306472782005141738268361e-1,
223 -.5119484997882099077875432497245168395840e-3
225const real_t RK6Solver::b[] =
227 .3438957868357036009278820124728322386520e-1,
230 .2582624555633503404659558098586120858767,
231 .4209371189673537150642551514069801967032,
232 4.405396469669310170148836816197095664891,
233 -176.4831190242986576151740942499002125029,
234 172.3641334014150730294022582711902413315
236const real_t RK6Solver::c[] =
239 .9593333333333333333333333333333333333333e-1,
247const real_t RK8Solver::a[] =
255 .3613975628004575124052940721184028345129,
257 -1.341524066700492771819987788202715834917,
258 1.370126503900035259414693716084313000404,
259 .490472027972027972027972027972027972028e-1,
262 .2350972042214404739862988335493427143122,
263 .180855592981356728810903963653454488485,
264 .6169289044289044289044289044289044289044e-1,
267 .1123656831464027662262557035130015442303,
268 -.3885046071451366767049048108111244567456e-1,
269 .1979188712522045855379188712522045855379e-1,
270 -1.767630240222326875735597119572145586714,
274 -6.061889377376669100821361459659331999758,
275 5.650823198222763138561298030600840174201,
276 65.62169641937623283799566054863063741227,
277 -1.180945066554970799825116282628297957882,
280 -41.50473441114320841606641502701994225874,
281 -4.434438319103725011225169229846100211776,
282 4.260408188586133024812193710744693240761,
283 43.75364022446171584987676829438379303004,
284 .787142548991231068744647504422630755086e-2,
285 -1.281405999441488405459510291182054246266,
288 -45.04713996013986630220754257136007322267,
289 -4.731362069449576477311464265491282810943,
290 4.514967016593807841185851584597240996214,
291 47.44909557172985134869022392235929015114,
292 .1059228297111661135687393955516542875228e-1,
293 -.5746842263844616254432318478286296232021e-2,
294 -1.724470134262485191756709817484481861731,
297 -60.92349008483054016518434619253765246063,
298 -5.95151837622239245520283276706185486829,
299 5.556523730698456235979791650843592496839,
300 63.98301198033305336837536378635995939281,
301 .1464202825041496159275921391759452676003e-1,
302 .6460408772358203603621865144977650714892e-1,
303 -.7930323169008878984024452548693373291447e-1,
304 -3.301622667747079016353994789790983625569,
307 -118.011272359752508566692330395789886851,
308 -10.14142238845611248642783916034510897595,
309 9.139311332232057923544012273556827000619,
310 123.3759428284042683684847180986501894364,
311 4.623244378874580474839807625067630924792,
312 -3.383277738068201923652550971536811240814,
313 4.527592100324618189451265339351129035325,
314 -5.828495485811622963193088019162985703755
316const real_t RK8Solver::b[] =
318 .4427989419007951074716746668098518862111e-1,
323 .3541049391724448744815552028733568354121,
324 .2479692154956437828667629415370663023884,
325 -15.69420203883808405099207034271191213468,
326 25.08406496555856261343930031237186278518,
327 -31.73836778626027646833156112007297739997,
328 22.93828327398878395231483560344797018313,
329 -.2361324633071542145259900641263517600737
331const real_t RK8Solver::c[] =
340 .901802041735856958259707940678372149956,
349 smax = std::min(s_,5);
370 MFEM_ASSERT( (i >= 0) && ( i < s ),
371 " AdamsBashforthSolver::GetStateVector \n" <<
372 " - Tried to get non-existent state "<<i);
379 MFEM_ASSERT( (i >= 0) && ( i < s ),
380 " AdamsBashforthSolver::GetStateVector \n" <<
381 " - Tried to get non-existent state "<<i);
389 MFEM_ASSERT( (i >= 0) && ( i < smax ),
390 " AdamsBashforthSolver::SetStateVector \n" <<
391 " - Tried to set non-existent state "<<i);
401 for (
int i = 0; i < smax; i++)
403 idx[i] = (smax-i)%smax;
411 if ( (dt_ > 0.0) && (fabs(dt-dt_) >10*std::numeric_limits<real_t>::epsilon()))
419 mfem::out <<
" - Time step changed" << std::endl;
420 mfem::out <<
" - Purging Adams-Bashforth history" << std::endl;
421 mfem::out <<
" - Will run Runge-Kutta to rebuild history" << std::endl;
426 s = std::min(s, smax);
430 f->
Mult(x, k[idx[0]]);
431 for (
int i = 0; i < s; i++)
433 x.
Add(a[i]*dt, k[idx[i]]);
439 f->
Mult(x,k[idx[0]]);
440 RKsolver->
Step(x,
t,dt);
444 for (
int i = 0; i < smax; i++) { idx[i] = ++idx[i]%smax; }
447const real_t AB1Solver::a[] =
449const real_t AB2Solver::a[] =
451const real_t AB3Solver::a[] =
452{23.0/12.0,-4.0/3.0, 5.0/12.0};
453const real_t AB4Solver::a[] =
454{55.0/24.0,-59.0/24.0, 37.0/24.0,-9.0/24.0};
455const real_t AB5Solver::a[] =
456{1901.0/720.0,-2774.0/720.0, 2616.0/720.0,-1274.0/720.0, 251.0/720.0};
461 smax = std::min(s_+1,5);
478 MFEM_ASSERT( (i >= 0) && ( i < s ),
479 " AdamsMoultonSolver::GetStateVector \n" <<
480 " - Tried to get non-existent state "<<i);
486 MFEM_ASSERT( (i >= 0) && ( i < s ),
487 " AdamsMoultonSolver::GetStateVector \n" <<
488 " - Tried to get non-existent state "<<i);
494 MFEM_ASSERT( (i >= 0) && ( i < smax ),
495 " AdamsMoultonSolver::SetStateVector \n" <<
496 " - Tried to set non-existent state "<<i);
507 for (
int i = 0; i < smax; i++)
509 idx[i] = (smax-i)%smax;
517 if ( (dt_ > 0.0) && (fabs(dt-dt_) >10*std::numeric_limits<real_t>::epsilon()))
525 mfem::out <<
" - Time step changed" << std::endl;
526 mfem::out <<
" - Purging Adams-Moulton history" << std::endl;
527 mfem::out <<
" - Will run Runge-Kutta to rebuild history" << std::endl;
531 if ((s == 0)&&(smax>1))
533 f->
Mult(x,k[idx[1]]);
536 s = std::min(s, smax);
541 for (
int i = 1; i < smax; i++)
543 x.
Add(a[i]*dt, k[idx[i]]);
546 x.
Add(a[0]*dt, k[idx[0]]);
551 RKsolver->
Step(x,
t,dt);
552 f->
Mult(x,k[idx[0]]);
557 for (
int i = 0; i < smax; i++) { idx[i] = ++idx[i]%smax; }
560const real_t AM0Solver::a[] =
562const real_t AM1Solver::a[] =
564const real_t AM2Solver::a[] =
565{5.0/12.0, 2.0/3.0, -1.0/12.0};
566const real_t AM3Solver::a[] =
567{3.0/8.0, 19.0/24.0,-5.0/24.0, 1.0/24.0};
568const real_t AM4Solver::a[] =
569{251.0/720.0,646.0/720.0,-264.0/720.0, 106.0/720.0, -19.0/720.0};
606 gamma = (3. - sqrt(3.))/6.;
608 else if (gamma_opt == 2)
610 gamma = (2. - sqrt(2.))/2.;
612 else if (gamma_opt == 3)
614 gamma = (2. + sqrt(2.))/2.;
618 gamma = (3. + sqrt(3.))/6.;
665 const real_t a = 1./sqrt(3.)*cos(M_PI/18.) + 0.5;
666 const real_t b = 1./(6.*(2.*
a-1.)*(2.*
a-1.));
677 x.
Add((1.-2.*
b)*dt,
k);
700 const real_t a = 0.435866521508458999416019;
701 const real_t b = 1.20849664917601007033648;
702 const real_t c = 0.717933260754229499708010;
734 add(x, dt/2.0,
k,
y);
758 const real_t a = (2.0 - sqrt(2.0)) / 2.0;
759 const real_t b = (1.0 - 2.0*
a) / (4.0*
a);
793 const real_t a = (3.0 + sqrt(3.0)) / 6.0;
794 const real_t b = (1.0 - 2.0*
a) / (4.0*
a);
795 const real_t b_2 = 1.0 / ( 12.0*
a*(1.0 - 2.0*
a) );
796 const real_t b_3 = (1.0 - 3.0*
a) / ( 3.0*(1.0 - 2.0*
a) );
802 x.
Add((1.0-b_2-b_3)*dt,
k);
827 MFEM_ASSERT( (i == 0) && (
nstate == 1),
828 "GeneralizedAlphaSolver::GetStateVector \n" <<
829 " - Tried to get non-existent state "<<i);
835 MFEM_ASSERT( (i == 0) && (
nstate == 1),
836 "GeneralizedAlphaSolver::GetStateVector \n" <<
837 " - Tried to get non-existent state "<<i);
843 MFEM_ASSERT( (i == 0),
844 "GeneralizedAlphaSolver::SetStateVector \n" <<
845 " - Tried to set non-existent state "<<i);
852 rho_inf = (rho_inf > 1.0) ? 1.0 : rho_inf;
853 rho_inf = (rho_inf < 0.0) ? 0.0 : rho_inf;
856 alpha_m = 0.5*(3.0 - rho_inf)/(1.0 + rho_inf);
863 os <<
"Generalized alpha time integrator:" << std::endl;
864 os <<
"alpha_m = " <<
alpha_m << std::endl;
865 os <<
"alpha_f = " <<
alpha_f << std::endl;
866 os <<
"gamma = " <<
gamma << std::endl;
870 os<<
"Second order"<<
" and ";
874 os<<
"First order"<<
" and ";
879 os<<
"Stable"<<std::endl;
883 os<<
"Unstable"<<std::endl;
980 a_[0] = (2.0+pow(2.0,1.0/3.0)+pow(2.0,-1.0/3.0))/6.0;
981 a_[1] = (1.0-pow(2.0,1.0/3.0)-pow(2.0,-1.0/3.0))/6.0;
985 b_[1] = 1.0/(2.0-pow(2.0,1.0/3.0));
986 b_[2] = 1.0/(1.0-pow(2.0,2.0/3.0));
990 MFEM_ASSERT(
false,
"Unsupported order in SIAVSolver");
997 for (
int i=0; i<order_; i++)
1010 p.Add(b_[i] * dt,
dp_);
1036 os <<
"Newmark time integrator:" << std::endl;
1037 os <<
"beta = " << beta << std::endl;
1038 os <<
"gamma = " << gamma << std::endl;
1042 os<<
"Second order"<<
" and ";
1046 os<<
"First order"<<
" and ";
1049 if ((gamma >= 0.5) && (beta >= (gamma + 0.5)*(gamma + 0.5)/4))
1051 os<<
"A-Stable"<<std::endl;
1053 else if ((gamma >= 0.5) && (beta >= 0.5*gamma))
1055 os<<
"Conditionally stable"<<std::endl;
1059 os<<
"Unstable"<<std::endl;
1065 real_t fac0 = 0.5 - beta;
1066 real_t fac2 = 1.0 - gamma;
1073 f->
Mult(x, dxdt, d2xdt2);
1079 x.
Add(fac0*dt*dt, d2xdt2);
1080 dxdt.
Add(fac2*dt, d2xdt2);
1085 x .
Add(fac3*dt*dt, d2xdt2);
1086 dxdt.
Add(fac4*dt, d2xdt2);
1103 MFEM_ASSERT( (i == 0) && (
nstate == 1),
1104 "GeneralizedAlpha2Solver::GetStateVector \n" <<
1105 " - Tried to get non-existent state "<<i);
1112 MFEM_ASSERT( (i == 0) && (
nstate == 1),
1113 "GeneralizedAlpha2Solver::GetStateVector \n" <<
1114 " - Tried to get non-existent state "<<i);
1120 MFEM_ASSERT( (i == 0),
1121 "GeneralizedAlpha2Solver::SetStateVector \n" <<
1122 " - Tried to set non-existent state "<<i);
1129 os <<
"Generalized alpha time integrator:" << std::endl;
1130 os <<
"alpha_m = " <<
alpha_m << std::endl;
1131 os <<
"alpha_f = " <<
alpha_f << std::endl;
1132 os <<
"beta = " <<
beta << std::endl;
1133 os <<
"gamma = " <<
gamma << std::endl;
1137 os<<
"Second order"<<
" and ";
1141 os<<
"First order"<<
" and ";
1148 os<<
"Stable"<<std::endl;
1152 os<<
"Unstable"<<std::endl;
1187 x *= 1.0 - 1.0/fac1;
1188 x.
Add (1.0/fac1,
xa);
1190 dxdt *= 1.0 - 1.0/fac1;
1191 dxdt.
Add (1.0/fac1,
va);
1193 d2xdt2 *= 1.0 - 1.0/fac5;
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void SetStateVector(int i, Vector &state) override
AdamsBashforthSolver(int s_, const real_t *a_)
const Vector & GetStateVector(int i) override
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].
const Vector & GetStateVector(int i) override
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 SetStateVector(int i, Vector &state) override
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
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].
virtual void Step(Vector &x, real_t &t, real_t &dt)
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
virtual void Init(TimeDependentOperator &f_)
Associate a TimeDependentOperator with the ODE solver.
virtual void Init(TimeDependentOperator &f_)
Associate a TimeDependentOperator with the ODE solver.
virtual void Step(Vector &x, real_t &t, real_t &dt)
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
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.
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 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].
void SetStateVector(int i, Vector &state) override
void PrintProperties(std::ostream &out=mfem::out)
const Vector & GetStateVector(int i) override
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void SetRhoInf(real_t rho_inf)
void SetStateVector(int i, Vector &state) override
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].
const Vector & GetStateVector(int i) override
void PrintProperties(std::ostream &out=mfem::out)
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, 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 &out=mfem::out)
void Init(SecondOrderTimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
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].
virtual MemoryClass GetMemoryClass() const
Return the MemoryClass preferred by the Operator.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
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, 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 forth-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].
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].
void Init(TimeDependentOperator &f_) override
Associate a TimeDependentOperator with the ODE solver.
void Step(Vector &q, Vector &p, real_t &t, real_t &dt) override
void Step(Vector &q, Vector &p, real_t &t, real_t &dt) override
TimeDependentOperator * F_
virtual void Init(Operator &P, TimeDependentOperator &F)
void Step(Vector &q, Vector &p, real_t &t, real_t &dt) override
SecondOrderTimeDependentOperator * f
Pointer to the associated TimeDependentOperator.
virtual void Init(SecondOrderTimeDependentOperator &f)
Associate a TimeDependentOperator with the ODE solver.
Base abstract class for second order time dependent operators.
virtual void Mult(const Vector &x, const Vector &dxdt, Vector &y) const
Perform the action of the operator: y = k = f(x,@ dxdt, t), where k solves the algebraic equation F(x...
virtual void ImplicitSolve(const real_t fac0, const real_t fac1, const Vector &x, const Vector &dxdt, Vector &k)
Solve the equation: k = f(x + fac0 k, dxdt + fac1 k, t), for the unknown k at the current time t.
Base abstract class for first order time dependent operators.
bool isExplicit() const
True if type is EXPLICIT.
virtual void Mult(const Vector &x, Vector &y) const
Perform the action of the operator: y = k = f(x, t), where k solves the algebraic equation F(x,...
virtual void SetTime(const real_t t_)
Set the current time.
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k)
Solve the equation: k = f(x + dt k, t), for the unknown k at the current time t.
virtual void Step(Vector &x, real_t &t, real_t &dt)
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in].
virtual void Init(TimeDependentOperator &f_)
Associate a TimeDependentOperator with the ODE solver.
void SetSize(int s)
Resize the vector to size s.
Vector & Add(const real_t a, const Vector &Va)
(*this) += a * Va
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
void add(const Vector &v1, const Vector &v2, Vector &v)
MemoryType GetMemoryType(MemoryClass mc)
Return a suitable MemoryType for a given MemoryClass.
real_t p(const Vector &x, real_t t)