OGS
|
The purpose of these classes and functions is to provide a general interface to external ODE solver libraries. The interface is designed s.t. it can be used without having to know which particular external library will be used to solve the ODE. Furthermore all user-side (or OGS6-side) computations are done using Eigen types. These types are convenient to use and provide bounds checking, even at compile-time.
The inheritance and cooperation between the classes involved when solving an ODE is depicted in the image below. The user side is at the top, the external library side at the bottom. Sundials' CVode solver has been chosen as an example since it is the first external solver we use.
The path on the left side is essentially the way data coming from the user takes towards the ODE solver backend. On that way Eigen types are stripped to raw pointers (double*
).
The path on the right side is the way data coming from the ODE solver backend takes towards the functions provided by the user. On that way raw pointers are wrapped into some Eigen::Map<>
s.
Classes | |
class | MathLib::ODE::ConcreteODESolver< Implementation, NumEquations > |
class | MathLib::ODE::CVodeSolverImpl |
class | MathLib::ODE::CVodeSolver |
class | MathLib::ODE::detail::FunctionHandles |
struct | MathLib::ODE::detail::FunctionHandlesImpl< N > |
Function handles for an ODE system of N equations. More... | |
class | MathLib::ODE::ODESolver< NumEquations > |
Typedefs | |
template<int N, int M> | |
using | MathLib::ODE::MappedMatrix = Eigen::Map<Eigen::Matrix<double, N, M, Eigen::ColMajor>> |
template<int N, int M> | |
using | MathLib::ODE::MappedConstMatrix |
Behaves like a const Eigen::Matrix. | |
template<int N> | |
using | MathLib::ODE::MappedVector = MappedMatrix<N, 1> |
template<int N> | |
using | MathLib::ODE::MappedConstVector = MappedConstMatrix<N, 1> |
template<unsigned N> | |
using | MathLib::ODE::Function |
template<unsigned N> | |
using | MathLib::ODE::JacobianFunction |
Functions | |
void | check_error (std::string const &f_name, int const error_flag) |
void | printStats (void *cvode_mem) |
Prints some statistics about an ODE solver run. | |
template<unsigned NumEquations> | |
std::unique_ptr< ODESolver< NumEquations > > | MathLib::ODE::createODESolver (BaseLib::ConfigTree const &config) |
using MathLib::ODE::Function |
A function computing ydot
as a function of t
and y
.
The function returns true or false indecating whether it succeeded.
N | the number of equations in the ODE system. |
Definition at line 54 of file ODESolverTypes.h.
using MathLib::ODE::JacobianFunction |
A function computing \(\mathtt{jac} := \partial \dot y/\partial y\).
The function returns true or false indecating whether it succeeded.
N | the number of equations in the ODE system. |
Definition at line 64 of file ODESolverTypes.h.
using MathLib::ODE::MappedConstMatrix |
Behaves like a const
Eigen::Matrix.
Definition at line 36 of file ODESolverTypes.h.
using MathLib::ODE::MappedConstVector = MappedConstMatrix<N, 1> |
Definition at line 45 of file ODESolverTypes.h.
using MathLib::ODE::MappedMatrix = Eigen::Map<Eigen::Matrix<double, N, M, Eigen::ColMajor>> |
This type can be used like an \(N \times M\) Eigen::Matrix, but it does not manage the storage for its entries on its own.
N | number of rows |
M | number of columns |
Definition at line 32 of file ODESolverTypes.h.
using MathLib::ODE::MappedVector = MappedMatrix<N, 1> |
Definition at line 41 of file ODESolverTypes.h.
void check_error | ( | std::string const & | f_name, |
int const | error_flag ) |
Checks Sundials error flags and aborts the program in case of error.
f_name | name of the function that returned the error_flag |
error_flag | the error flag to be checked |
Definition at line 32 of file CVodeSolver.cpp.
References OGS_FATAL.
Referenced by MathLib::ODE::CVodeSolverImpl::CVodeSolverImpl(), MathLib::ODE::CVodeSolverImpl::preSolve(), printStats(), and MathLib::ODE::CVodeSolverImpl::solve().
std::unique_ptr< ODESolver< NumEquations > > MathLib::ODE::createODESolver | ( | BaseLib::ConfigTree const & | config | ) |
Creates a new ODESolver instance from the given config
.
NumEquations | the number of equations in the ODE system to be solved. |
Definition at line 39 of file ODESolverBuilder.h.
Referenced by ProcessLib::TES::TESFEMReactionAdaptorCaOH2::TESFEMReactionAdaptorCaOH2().
void printStats | ( | void * | cvode_mem | ) |
Prints some statistics about an ODE solver run.
Definition at line 42 of file CVodeSolver.cpp.
References check_error(), and DBUG().
Referenced by MathLib::ODE::CVodeSolverImpl::~CVodeSolverImpl().