44template <concepts::multi_variate_problem Problem>
60 static_assert(!problem_type::allowed_evaluations.mass,
61 "Mass matrix is not supported.");
90 problem.evaluate_on(time, variable,
108 problem_ !=
nullptr,
"evaluate_and_update_jacobian is not called.");
111 if (target_norm < std::numeric_limits<scalar_type>::min()) {
112 result = variable_type::Zero(target.size());
116 std::sqrt(std::numeric_limits<scalar_type>::epsilon()) /
126 result /=
static_cast<scalar_type>(2) * diff_width;
140 target += step_size * coeff * (*time_derivative_);
152 static constexpr index_type max_iterations = 100;
153 const auto coeff_function = [
this](
const auto& target,
auto& result) {
158 result = variable_type::Zero(rhs.size());
159 for (
index_type i = 0; i < max_iterations; ++i) {
Class of error tolerances hairer1993.
Class to solve linear equations using generalized minimal residual (GMRES) golub2013.
void solve(CoeffFunction &&coeff_function, const vector_type &rhs, vector_type &solution)
Solve.
auto max_subspace_dim(index_type val) -> gmres &
Set the maximum number of dimensions of subspace.
Class to solve equations in Rosenbrock methods using GMRES.
void apply_jacobian(const Target &target, Result &result)
Multiply Jacobian matrix to a vector.
scalar_type inverted_jacobian_coeff_
Coefficient multiplied to Jacobian matrices in inverted matrices.
problem_type * problem_
Problem.
std::optional< variable_type > time_derivative_
Partial derivative with respect to time.
scalar_type step_size_
Step size.
auto max_subspace_dim(index_type val) -> gmres_rosenbrock_equation_solver &
Set the maximum number of dimensions of subspace used in GMRES.
void add_time_derivative_term(const scalar_type &step_size, const scalar_type &coeff, variable_type &target)
Add a term of partial derivative with respect to time.
void evaluate_and_update_jacobian(problem_type &problem, const scalar_type &time, const scalar_type &step_size, const variable_type &variable)
Update Jacobian matrix and internal parameters.
error_tolerances< variable_type > tolerances_
Error tolerances.
static constexpr bool use_time_derivative
Whether to use partial derivative with respect to time.
impl::gmres< variable_type > gmres_
GMRES solver.
void solve(const variable_type &rhs, variable_type &result)
Solve a linear equation.
variable_type residual_
Residual.
scalar_type tolerance_rate_
Rate of tolerance in this solver.
Problem problem_type
Type of problem.
variable_type variable_
Variable.
static constexpr auto default_tolerance_rate
Default rate of tolerance in this solver.
typename problem_type::scalar_type scalar_type
Type of scalars.
typename problem_type::variable_type variable_type
Type of variables.
auto tolerances(const error_tolerances< variable_type > &val) -> gmres_rosenbrock_equation_solver &
Set the error tolerances.
gmres_rosenbrock_equation_solver(const scalar_type &inverted_jacobian_coeff)
Constructor.
Concept of Eigen's dense vectors with real scalars.
Concept of problems of ordinary differential equations differentiable by time variable.
Definition of error_tolerances class.
Definition of evaluation_type enumeration.
Definition of gmres class.
Definition of index_type type.
Definition of multi_variate_problem concept.
std::ptrdiff_t index_type
Type of indices in this library.
Namespace of Rosenbrock method.
Definition of NUM_COLLECT_PRECONDITION macro.
#define NUM_COLLECT_PRECONDITION(CONDITION,...)
Check whether a precondition is satisfied and throw an exception if not.
Definition of real_scalar_dense_vector concept.
Struct to specify types of evaluations.
Definition of time_differentiable_problem concept.