#include <source/solvers/packages/sundials/cvode/CVODESolver.h>
It is intended to be sufficiently generic to be used independently of the SAMRAI framework. This class declares one private static member function to link the user-defined routine for right-hand side function evaluation and two private statice member functions to link the user-defined preconditioner setup and solve routines. The implementation of these functions is defined by the user in a subclass of the abstract base class CVODEAbstractFunctions. The vector objects used within the solver are given in a subclass of the abstract class SundialsAbstractVector. The SundialsAbstractVector class defines the vector kernel operations required by the CVODE package so that they may be easily supplied by a user who opts not to use the vector kernel supplied by the CVODE package. (It should be noted that the vector kernel used by CVODE is the same as the one used by the other packages in the Sundials of solvers).
Note that this class provides no input or restart capabilities and relies on CVODE for output reporting.
CVODESolver Usage:
CVODE was developed in the Center for Applied Scientific Computing (CASC) at Lawrence Livermore National Laboratory (LLNL). Many of the comments in this class were taken verbatim from CVODE header files. For more information about CVODE and a complete description of the operations and data structures used by this class, see S.D. Cohen and A.C. Hindmarsh, "CVODE User Guide", UCRL-MA-118618, Lawrence Livermore National Laboratory, 1994.
SAMRAI::solv::CVODESolver::CVODESolver | ( | const std::string & | object_name, | |
CVODEAbstractFunctions * | my_functions, | |||
const bool | uses_preconditioner | |||
) |
Constructor for CVODESolver sets default CVODE parameters and initializes the solver package with user-supplied functions CVODESolver parameters may be changed later using member functions described below.
Notes:
Assertion checks:
SAMRAI::solv::CVODESolver::~CVODESolver | ( | ) | [virtual] |
Virtual destructor for CVODESolver closes the CVODE log file and frees the memory allocated for the CVODE memory record.
void SAMRAI::solv::CVODESolver::initialize | ( | SundialsAbstractVector * | solution | ) |
Initialize solver with solution vector. The solution vector is required to initialize the memory record used internally within CVODE. This routine must be called before the solver can be used.
Assertion checks:
int SAMRAI::solv::CVODESolver::solve | ( | ) |
Integrate ODE system specified t_f. The integer return value is a termination code defined by CVODE. The following is a table of termination codes and a brief description of their meanings.
CVODE Termination Codes:
See cvode.h header file for more information about return values.
If CVODE or CVSpgmr requires re-initialization, it is automatically done before the solve. This may be required if any of the CVODE or CVSpgmr data parameters have changed since the last call to the solver.
Assertion checks:
void SAMRAI::solv::CVODESolver::setLogFileData | ( | const std::string & | log_fname = std::string() |
) |
Accessor function for setting CVODE output log file name and output printing options. Output file name and options may be changed throughout run as desired.
If the file name string is empty the default file name "cvode.log" is used.
void SAMRAI::solv::CVODESolver::setCVODEFunctions | ( | CVODEAbstractFunctions * | my_functions, | |
const bool | uses_preconditioner | |||
) |
Set CVODESolver to use my_functions as the concrete subclass of the CVODEAbstractFunctions class that defines the right-hand side evaluation and preconditioner functions. The uses_preconditioner argument indicates whether or not the the user has defined preconditioner routines in their concrete subclass of the CVODEAbstractFunctions class.
Assertion checks:
CVODEAbstractFunctions * SAMRAI::solv::CVODESolver::getCVODEFunctions | ( | ) | const |
Return pointer to object that provides user-defined functions for CVODE and CVSpgmr.
void SAMRAI::solv::CVODESolver::setLinearMultistepMethod | ( | int | linear_multistep_method | ) |
Set linear multistep method. The user can specify either ADAMS or BDF (backward differentiation formula) methods The BDF method is recommended for stiff problems, and the ADAMS method is recommended for nonstiff problems.
Assertion checks:
Note: the enumeration constants ADAMS and BDF are defined in cvode.h.
void SAMRAI::solv::CVODESolver::setIterationType | ( | int | iteration_type | ) |
Set iteration type. The user can specify either FUNCTIONAL iteration, which does not require linear algebra, or a NEWTON iteration, which requires the solution of linear systems. In the NEWTON case, the user must also specify a CVODE linear solver. NEWTON is recommended in case of stiff problems.
Assertion checks:
Note: the enumeration constants FUNCTIONAL and NEWTON are defined in cvode.h.
void SAMRAI::solv::CVODESolver::setToleranceType | ( | int | tolerance_type | ) |
Set tolerance type. This parameter specifies the relative and absolute tolerance types to be used. The SS tolerance type means a scalar relative and absolute tolerance, while the SV tolerance type means a scalar relative tolerance and a vector absolute tolerance (a potentially different absolute tolerance for each vector component).
Assertion checks:
Note: the enumeration constants SS and SV are defined in cvode.h.
void SAMRAI::solv::CVODESolver::setRelativeTolerance | ( | double | relative_tolerance | ) |
Set the relative tolerance level.
Assertion checks:
Note that pure absolute tolerance can be used by setting the relative tolerance to 0. However, it is an error to simultaneously set relative and absolute tolerances to 0.
void SAMRAI::solv::CVODESolver::setAbsoluteTolerance | ( | double | absolute_tolerance | ) |
Set the scalar absolute tolerance level.
Assertion checks:
Note that pure relative tolerance can be used by setting the absolute tolerance to 0. However, it is an error to simultaneously set relative and absolute tolerances to 0.
void SAMRAI::solv::CVODESolver::setAbsoluteTolerance | ( | SundialsAbstractVector * | absolute_tolerance | ) |
Set the vector absolute tolerance level.
Assertion checks:
Note that pure relative tolerance can be used by setting the absolute tolerance to 0. However, it is an error to simultaneously set relative and absolute tolerances to 0.
void SAMRAI::solv::CVODESolver::setSteppingMethod | ( | int | stepping_method | ) |
Set stepping method to use for integration. There are stepping methods: NORMAL and ONE_STEP. The NORMAL method has the solver take internal steps until it has reached or just passed the user specified t_f parameter. The solver then interpolates in order to return an approximate value of y(t_f). The ONE_STEP option tells the solver to just take one internal step and return the solution at the point reached by that step.
Assertion checks:
Note: the enumeration constants NORMAL and ONE_STEP are defined in cvode.h.
void SAMRAI::solv::CVODESolver::setInitialValueOfIndependentVariable | ( | double | t_0 | ) |
Set initial value for independent variable.
void SAMRAI::solv::CVODESolver::setFinalValueOfIndependentVariable | ( | double | t_f, | |
bool | cvode_needs_initialization | |||
) |
Set final value for independent variable (i.e. the value of independent variable to integrate the system to). The boolean argument specifies whether CVODE should be re-initialized (i.e. on first step) or if we are taking subsequent steps in a sequence, in which case it is not initialized.
void SAMRAI::solv::CVODESolver::setInitialConditionVector | ( | SundialsAbstractVector * | ic_vector | ) |
Set initial condition vector.
Assertion checks:
void SAMRAI::solv::CVODESolver::setMaximumLinearMultistepMethodOrder | ( | int | max_order | ) |
Set maximum order for the linear multistep method. By default, this is set to 12 for ADAMS methods and 5 for BDF methods.
Assertion checks:
void SAMRAI::solv::CVODESolver::setMaximumNumberOfInternalSteps | ( | int | max_num_internal_steps | ) |
Set maximum number of internal steps to be taken by the solver in its attempt to reach t_f. By default, this is set to 500.
Assertion checks:
void SAMRAI::solv::CVODESolver::setMaximumNumberOfNilStepWarnings | ( | int | max_num_warnings | ) |
Set maximum number of warning messages issued by the solver that (t + h == t) on the next internal step. By default, this is set to 10.
Assertion checks:
void SAMRAI::solv::CVODESolver::setInitialStepSize | ( | double | init_step_size | ) |
Set initial step size.
Assertion checks:
void SAMRAI::solv::CVODESolver::setMaximumAbsoluteStepSize | ( | double | max_step_size | ) |
Set maximum absolute value of step size allowed. By default, there is no upper bound on the absolute value of step size.
Assertion checks:
void SAMRAI::solv::CVODESolver::setMinimumAbsoluteStepSize | ( | double | min_step_size | ) |
Set minimum absolute value of step size allowed. By default, this is set to 0.0.
Assertion checks:
void SAMRAI::solv::CVODESolver::setPreconditioningType | ( | int | precondition_type | ) |
Set the preconditioning type to be used by CVSpgmr. This must be one of the four enumeration constants NONE, LEFT, RIGHT, or BOTH defined in iterativ.h. These correspond to no preconditioning, left preconditioning only, right preconditioning only, and both left and right preconditioning, respectively.
Assertion Checks:
void SAMRAI::solv::CVODESolver::setGramSchmidtType | ( | int | gs_type | ) |
Set the Gram-Schmidt orthogonalization type to be used by CVSpgmr. This must be one of the two enumeration constants MODIFIED_GS or CLASSICAL_GS defined in iterativ.h. These correspond to using modified Gram-Schmidt and classical Gram-Schmidt, respectively.
Assertion Checks:
void SAMRAI::solv::CVODESolver::setMaxKrylovDimension | ( | int | max_krylov_dim | ) |
Set the maximum Krylov dimension to be used by CVSpgmr. This is an optional input to the CVSPGMR solver. Pass 0 to use the default value MIN(num_equations, CVSPGMR_MAXL=5).
Assertion Checks:
void SAMRAI::solv::CVODESolver::setCVSpgmrToleranceScaleFactor | ( | double | tol_scale_factor | ) |
Set the factor by which the tolerance on the nonlinear iteration is multiplied to get a tolerance on the linear iteration. This is an optional input to the CVSPGMR solver. Pass 0 to use the default value CVSPGMR_DELT = 0.05.
Assertion Checks:
SundialsAbstractVector * SAMRAI::solv::CVODESolver::getSolutionVector | ( | ) | const |
Get solution vector.
int SAMRAI::solv::CVODESolver::getDkyVector | ( | double | t, | |
int | k, | |||
SundialsAbstractVector * | dky | |||
) | const |
Get k-th derivative vector at the specified value of the independent variable, t. The integer return value is return code the CVODE CVodeDky() function. The following is a table of termination codes and a brief description of their meanings.
CVodeDky Return Codes:
Important Notes:
double SAMRAI::solv::CVODESolver::getActualFinalValueOfIndependentVariable | ( | ) | const |
Get actual value of the independent variable that CVODE integrated to (i.e. the value of t that actually corresponds to the solution vector y).
void SAMRAI::solv::CVODESolver::printStatistics | ( | std::ostream & | os | ) | const |
Print CVODE and CVSpgmr statistics.
void SAMRAI::solv::CVODESolver::printCVODEStatistics | ( | std::ostream & | os | ) | const |
Print CVODE statistics to the stream.
The abbreviations printed out refer to the following quantities:
int SAMRAI::solv::CVODESolver::getNumberOfInternalStepsTaken | ( | ) | const |
Return the cumulative number of internal steps taken by the solver.
Note: if the solver was not set to collect statistics, a value of -1 is returned.
int SAMRAI::solv::CVODESolver::getNumberOfRHSFunctionCalls | ( | ) | const |
Return the number of calls to the right-hand side function.
Note: if the solver was not set to collect statistics, a value of -1 is returned.
int SAMRAI::solv::CVODESolver::getNumberOfLinearSolverSetupCalls | ( | ) | const |
Return the number of calls made to linear solver setup routines.
Note: if the solver was not set to collect statistics, a value of -1 is returned.
int SAMRAI::solv::CVODESolver::getNumberOfNewtonIterations | ( | ) | const |
Return the number of NEWTON iterations performed.
Note: if the solver was not set to collect statistics, a value of -1 is returned.
int SAMRAI::solv::CVODESolver::getNumberOfNonlinearConvergenceFailures | ( | ) | const |
Return the number of nonlinear convergence failures that have occurred.
Note: if the solver was not set to collect statistics, a value of -1 is returned.
int SAMRAI::solv::CVODESolver::getNumberOfLocalErrorTestFailures | ( | ) | const |
Return the number of local error test failures.
Note: if the solver was not set to collect statistics, a value of -1 is returned.
int SAMRAI::solv::CVODESolver::getOrderUsedDuringLastInternalStep | ( | ) | const |
Return the order of the linear multistep method used during the last internal step.
Note: if the solver was not set to collect statistics, a value of -1 is returned.
int SAMRAI::solv::CVODESolver::getOrderToBeUsedDuringNextInternalStep | ( | ) | const |
Return the order of the linear multistep method to be used during the next internal step.
Note: if the solver was not set to collect statistics, a value of -1 is returned.
int SAMRAI::solv::CVODESolver::getCVODEMemoryUsageForDoubles | ( | ) | const |
Return the size (in LLNL_REAL words) of memory used for LLNL_REALS.
Note: if the solver was not set to collect statistics, a value of -1 is returned.
int SAMRAI::solv::CVODESolver::getCVODEMemoryUsageForIntegers | ( | ) | const |
Return the size (in integer words) of memory used for integers.
Note: if the solver was not set to collect statistics, a value of -1 is returned.
double SAMRAI::solv::CVODESolver::getStepSizeForLastInternalStep | ( | ) | const |
Return the step size for the last internal step.
Note: if the solver was not set to collect statistics, a value of -1 is returned.
double SAMRAI::solv::CVODESolver::getStepSizeForNextInternalStep | ( | ) | const |
Return the step size to be used in the next internal step.
Note: if the solver was not set to collect statistics, a value of -1 is returned.
double SAMRAI::solv::CVODESolver::getCurrentInternalValueOfIndependentVariable | ( | ) | const |
Return the current internal value of the independent variable reached by the solver.
Note: if the solver was not set to collect statistics, the minimum double value (as defined in float.h) is returned.
double SAMRAI::solv::CVODESolver::getCVODESuggestedToleranceScalingFactor | ( | ) | const |
Return the suggested tolerance scaling factor.
Note: if the solver was not set to collect statistics, a value of -1 is returned.
void SAMRAI::solv::CVODESolver::printCVSpgmrStatistics | ( | std::ostream & | os | ) | const |
Print CVSpgmr statistics to the stream.
The abbreviations printed out refer to the following quantities:
int SAMRAI::solv::CVODESolver::getNumberOfPreconditionerEvaluations | ( | ) | const |
Return the number of preconditioner evaluations.
int SAMRAI::solv::CVODESolver::getNumberOfLinearIterations | ( | ) | const |
Return the number of linear iterations.
int SAMRAI::solv::CVODESolver::getNumberOfPrecondSolveCalls | ( | ) | const |
Return the number of CVSpgmrPrecondSolve() calls.
int SAMRAI::solv::CVODESolver::getNumberOfLinearConvergenceFailures | ( | ) | const |
Return the number of linear convergence failures.
int SAMRAI::solv::CVODESolver::getCVSpgmrMemoryUsageForDoubles | ( | ) | const |
Return the size (in double words) of memory used for doubles.
int SAMRAI::solv::CVODESolver::getCVSpgmrMemoryUsageForIntegers | ( | ) | const |
Return the size (in integer words) of memory used for integers.
void SAMRAI::solv::CVODESolver::printClassData | ( | std::ostream & | os | ) | const [virtual] |
Print out all data members for this object.