From e29b17798f018343ed99257101b846798cab88ae Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Wed, 9 Sep 2015 21:08:45 -0400 Subject: [PATCH] make AdditionalData ctor explicit Constructors of AdditionalData in various linear solvers are now marked explicit. This is to avoid implicit conversions from int. See #1571 for an example where an MPI communiator (which is an int) is silently converted because of the default values in AdditionalData. --- include/deal.II/lac/petsc_solver.h | 1 + include/deal.II/lac/solver_bicgstab.h | 7 ++++--- include/deal.II/lac/solver_cg.h | 1 + include/deal.II/lac/solver_gmres.h | 2 ++ include/deal.II/lac/solver_qmrs.h | 1 + include/deal.II/lac/solver_richardson.h | 1 + include/deal.II/lac/trilinos_solver.h | 7 +++++++ 7 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/deal.II/lac/petsc_solver.h b/include/deal.II/lac/petsc_solver.h index 299bd3f929..a27e1aa429 100644 --- a/include/deal.II/lac/petsc_solver.h +++ b/include/deal.II/lac/petsc_solver.h @@ -254,6 +254,7 @@ namespace PETScWrappers /** * Constructor. By default, set the damping parameter to one. */ + explicit AdditionalData (const double omega = 1); /** diff --git a/include/deal.II/lac/solver_bicgstab.h b/include/deal.II/lac/solver_bicgstab.h index 7a23a3824f..325a81331c 100644 --- a/include/deal.II/lac/solver_bicgstab.h +++ b/include/deal.II/lac/solver_bicgstab.h @@ -90,10 +90,11 @@ public: * The default is to perform an exact residual computation and breakdown * parameter 1e-10. */ + explicit AdditionalData(const bool exact_residual = true, - const double breakdown = 1.e-10) : - exact_residual(exact_residual), - breakdown(breakdown) + const double breakdown = 1.e-10) + : exact_residual(exact_residual), + breakdown(breakdown) {} /** * Flag for exact computation of residual. diff --git a/include/deal.II/lac/solver_cg.h b/include/deal.II/lac/solver_cg.h index de0bc89539..c11f6f52e8 100644 --- a/include/deal.II/lac/solver_cg.h +++ b/include/deal.II/lac/solver_cg.h @@ -141,6 +141,7 @@ public: * @deprecated Instead use: connect_coefficients_slot, * connect_condition_number_slot, and connect_eigenvalues_slot. */ + explicit AdditionalData (const bool log_coefficients, const bool compute_condition_number = false, const bool compute_all_condition_numbers = false, diff --git a/include/deal.II/lac/solver_gmres.h b/include/deal.II/lac/solver_gmres.h index c37f941d1a..c149c95612 100644 --- a/include/deal.II/lac/solver_gmres.h +++ b/include/deal.II/lac/solver_gmres.h @@ -184,6 +184,7 @@ public: * left, the residual of the stopping criterion to the default residual, * and re-orthogonalization only if necessary. */ + explicit AdditionalData (const unsigned int max_n_tmp_vectors = 30, const bool right_preconditioning = false, const bool use_default_residual = true, @@ -421,6 +422,7 @@ public: /** * Constructor. By default, set the maximum basis size to 30. */ + explicit AdditionalData(const unsigned int max_basis_size = 30, const bool /*use_default_residual*/ = true) : diff --git a/include/deal.II/lac/solver_qmrs.h b/include/deal.II/lac/solver_qmrs.h index 5706828ee4..0f41712aec 100644 --- a/include/deal.II/lac/solver_qmrs.h +++ b/include/deal.II/lac/solver_qmrs.h @@ -90,6 +90,7 @@ public: * The default is no exact residual computation and breakdown parameter * 1e-16. */ + explicit AdditionalData(bool exact_residual = false, double breakdown=1.e-16) : exact_residual(exact_residual), diff --git a/include/deal.II/lac/solver_richardson.h b/include/deal.II/lac/solver_richardson.h index 71376143f7..e96c3f1b9e 100644 --- a/include/deal.II/lac/solver_richardson.h +++ b/include/deal.II/lac/solver_richardson.h @@ -69,6 +69,7 @@ public: /** * Constructor. By default, set the damping parameter to one. */ + explicit AdditionalData (const double omega = 1, const bool use_preconditioned_residual = false); diff --git a/include/deal.II/lac/trilinos_solver.h b/include/deal.II/lac/trilinos_solver.h index fda44afe05..9ab13fc2aa 100644 --- a/include/deal.II/lac/trilinos_solver.h +++ b/include/deal.II/lac/trilinos_solver.h @@ -90,6 +90,7 @@ namespace TrilinosWrappers * it is quite inelegant to set a specific option of one solver in the * base class for all solvers. */ + explicit AdditionalData (const bool output_solver_details = false, const unsigned int gmres_restart_parameter = 30); @@ -276,6 +277,7 @@ namespace TrilinosWrappers /** * Sets the additional data field to the desired output format. */ + explicit AdditionalData (const bool output_solver_details = false); /** @@ -321,6 +323,7 @@ namespace TrilinosWrappers /** * Sets the additional data field to the desired output format. */ + explicit AdditionalData (const bool output_solver_details = false); /** @@ -367,6 +370,7 @@ namespace TrilinosWrappers * Constructor. By default, set the number of temporary vectors to 30, * i.e. do a restart every 30 iterations. */ + explicit AdditionalData (const bool output_solver_details = false, const unsigned int restart_parameter = 30); @@ -419,6 +423,7 @@ namespace TrilinosWrappers /** * Sets the additional data field to the desired output format. */ + explicit AdditionalData (const bool output_solver_details = false); /** @@ -465,6 +470,7 @@ namespace TrilinosWrappers /** * Sets the additional data field to the desired output format. */ + explicit AdditionalData (const bool output_solver_details = false); /** @@ -519,6 +525,7 @@ namespace TrilinosWrappers /** * Sets the additional data field to the desired output format. */ + explicit AdditionalData (const bool output_solver_details = false, const std::string &solver_type = "Amesos_Klu"); -- 2.39.5