forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add explicit Heun, Ralston, and Midpoint time integration methods.
* These three methods have a common ExplicitRK2 base class. * The original RungeKutta2 method is equivalent to ExplicitMidpoint. * Improve documentation. Refs idaholab#1929.
- Loading branch information
1 parent
bc5cfc1
commit 78842f5
Showing
10 changed files
with
508 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ | ||
/* */ | ||
/* (c) 2010 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by Battelle Energy Alliance, LLC */ | ||
/* Under Contract No. DE-AC07-05ID14517 */ | ||
/* With the U. S. Department of Energy */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
|
||
#ifndef EXPLICITMIDPOINT_H | ||
#define EXPLICITMIDPOINT_H | ||
|
||
#include "ExplicitRK2.h" | ||
|
||
class ExplicitMidpoint; | ||
|
||
template<> | ||
InputParameters validParams<ExplicitMidpoint>(); | ||
|
||
/** | ||
* The explicit midpoint time integration method. | ||
* | ||
* The Butcher tableau for this method is: | ||
* 0 | 0 | ||
* 1/2 | 1/2 0 | ||
* --------------------- | ||
* | 0 1 | ||
* | ||
* See: ExplicitRK2.h for more information. | ||
*/ | ||
class ExplicitMidpoint : public ExplicitRK2 | ||
{ | ||
public: | ||
ExplicitMidpoint(const InputParameters & parameters); | ||
virtual ~ExplicitMidpoint() {} | ||
|
||
protected: | ||
/// Method coefficient overrides | ||
virtual Real a() const { return .5; } | ||
virtual Real b1() const { return 0.; } | ||
virtual Real b2() const { return 1.; } | ||
}; | ||
|
||
|
||
#endif /* EXPLICITMIDPOINT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ | ||
/* */ | ||
/* (c) 2010 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by Battelle Energy Alliance, LLC */ | ||
/* Under Contract No. DE-AC07-05ID14517 */ | ||
/* With the U. S. Department of Energy */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
|
||
#ifndef EXPLICITRK2_H | ||
#define EXPLICITRK2_H | ||
|
||
#include "TimeIntegrator.h" | ||
|
||
class ExplicitRK2; | ||
|
||
template<> | ||
InputParameters validParams<ExplicitRK2>(); | ||
|
||
/** | ||
* Base class for three different explicit second-order Runge-Kutta | ||
* time integration methods: | ||
* - Explicit midpoint method (ExplicitMidpoint.C) | ||
* - Heun's method (Heun.C) | ||
* - Ralston's method (Ralston.C) | ||
* | ||
* Each of these methods is characterized by the following generic | ||
* Butcher tableau: | ||
* 0 | 0 | ||
* a | a 0 | ||
* --------------------- | ||
* | b1 b2 | ||
* | ||
* where a, b1, and b2 are constants that define the different | ||
* methods. | ||
* | ||
* The stability function for each of these methods is: | ||
* R(z) = z*(z + 2)/2 + 1 | ||
* | ||
* The methods are all explicit, so they are neither A-stable nor L-stable, | ||
* lim R(z), z->oo = oo | ||
* | ||
* See also: | ||
* https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods | ||
* https://en.wikipedia.org/wiki/Midpoint_method | ||
* https://en.wikipedia.org/wiki/Heun%27s_method | ||
* | ||
* All three methods require two mass matrix (linear) system solves | ||
* per timestep. Although strictly speaking these are "two stage" | ||
* methods, we treat the "update" step as a third stage, since in | ||
* finite element analysis the update step requires a mass matrix | ||
* solve. | ||
* | ||
* IMPORTANT: To use the explicit TimeIntegrators derived from this | ||
* method, you must generally add "implicit=false" to the Kernels, | ||
* Materials, etc. used in your simulation, so that MOOSE evaluates | ||
* them correctly! An important exception are TimeDerivative kernels, | ||
* which should never be marked "implicit=false". | ||
*/ | ||
class ExplicitRK2 : public TimeIntegrator | ||
{ | ||
public: | ||
ExplicitRK2(const InputParameters & parameters); | ||
virtual ~ExplicitRK2(); | ||
|
||
virtual int order() { return 2; } | ||
|
||
virtual void computeTimeDerivatives(); | ||
virtual void solve(); | ||
virtual void postStep(NumericVector<Number> & residual); | ||
|
||
protected: | ||
unsigned int _stage; | ||
|
||
/// Buffer to store non-time residual from the first stage. | ||
NumericVector<Number> & _residual_old; | ||
|
||
/// The method coefficients. See the table above for description. | ||
/// These are pure virtual in the base class, and must be overridden | ||
/// in subclasses to implement different schemes. | ||
virtual Real a() const = 0; | ||
virtual Real b1() const = 0; | ||
virtual Real b2() const = 0; | ||
}; | ||
|
||
|
||
#endif /* EXPLICITRK2_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ | ||
/* */ | ||
/* (c) 2010 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by Battelle Energy Alliance, LLC */ | ||
/* Under Contract No. DE-AC07-05ID14517 */ | ||
/* With the U. S. Department of Energy */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
|
||
#ifndef HEUN_H | ||
#define HEUN_H | ||
|
||
#include "ExplicitRK2.h" | ||
|
||
class Heun; | ||
|
||
template<> | ||
InputParameters validParams<Heun>(); | ||
|
||
/** | ||
* Heun's (aka improved Euler) time integration method. | ||
* | ||
* The Butcher tableau for this method is: | ||
* 0 | 0 | ||
* 1 | 1 0 | ||
* --------------------- | ||
* | 1/2 1/2 | ||
* | ||
* See: ExplicitRK2.h for more information. | ||
*/ | ||
class Heun : public ExplicitRK2 | ||
{ | ||
public: | ||
Heun(const InputParameters & parameters); | ||
virtual ~Heun() {} | ||
|
||
protected: | ||
/// Method coefficient overrides | ||
virtual Real a() const { return 1.; } | ||
virtual Real b1() const { return .5; } | ||
virtual Real b2() const { return .5; } | ||
}; | ||
|
||
|
||
#endif /* HEUN_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ | ||
/* */ | ||
/* (c) 2010 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by Battelle Energy Alliance, LLC */ | ||
/* Under Contract No. DE-AC07-05ID14517 */ | ||
/* With the U. S. Department of Energy */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
|
||
#ifndef RALSTON_H | ||
#define RALSTON_H | ||
|
||
#include "ExplicitRK2.h" | ||
|
||
class Ralston; | ||
|
||
template<> | ||
InputParameters validParams<Ralston>(); | ||
|
||
/** | ||
* Ralston's time integration method. | ||
* | ||
* The Butcher tableau for this method is: | ||
* 0 | 0 | ||
* 2/3 | 2/3 0 | ||
* --------------------- | ||
* | 1/4 3/4 | ||
* | ||
* See: ExplicitRK2.h for more information. | ||
*/ | ||
class Ralston : public ExplicitRK2 | ||
{ | ||
public: | ||
Ralston(const InputParameters & parameters); | ||
virtual ~Ralston() {} | ||
|
||
protected: | ||
/// Method coefficient overrides | ||
virtual Real a() const { return 2./3.; } | ||
virtual Real b1() const { return .25; } | ||
virtual Real b2() const { return .75; } | ||
}; | ||
|
||
|
||
#endif /* RALSTON_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ | ||
/* */ | ||
/* (c) 2010 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by Battelle Energy Alliance, LLC */ | ||
/* Under Contract No. DE-AC07-05ID14517 */ | ||
/* With the U. S. Department of Energy */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
|
||
#include "ExplicitMidpoint.h" | ||
|
||
template<> | ||
InputParameters validParams<ExplicitMidpoint>() | ||
{ | ||
InputParameters params = validParams<ExplicitRK2>(); | ||
|
||
return params; | ||
} | ||
|
||
ExplicitMidpoint::ExplicitMidpoint(const InputParameters & parameters) : | ||
ExplicitRK2(parameters) | ||
{ | ||
} |
Oops, something went wrong.