From 2c1b943404e3bd6dc609e037f24e67ce258c32a0 Mon Sep 17 00:00:00 2001 From: Sebastian Proell Date: Mon, 1 Feb 2021 15:52:58 +0100 Subject: [PATCH] ARKode: remove/deprecate unused functionality remove internal solver reference in operators deprecate unnecessary reinit_vector --- .../changes/incompatibilities/20210201Proell | 3 ++ include/deal.II/sundials/arkode.h | 42 ++++++------------- source/sundials/arkode.cc | 42 +++++++------------ tests/sundials/arkode_01.cc | 2 - tests/sundials/arkode_02.cc | 2 - tests/sundials/arkode_03.cc | 5 --- tests/sundials/arkode_04.cc | 5 --- tests/sundials/arkode_05.cc | 5 --- tests/sundials/arkode_06.cc | 5 --- tests/sundials/arkode_07.cc | 5 --- tests/sundials/arkode_08.cc | 2 - 11 files changed, 30 insertions(+), 88 deletions(-) create mode 100644 doc/news/changes/incompatibilities/20210201Proell diff --git a/doc/news/changes/incompatibilities/20210201Proell b/doc/news/changes/incompatibilities/20210201Proell new file mode 100644 index 0000000000..503fdaa212 --- /dev/null +++ b/doc/news/changes/incompatibilities/20210201Proell @@ -0,0 +1,3 @@ +Deprecated: ARKode does no longer need a `reinit_vector` function. +
+(Sebastian Proell, 2021/02/01) diff --git a/include/deal.II/sundials/arkode.h b/include/deal.II/sundials/arkode.h index bd5bda0dcf..0196c33a81 100644 --- a/include/deal.II/sundials/arkode.h +++ b/include/deal.II/sundials/arkode.h @@ -280,10 +280,8 @@ namespace SUNDIALS * $z_j$ where $j < i$). Additional information on the specific predictor * algorithms implemented in ARKode is provided in ARKode documentation. * - * The user has to provide the implementation of the following - *`std::function`s: - * - reinit_vector() - * and either one or both of + * The user has to provide the implementation of at least one (or both) of the + * following `std::function`s: * - implicit_function() * - explicit_function() * @@ -363,12 +361,7 @@ namespace SUNDIALS * * SUNDIALS::ARKode ode; * - * ode.reinit_vector = [] (VectorType&v) - * { - * v.reinit(2); - * }; - * - * double kappa = 1.0; + * const double kappa = 1.0; * * ode.explicit_function = [kappa] (double, * const VectorType &y, @@ -634,9 +627,14 @@ namespace SUNDIALS get_arkode_memory() const; /** - * A function object that users need to supply and that is intended to - * reinit the given vector. + * A function object that was used to `reinit` the given vector. Setting + * this field does no longer have any effect and all auxiliary vectors are + * reinit-ed automatically based on the user-supplied vector in solve_ode(). + * + * @deprecated This function is no longer used and can be safely removed in + * user code. */ + DEAL_II_DEPRECATED std::function reinit_vector; /** @@ -1373,19 +1371,12 @@ namespace SUNDIALS /** * Constructor. * - * @param solver The ARKode solver that uses this operator * @param A_data Data required by @p a_times_fn * @param a_times_fn A function pointer to the function that computes A*v */ - SundialsOperator(ARKode &solver, - void * A_data, - ATimesFn a_times_fn); + SundialsOperator(void *A_data, ATimesFn a_times_fn); private: - /** - * Reference to the ARKode object that uses this SundialsOperator. - */ - ARKode &solver; /** * Data necessary to evaluate a_times_fn. */ @@ -1421,23 +1412,14 @@ namespace SUNDIALS /** * Constructor. * - * @param solver The ARKode solver that uses this operator * @param P_data Data required by @p p_solve_fn * @param p_solve_fn A function pointer to the function that computes A*v * @param tol Tolerance, that an iterative solver should use to judge * convergence */ - SundialsPreconditioner(ARKode &solver, - void * P_data, - PSolveFn p_solve_fn, - double tol); + SundialsPreconditioner(void *P_data, PSolveFn p_solve_fn, double tol); private: - /** - * Reference to the ARKode object that uses this SundialsPreconditioner. - */ - ARKode &solver; - /** * Data necessary to calls p_solve_fn */ diff --git a/source/sundials/arkode.cc b/source/sundials/arkode.cc index 7cf6d94a4d..41e88ffa2f 100644 --- a/source/sundials/arkode.cc +++ b/source/sundials/arkode.cc @@ -384,11 +384,8 @@ namespace SUNDIALS LinearSolveFunction lsolve; - //! solver reference to forward all solver related calls to user-specified - //! functions - ARKode *solver; - void * P_data; - void * A_data; + void *P_data; + void *A_data; }; @@ -422,18 +419,15 @@ namespace SUNDIALS N_Vector b, realtype tol) { - auto content = access_content(LS); - ARKode &solver = *(content->solver); + auto content = access_content(LS); auto *src_b = internal::unwrap_nvector_const(b); auto *dst_x = internal::unwrap_nvector(x); - SundialsOperator op(solver, - content->A_data, - content->a_times_fn); + SundialsOperator op(content->A_data, content->a_times_fn); SundialsPreconditioner preconditioner( - solver, content->P_data, content->preconditioner_solve, tol); + content->P_data, content->preconditioner_solve, tol); return content->lsolve(op, preconditioner, *dst_x, *src_b, tol); } @@ -503,8 +497,7 @@ namespace SUNDIALS class SundialsLinearSolverWrapper { public: - SundialsLinearSolverWrapper(ARKode & solver, - LinearSolveFunction lsolve) + SundialsLinearSolverWrapper(LinearSolveFunction lsolve) { sun_linear_solver = SUNLinSolNewEmpty(); sun_linear_solver->ops->gettype = arkode_linsol_get_type; @@ -515,7 +508,6 @@ namespace SUNDIALS sun_linear_solver->ops->setpreconditioner = arkode_linsol_set_preconditioner; - content.solver = &solver; content.lsolve = lsolve; sun_linear_solver->content = &content; } @@ -811,7 +803,7 @@ namespace SUNDIALS { linear_solver = std::make_unique>( - *this, solve_linearized_system); + solve_linearized_system); sun_linear_solver = linear_solver->get_wrapped_solver(); } else @@ -882,7 +874,7 @@ namespace SUNDIALS { mass_solver = std::make_unique>( - *this, solve_mass); + solve_mass); sun_mass_linear_solver = mass_solver->get_wrapped_solver(); } else @@ -949,11 +941,9 @@ namespace SUNDIALS # if DEAL_II_SUNDIALS_VERSION_GTE(4, 0, 0) template - SundialsOperator::SundialsOperator(ARKode &solver, - void * A_data, - ATimesFn a_times_fn) - : solver(solver) - , A_data(A_data) + SundialsOperator::SundialsOperator(void * A_data, + ATimesFn a_times_fn) + : A_data(A_data) , a_times_fn(a_times_fn) { @@ -978,12 +968,10 @@ namespace SUNDIALS template SundialsPreconditioner::SundialsPreconditioner( - ARKode &solver, - void * P_data, - PSolveFn p_solve_fn, - double tol) - : solver(solver) - , P_data(P_data) + void * P_data, + PSolveFn p_solve_fn, + double tol) + : P_data(P_data) , p_solve_fn(p_solve_fn) , tol(tol) {} diff --git a/tests/sundials/arkode_01.cc b/tests/sundials/arkode_01.cc index 28c49b0378..279f2ee6ad 100644 --- a/tests/sundials/arkode_01.cc +++ b/tests/sundials/arkode_01.cc @@ -76,8 +76,6 @@ main(int argc, char **argv) SUNDIALS::ARKode ode(data); - ode.reinit_vector = [&](VectorType &v) { v.reinit(2); }; - double kappa = 1.0; ode.explicit_function = diff --git a/tests/sundials/arkode_02.cc b/tests/sundials/arkode_02.cc index afae0d877b..8e4d395981 100644 --- a/tests/sundials/arkode_02.cc +++ b/tests/sundials/arkode_02.cc @@ -69,8 +69,6 @@ main(int argc, char **argv) SUNDIALS::ARKode ode(data); - ode.reinit_vector = [&](VectorType &v) { v.reinit(2); }; - double kappa = 1.0; ode.implicit_function = diff --git a/tests/sundials/arkode_03.cc b/tests/sundials/arkode_03.cc index db0a27ce60..0714ac9751 100644 --- a/tests/sundials/arkode_03.cc +++ b/tests/sundials/arkode_03.cc @@ -72,11 +72,6 @@ main(int argc, char **argv) SUNDIALS::ARKode ode(data); - ode.reinit_vector = [&](VectorType &v) { - // Three independent variables - v.reinit(3); - }; - // Parameters double u0 = 3.9, v0 = 1.1, w0 = 2.8, a = 1.2, b = 2.5, eps = 1e-5; diff --git a/tests/sundials/arkode_04.cc b/tests/sundials/arkode_04.cc index 3198c8a57e..04116ad06c 100644 --- a/tests/sundials/arkode_04.cc +++ b/tests/sundials/arkode_04.cc @@ -72,11 +72,6 @@ main(int argc, char **argv) SUNDIALS::ARKode ode(data); - ode.reinit_vector = [&](VectorType &v) { - // Three independent variables - v.reinit(3); - }; - // Parameters double u0 = 3.9, v0 = 1.1, w0 = 2.8, a = 1.2, b = 2.5, eps = 1e-5; // Explicit jacobian. diff --git a/tests/sundials/arkode_05.cc b/tests/sundials/arkode_05.cc index 40339066bd..66d37344f3 100644 --- a/tests/sundials/arkode_05.cc +++ b/tests/sundials/arkode_05.cc @@ -72,11 +72,6 @@ main(int argc, char **argv) SUNDIALS::ARKode ode(data); - ode.reinit_vector = [&](VectorType &v) { - // Three independent variables - v.reinit(3); - }; - // Parameters double u0 = 3.9, v0 = 1.1, w0 = 2.8, a = 1.2, b = 2.5, eps = 1e-5; // Explicit jacobian. diff --git a/tests/sundials/arkode_06.cc b/tests/sundials/arkode_06.cc index 8bd82b01ba..d0f5a69810 100644 --- a/tests/sundials/arkode_06.cc +++ b/tests/sundials/arkode_06.cc @@ -79,11 +79,6 @@ main(int argc, char **argv) SUNDIALS::ARKode ode(data); - ode.reinit_vector = [&](VectorType &v) { - // Three independent variables - v.reinit(3); - }; - // Parameters double u0 = 3.9, v0 = 1.1, w0 = 2.8, a = 1.2, b = 2.5, eps = 1e-5; // Explicit jacobian. diff --git a/tests/sundials/arkode_07.cc b/tests/sundials/arkode_07.cc index cbbb08378a..264099ce4f 100644 --- a/tests/sundials/arkode_07.cc +++ b/tests/sundials/arkode_07.cc @@ -79,11 +79,6 @@ main(int argc, char **argv) SUNDIALS::ARKode ode(data); - ode.reinit_vector = [&](VectorType &v) { - // Three independent variables - v.reinit(3); - }; - // Parameters double u0 = 3.9, v0 = 1.1, w0 = 2.8, a = 1.2, b = 2.5, eps = 1e-5; // Explicit jacobian. diff --git a/tests/sundials/arkode_08.cc b/tests/sundials/arkode_08.cc index 97f8a863b2..7abd387302 100644 --- a/tests/sundials/arkode_08.cc +++ b/tests/sundials/arkode_08.cc @@ -69,8 +69,6 @@ main(int argc, char **argv) SUNDIALS::ARKode ode(data); - ode.reinit_vector = [&](VectorType &v) { v.reinit(2); }; - // Explicit jacobian = stiffness matrix FullMatrix K(2, 2); K(0, 0) = K(1, 1) = 0.5; -- 2.39.5