From: Wolfgang Bangerth Date: Wed, 17 Mar 2021 08:59:22 +0000 (+0100) Subject: Move implementation of functions into the .cc file. X-Git-Tag: v9.3.0-rc1~308^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c0ab44c87921b90aab631b1603212722262f6e4;p=dealii.git Move implementation of functions into the .cc file. --- diff --git a/include/deal.II/sundials/kinsol.h b/include/deal.II/sundials/kinsol.h index c801f28fec..82ba7f519c 100644 --- a/include/deal.II/sundials/kinsol.h +++ b/include/deal.II/sundials/kinsol.h @@ -253,7 +253,7 @@ namespace SUNDIALS * @param dq_relative_error Relative error for different quotient * computation * - * Linesearch parameters: + * Line search parameters: * * @param maximum_beta_failures Maximum number of beta-condition failures * @@ -261,29 +261,16 @@ namespace SUNDIALS * * @param anderson_subspace_size Anderson acceleration subspace size */ - AdditionalData( - // Global parameters - const SolutionStrategy &strategy = linesearch, - const unsigned int maximum_non_linear_iterations = 200, - const double function_tolerance = 0.0, - const double step_tolerance = 0.0, - const bool no_init_setup = false, - const unsigned int maximum_setup_calls = 0, - const double maximum_newton_step = 0.0, - const double dq_relative_error = 0.0, - const unsigned int maximum_beta_failures = 0, - const unsigned int anderson_subspace_size = 0) - : strategy(strategy) - , maximum_non_linear_iterations(maximum_non_linear_iterations) - , function_tolerance(function_tolerance) - , step_tolerance(step_tolerance) - , no_init_setup(no_init_setup) - , maximum_setup_calls(maximum_setup_calls) - , maximum_newton_step(maximum_newton_step) - , dq_relative_error(dq_relative_error) - , maximum_beta_failures(maximum_beta_failures) - , anderson_subspace_size(anderson_subspace_size) - {} + AdditionalData(const SolutionStrategy &strategy = linesearch, + const unsigned int maximum_non_linear_iterations = 200, + const double function_tolerance = 0.0, + const double step_tolerance = 0.0, + const bool no_init_setup = false, + const unsigned int maximum_setup_calls = 0, + const double maximum_newton_step = 0.0, + const double dq_relative_error = 0.0, + const unsigned int maximum_beta_failures = 0, + const unsigned int anderson_subspace_size = 0); /** * Add all AdditionalData() parameters to the given ParameterHandler @@ -324,53 +311,7 @@ namespace SUNDIALS * using `prm`. */ void - add_parameters(ParameterHandler &prm) - { - static std::string strategy_str("newton"); - prm.add_parameter("Solution strategy", - strategy_str, - "Choose among newton|linesearch|fixed_point|picard", - Patterns::Selection( - "newton|linesearch|fixed_point|picard")); - prm.add_action("Solution strategy", [&](const std::string &value) { - if (value == "newton") - strategy = newton; - else if (value == "linesearch") - strategy = linesearch; - else if (value == "fixed_point") - strategy = fixed_point; - else if (value == "picard") - strategy = picard; - else - Assert(false, ExcInternalError()); - }); - prm.add_parameter("Maximum number of nonlinear iterations", - maximum_non_linear_iterations); - prm.add_parameter("Function norm stopping tolerance", - function_tolerance); - prm.add_parameter("Scaled step stopping tolerance", step_tolerance); - - prm.enter_subsection("Newton parameters"); - prm.add_parameter("No initial matrix setup", no_init_setup); - prm.add_parameter("Maximum iterations without matrix setup", - maximum_setup_calls); - prm.add_parameter("Maximum allowable scaled length of the Newton step", - maximum_newton_step); - prm.add_parameter("Relative error for different quotient computation", - dq_relative_error); - prm.leave_subsection(); - - prm.enter_subsection("Linesearch parameters"); - prm.add_parameter("Maximum number of beta-condition failures", - maximum_beta_failures); - prm.leave_subsection(); - - - prm.enter_subsection("Fixed point and Picard parameters"); - prm.add_parameter("Anderson acceleration subspace size", - anderson_subspace_size); - prm.leave_subsection(); - } + add_parameters(ParameterHandler &prm); /** * The solution strategy to use. If you choose SolutionStrategy::newton diff --git a/source/sundials/kinsol.cc b/source/sundials/kinsol.cc index 695532c353..9e7d553242 100644 --- a/source/sundials/kinsol.cc +++ b/source/sundials/kinsol.cc @@ -52,6 +52,83 @@ namespace SUNDIALS { using namespace internal; + + template + KINSOL::AdditionalData::AdditionalData( + const SolutionStrategy &strategy, + const unsigned int maximum_non_linear_iterations, + const double function_tolerance, + const double step_tolerance, + const bool no_init_setup, + const unsigned int maximum_setup_calls, + const double maximum_newton_step, + const double dq_relative_error, + const unsigned int maximum_beta_failures, + const unsigned int anderson_subspace_size) + : strategy(strategy) + , maximum_non_linear_iterations(maximum_non_linear_iterations) + , function_tolerance(function_tolerance) + , step_tolerance(step_tolerance) + , no_init_setup(no_init_setup) + , maximum_setup_calls(maximum_setup_calls) + , maximum_newton_step(maximum_newton_step) + , dq_relative_error(dq_relative_error) + , maximum_beta_failures(maximum_beta_failures) + , anderson_subspace_size(anderson_subspace_size) + {} + + + + template + void + KINSOL::AdditionalData::add_parameters(ParameterHandler &prm) + { + static std::string strategy_str("newton"); + prm.add_parameter("Solution strategy", + strategy_str, + "Choose among newton|linesearch|fixed_point|picard", + Patterns::Selection( + "newton|linesearch|fixed_point|picard")); + prm.add_action("Solution strategy", [&](const std::string &value) { + if (value == "newton") + strategy = newton; + else if (value == "linesearch") + strategy = linesearch; + else if (value == "fixed_point") + strategy = fixed_point; + else if (value == "picard") + strategy = picard; + else + Assert(false, ExcInternalError()); + }); + prm.add_parameter("Maximum number of nonlinear iterations", + maximum_non_linear_iterations); + prm.add_parameter("Function norm stopping tolerance", function_tolerance); + prm.add_parameter("Scaled step stopping tolerance", step_tolerance); + + prm.enter_subsection("Newton parameters"); + prm.add_parameter("No initial matrix setup", no_init_setup); + prm.add_parameter("Maximum iterations without matrix setup", + maximum_setup_calls); + prm.add_parameter("Maximum allowable scaled length of the Newton step", + maximum_newton_step); + prm.add_parameter("Relative error for different quotient computation", + dq_relative_error); + prm.leave_subsection(); + + prm.enter_subsection("Linesearch parameters"); + prm.add_parameter("Maximum number of beta-condition failures", + maximum_beta_failures); + prm.leave_subsection(); + + + prm.enter_subsection("Fixed point and Picard parameters"); + prm.add_parameter("Anderson acceleration subspace size", + anderson_subspace_size); + prm.leave_subsection(); + } + + namespace { template