MFEM
v4.5.2
Finite element discretization library
|
#include <sundials.hpp>
Public Member Functions | |
CVODESSolver (int lmm) | |
CVODESSolver (MPI_Comm comm, int lmm) | |
void | Init (TimeDependentAdjointOperator &f_) |
void | InitB (TimeDependentAdjointOperator &f_) |
Initialize the adjoint problem. More... | |
virtual void | Step (Vector &x, double &t, double &dt) |
virtual void | StepB (Vector &w, double &t, double &dt) |
Solve one adjoint time step. More... | |
void | SetWFTolerances (EWTFunction func) |
Set multiplicative error weights. More... | |
void | InitQuadIntegration (mfem::Vector &q0, double reltolQ=1e-3, double abstolQ=1e-8) |
void | InitQuadIntegrationB (mfem::Vector &qB0, double reltolQB=1e-3, double abstolQB=1e-8) |
Initialize Quadrature Integration (Adjoint) More... | |
void | InitAdjointSolve (int steps, int interpolation) |
Initialize Adjoint. More... | |
void | SetMaxNStepsB (int mxstepsB) |
Set the maximum number of backward steps. More... | |
long | GetNumSteps () |
Get Number of Steps for ForwardSolve. More... | |
void | EvalQuadIntegration (double t, Vector &q) |
Evaluate Quadrature. More... | |
void | EvalQuadIntegrationB (double t, Vector &dG_dp) |
Evaluate Quadrature solution. More... | |
void | GetForwardSolution (double tB, mfem::Vector &yy) |
Get Interpolated Forward solution y at backward integration time tB. More... | |
void | UseMFEMLinearSolverB () |
Set Linear Solver for the backward problem. More... | |
void | UseSundialsLinearSolverB () |
Use built in SUNDIALS Newton solver. More... | |
void | SetSStolerancesB (double reltol, double abstol) |
Tolerance specification functions for the adjoint problem. More... | |
void | SetSVtolerancesB (double reltol, Vector abstol) |
Tolerance specification functions for the adjoint problem. More... | |
virtual | ~CVODESSolver () |
Destroy the associated CVODES memory and SUNDIALS objects. More... | |
Public Member Functions inherited from mfem::CVODESolver | |
CVODESolver (int lmm) | |
Construct a serial wrapper to SUNDIALS' CVODE integrator. More... | |
CVODESolver (MPI_Comm comm, int lmm) | |
Construct a parallel wrapper to SUNDIALS' CVODE integrator. More... | |
void | Init (TimeDependentOperator &f_) |
Initialize CVODE: calls CVodeCreate() to create the CVODE memory and set some defaults. More... | |
void | UseMFEMLinearSolver () |
Attach the linear system setup and solve methods from the TimeDependentOperator i.e., SUNImplicitSetup() and SUNImplicitSolve() to CVODE. More... | |
void | UseSundialsLinearSolver () |
Attach SUNDIALS GMRES linear solver to CVODE. More... | |
void | SetStepMode (int itask) |
Select the CVODE step mode: CV_NORMAL (default) or CV_ONE_STEP. More... | |
void | SetSStolerances (double reltol, double abstol) |
Set the scalar relative and scalar absolute tolerances. More... | |
void | SetSVtolerances (double reltol, Vector abstol) |
Set the scalar relative and vector of absolute tolerances. More... | |
void | SetRootFinder (int components, RootFunction func) |
Initialize Root Finder. More... | |
void | SetMaxStep (double dt_max) |
Set the maximum time step. More... | |
void | SetMaxNSteps (int steps) |
Set the maximum number of time steps. More... | |
long | GetNumSteps () |
Get the number of internal steps taken so far. More... | |
void | SetMaxOrder (int max_order) |
Set the maximum method order. More... | |
void | PrintInfo () const |
Print various CVODE statistics. More... | |
virtual | ~CVODESolver () |
Destroy the associated CVODE memory and SUNDIALS objects. More... | |
Public Member Functions inherited from mfem::ODESolver | |
ODESolver () | |
virtual void | Run (Vector &x, double &t, double &dt, double tf) |
Perform time integration from time t [in] to time tf [in]. More... | |
virtual int | GetMaxStateSize () |
Function for getting and setting the state vectors. More... | |
virtual int | GetStateSize () |
virtual const Vector & | GetStateVector (int i) |
virtual void | GetStateVector (int i, Vector &state) |
virtual void | SetStateVector (int i, Vector &state) |
virtual | ~ODESolver () |
Public Member Functions inherited from mfem::SundialsSolver | |
void * | GetMem () const |
Access the SUNDIALS memory structure. More... | |
int | GetFlag () const |
Returns the last flag returned by a call to a SUNDIALS function. More... | |
Static Public Member Functions | |
static int | LinSysSetupB (realtype t, N_Vector y, N_Vector yB, N_Vector fyB, SUNMatrix A, booleantype jok, booleantype *jcur, realtype gamma, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) |
Setup the linear system A x = b. More... | |
static int | LinSysSolveB (SUNLinearSolver LS, SUNMatrix A, N_Vector x, N_Vector b, realtype tol) |
Solve the linear system A x = b. More... | |
Static Protected Member Functions | |
static int | RHSQ (realtype t, const N_Vector y, N_Vector qdot, void *user_data) |
Wrapper to compute the ODE RHS Quadrature function. More... | |
static int | RHSB (realtype t, N_Vector y, N_Vector yB, N_Vector yBdot, void *user_dataB) |
Wrapper to compute the ODE RHS backward function. More... | |
static int | RHSQB (realtype t, N_Vector y, N_Vector yB, N_Vector qBdot, void *user_dataB) |
Wrapper to compute the ODE RHS Backwards Quadrature function. More... | |
static int | ewt (N_Vector y, N_Vector w, void *user_data) |
Error control function. More... | |
Static Protected Member Functions inherited from mfem::CVODESolver | |
static int | RHS (realtype t, const N_Vector y, N_Vector ydot, void *user_data) |
Number of components in gout. More... | |
static int | LinSysSetup (realtype t, N_Vector y, N_Vector fy, SUNMatrix A, booleantype jok, booleantype *jcur, realtype gamma, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) |
Setup the linear system \( A x = b \). More... | |
static int | LinSysSolve (SUNLinearSolver LS, SUNMatrix A, N_Vector x, N_Vector b, realtype tol) |
Solve the linear system \( A x = b \). More... | |
static int | root (realtype t, N_Vector y, realtype *gout, void *user_data) |
Prototype to define root finding for CVODE. More... | |
Protected Attributes | |
int | ncheck |
number of checkpoints used so far More... | |
int | indexB |
backward problem index More... | |
SUNMatrix | AB |
Linear system A = I - gamma J, M - gamma J, or J. More... | |
SUNLinearSolver | LSB |
Linear solver for A. More... | |
SundialsNVector * | q |
Quadrature vector. More... | |
SundialsNVector * | yB |
State vector. More... | |
SundialsNVector * | yy |
State vector. More... | |
SundialsNVector * | qB |
State vector. More... | |
Protected Attributes inherited from mfem::CVODESolver | |
int | lmm_type |
Linear multistep method type. More... | |
int | step_mode |
CVODE step mode (CV_NORMAL or CV_ONE_STEP). More... | |
int | root_components |
RootFunction | root_func |
A class member to facilitate pointing to a user-specified root function. More... | |
EWTFunction | ewt_func |
A class member to facilitate pointing to a user-specified error weight function. More... | |
Protected Attributes inherited from mfem::ODESolver | |
TimeDependentOperator * | f |
Pointer to the associated TimeDependentOperator. More... | |
MemoryType | mem_type |
Protected Attributes inherited from mfem::SundialsSolver | |
void * | sundials_mem |
SUNDIALS mem structure. More... | |
int | flag |
Last flag returned from a call to SUNDIALS. More... | |
bool | reinit |
Flag to signal memory reinitialization is need. More... | |
long | saved_global_size |
Global vector length on last initialization. More... | |
SundialsNVector * | Y |
State vector. More... | |
SUNMatrix | A |
SUNMatrix | M |
Mass matrix M. More... | |
SUNLinearSolver | LSA |
Linear solver for A. More... | |
SUNLinearSolver | LSM |
Linear solver for M. More... | |
SUNNonlinearSolver | NLS |
Nonlinear solver. More... | |
Static Protected Attributes | |
static constexpr double | default_rel_tolB = 1e-4 |
Default scalar backward relative tolerance. More... | |
static constexpr double | default_abs_tolB = 1e-9 |
Default scalar backward absolute tolerance. More... | |
static constexpr double | default_abs_tolQB = 1e-9 |
Default scalar backward absolute quadrature tolerance. More... | |
Static Protected Attributes inherited from mfem::SundialsSolver | |
static constexpr double | default_rel_tol = 1e-4 |
Default scalar relative tolerance. More... | |
static constexpr double | default_abs_tol = 1e-9 |
Default scalar absolute tolerance. More... | |
Additional Inherited Members | |
Protected Types inherited from mfem::CVODESolver | |
typedef std::function< int(realtype t, Vector y, Vector gout, CVODESolver *)> | RootFunction |
Typedef for root finding functions. More... | |
typedef std::function< int(Vector y, Vector w, CVODESolver *)> | EWTFunction |
Typedef declaration for error weight functions. More... | |
Protected Member Functions inherited from mfem::SundialsSolver | |
bool | Parallel () const |
bool | Parallel () const |
SundialsSolver () | |
Protected constructor: objects of this type should be constructed only as part of a derived class. More... | |
void | AllocateEmptyNVector (N_Vector &y) |
void | AllocateEmptyNVector (N_Vector &y, MPI_Comm comm) |
Definition at line 507 of file sundials.hpp.
mfem::CVODESSolver::CVODESSolver | ( | int | lmm | ) |
Construct a serial wrapper to SUNDIALS' CVODE integrator.
[in] | lmm | Specifies the linear multistep method, the options are: CV_ADAMS - implicit methods for non-stiff systems CV_BDF - implicit methods for stiff systems |
Definition at line 964 of file sundials.cpp.
mfem::CVODESSolver::CVODESSolver | ( | MPI_Comm | comm, |
int | lmm | ||
) |
Construct a parallel wrapper to SUNDIALS' CVODE integrator.
[in] | comm | The MPI communicator used to partition the ODE system |
[in] | lmm | Specifies the linear multistep method, the options are: CV_ADAMS - implicit methods for non-stiff systems CV_BDF - implicit methods for stiff systems |
Definition at line 978 of file sundials.cpp.
|
virtual |
Destroy the associated CVODES memory and SUNDIALS objects.
Definition at line 1316 of file sundials.cpp.
void mfem::CVODESSolver::EvalQuadIntegration | ( | double | t, |
Vector & | q | ||
) |
Evaluate Quadrature.
Definition at line 992 of file sundials.cpp.
void mfem::CVODESSolver::EvalQuadIntegrationB | ( | double | t, |
Vector & | dG_dp | ||
) |
Evaluate Quadrature solution.
Definition at line 1002 of file sundials.cpp.
|
staticprotected |
Error control function.
Definition at line 1249 of file sundials.cpp.
void mfem::CVODESSolver::GetForwardSolution | ( | double | tB, |
mfem::Vector & | yy | ||
) |
Get Interpolated Forward solution y at backward integration time tB.
Definition at line 1012 of file sundials.cpp.
long mfem::CVODESSolver::GetNumSteps | ( | ) |
Get Number of Steps for ForwardSolve.
void mfem::CVODESSolver::Init | ( | TimeDependentAdjointOperator & | f_ | ) |
Initialize CVODE: Calls CVodeInit() and sets some defaults. We define this to force the time dependent operator to be a TimeDependenAdjointOperator.
[in] | f_ | the TimeDependentAdjointOperator that defines the ODE system |
Definition at line 1021 of file sundials.cpp.
void mfem::CVODESSolver::InitAdjointSolve | ( | int | steps, |
int | interpolation | ||
) |
Initialize Adjoint.
Definition at line 1059 of file sundials.cpp.
void mfem::CVODESSolver::InitB | ( | TimeDependentAdjointOperator & | f_ | ) |
Initialize the adjoint problem.
Definition at line 1026 of file sundials.cpp.
void mfem::CVODESSolver::InitQuadIntegration | ( | mfem::Vector & | q0, |
double | reltolQ = 1e-3 , |
||
double | abstolQ = 1e-8 |
||
) |
Definition at line 1071 of file sundials.cpp.
void mfem::CVODESSolver::InitQuadIntegrationB | ( | mfem::Vector & | qB0, |
double | reltolQB = 1e-3 , |
||
double | abstolQB = 1e-8 |
||
) |
Initialize Quadrature Integration (Adjoint)
Definition at line 1086 of file sundials.cpp.
|
static |
Setup the linear system A x = b.
Definition at line 1148 of file sundials.cpp.
|
static |
Solve the linear system A x = b.
Definition at line 1167 of file sundials.cpp.
|
staticprotected |
Wrapper to compute the ODE RHS backward function.
Definition at line 1233 of file sundials.cpp.
|
staticprotected |
Wrapper to compute the ODE RHS Quadrature function.
Definition at line 1206 of file sundials.cpp.
|
staticprotected |
Wrapper to compute the ODE RHS Backwards Quadrature function.
Definition at line 1219 of file sundials.cpp.
void mfem::CVODESSolver::SetMaxNStepsB | ( | int | mxstepsB | ) |
Set the maximum number of backward steps.
Definition at line 1065 of file sundials.cpp.
void mfem::CVODESSolver::SetSStolerancesB | ( | double | reltol, |
double | abstol | ||
) |
Tolerance specification functions for the adjoint problem.
It should be called after InitB() is called.
[in] | reltol | the scalar relative error tolerance. |
[in] | abstol | the scalar absolute error tolerance. |
Definition at line 1180 of file sundials.cpp.
void mfem::CVODESSolver::SetSVtolerancesB | ( | double | reltol, |
Vector | abstol | ||
) |
Tolerance specification functions for the adjoint problem.
It should be called after InitB() is called.
[in] | reltol | the scalar relative error tolerance |
[in] | abstol | the vector of absolute error tolerances |
Definition at line 1186 of file sundials.cpp.
void mfem::CVODESSolver::SetWFTolerances | ( | EWTFunction | func | ) |
Set multiplicative error weights.
Definition at line 1198 of file sundials.cpp.
|
virtual |
Integrate the ODE with CVODE using the specified step mode.
[out] | x | Solution vector at the requested output time x=x(t). |
[in,out] | t | On output, the output time reached. |
[in,out] | dt | On output, the last time step taken. |
Reimplemented from mfem::CVODESolver.
Definition at line 1260 of file sundials.cpp.
|
virtual |
Solve one adjoint time step.
Definition at line 1288 of file sundials.cpp.
void mfem::CVODESSolver::UseMFEMLinearSolverB | ( | ) |
Set Linear Solver for the backward problem.
Definition at line 1101 of file sundials.cpp.
void mfem::CVODESSolver::UseSundialsLinearSolverB | ( | ) |
Use built in SUNDIALS Newton solver.
Definition at line 1133 of file sundials.cpp.
|
protected |
Linear system A = I - gamma J, M - gamma J, or J.
Definition at line 530 of file sundials.hpp.
|
staticprotected |
Default scalar backward absolute tolerance.
Definition at line 540 of file sundials.hpp.
|
staticprotected |
Default scalar backward absolute quadrature tolerance.
Definition at line 542 of file sundials.hpp.
|
staticprotected |
Default scalar backward relative tolerance.
Definition at line 538 of file sundials.hpp.
|
protected |
backward problem index
Definition at line 514 of file sundials.hpp.
|
protected |
Linear solver for A.
Definition at line 531 of file sundials.hpp.
|
protected |
number of checkpoints used so far
Definition at line 513 of file sundials.hpp.
|
protected |
Quadrature vector.
Definition at line 532 of file sundials.hpp.
|
protected |
State vector.
Definition at line 535 of file sundials.hpp.
|
protected |
State vector.
Definition at line 533 of file sundials.hpp.
|
protected |
State vector.
Definition at line 534 of file sundials.hpp.