File imex-bdf2.hxx¶
-
class
IMEXBDF2
: public Solver¶ - #include <imex-bdf2.hxx>
IMEX-BDF2 time integration solver
Scheme taken from this paper: http://homepages.cwi.nl/~willem/DOCART/JCP07.pdf
W.Hundsdorfer, S.J.Ruuth “IMEX extensions of linear multistep methods with general
monotonicity and boundedness properties” JCP 225 (2007) 2016-2042
The method has been extended to variable order, variable timestep, and includes some adaptive capabilities
Public Functions
-
~IMEXBDF2
()¶
-
int
init
(int nout, BoutReal tstep)¶ Initialise solver. Must be called once and only once
Initialisation routine. Called once before solve.
- Parameters
nout
: Number of outputststep
: Time between outputs. NB: Not internal timestep
-
int
run
()¶ Run the simulation.
-
PetscErrorCode
snes_function
(Vec x, Vec f, bool linear)¶ Nonlinear function. This is called by PETSc SNES object via a static C-style function. For implicit time integration this function calculates:
f = (x - gamma*G(x)) - rhs
- Parameters
x
: The state vectorf
: The vector for the result f(x)linear
: Specifies that the SNES solver is in a linear (KSP) inner loop, so the operator should be linearised if possible
-
PetscErrorCode
precon
(Vec x, Vec f)¶ Preconditioner. Called by PCapply via a C-style static function.
- Parameters
x
: The vector to be operated onf
: The result of the operation
Private Functions
-
void
take_step
(BoutReal curtime, BoutReal dt, int order = 2)¶ Take a full step at requested order
Take a full IMEX-BDF step of order “order”. Note that this assumes that enough time points are already available (in u and f).
- Parameters
curtime
: The current simulation timedt
: The time step to takeorder
: The order of accuracy
Inputs: u* - Solution history f* - Non-stiff component history
Outputs: u - Latest Solution f1 - Non-stiff time derivative at current time
-
void
constructSNES
(SNES *snesIn)¶ Setup a SNES object This includes creating, setting functions, options, and internal (KSP) solver, and Jacobian options including coloring.
-
void
shuffleState
()¶ Shuffle state along one step.
-
void
calculateCoeffs
(int order)¶ Populate the *Fac vectors and dtImp with appropriate coefficients for this order.
-
template<class
Op
>
voidloopVars
(BoutReal *u)¶ Loop over arrays, using template parameter to specify the operation to be performed at each point
-
void
saveVars
(BoutReal *u)¶ Save variables from BOUT++ fields into a pre-allocated array
u
Copy data from fields into array
Private Members
-
int
maxOrder
¶ Specify the maximum order of the scheme to use (1/2/3)
-
int
nsteps
¶ Number of output steps.
-
int
ninternal
¶ Number of internal steps per output.
-
int
mxstep
¶ Maximum number of internal steps between outputs.
-
bool
adaptive
¶ Use adaptive timestepping?
-
int
nadapt
¶ How often do we check the error.
-
int
mxstepAdapt
¶ Maximum no. consecutive times we try to reduce timestep.
-
int
nlocal
¶
-
int
neq
¶ Number of variables on local processor and in total.
-
int
predictor
¶ Predictor method.
-
Vec
snes_f
¶ Used by SNES to store function.
-
Vec
snes_x
¶ Result of SNES.
-
SNES
snes
¶ SNES context.
-
SNES
snesAlt
¶ Alternative SNES object for adaptive checks.
-
SNES
snesUse
¶ The snes object to use in solve stage. Allows easy switching.
-
Mat
Jmf
¶ Matrix-free Jacobian.
-
bool
verbose
¶ Gives a more verbose output for each timestep.
-
int
linear_fails
¶ Number of linear (KSP) convergence failures.
-
int
nonlinear_fails
¶ Numbef of nonlinear (SNES) convergence failures.
-
bool
have_constraints
¶ Are there any constraint variables?
Private Static Attributes
-
const int
MAX_SUPPORTED_ORDER
= 4¶
-