From: Jean-Paul Pelteret Date: Mon, 6 May 2019 19:24:23 +0000 (+0200) Subject: Fix some failing AD tests. X-Git-Tag: v9.1.0-rc1~123^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbdb593b9c928cb44b4628cc309c6fcd026353f4;p=dealii.git Fix some failing AD tests. This targets issues picked up by compiling with -Werror --- diff --git a/tests/ad_common_tests/physics_functions_03.h b/tests/ad_common_tests/physics_functions_03.h index e2dd5a0d33..17da5488c1 100644 --- a/tests/ad_common_tests/physics_functions_03.h +++ b/tests/ad_common_tests/physics_functions_03.h @@ -48,12 +48,12 @@ test_physics() Tensor<2, dim, ADNumberType> grad_u; const Tensor<2, dim, ADNumberType> F = Physics::Elasticity::Kinematics::F(grad_u); - const Tensor<1, dim, ADNumberType> N; - const Tensor<1, dim, ADNumberType> V; - const Tensor<2, dim, ADNumberType> T1; - const SymmetricTensor<2, dim, ADNumberType> T2; - const Tensor<4, dim, ADNumberType> TT1; - const SymmetricTensor<4, dim, ADNumberType> TT2; + const Tensor<1, dim, ADNumberType> N{}; + const Tensor<1, dim, ADNumberType> V{}; + const Tensor<2, dim, ADNumberType> T1{}; + const SymmetricTensor<2, dim, ADNumberType> T2{}; + const Tensor<4, dim, ADNumberType> TT1{}; + const SymmetricTensor<4, dim, ADNumberType> TT2{}; const Tensor<1, dim, ADNumberType> ddet_F_dC = Physics::Transformations::nansons_formula(N, F); diff --git a/tests/ad_common_tests/step-44-helper_res_lin_01.h b/tests/ad_common_tests/step-44-helper_res_lin_01.h index b0059c1c7c..32dd901bdd 100644 --- a/tests/ad_common_tests/step-44-helper_res_lin_01.h +++ b/tests/ad_common_tests/step-44-helper_res_lin_01.h @@ -184,7 +184,6 @@ namespace Step44 { std::string type_lin; double tol_lin; - double max_iterations_lin; bool use_static_condensation; std::string preconditioner_type; double preconditioner_relaxation; @@ -206,11 +205,6 @@ namespace Step44 "1e-6", Patterns::Double(0.0), "Linear solver residual (scaled by residual norm)"); - prm.declare_entry( - "Max iteration multiplier", - "1", - Patterns::Double(0.0), - "Linear solver iterations (multiples of the system matrix size)"); prm.declare_entry("Use static condensation", "true", Patterns::Bool(), @@ -233,7 +227,6 @@ namespace Step44 { type_lin = prm.get("Solver type"); tol_lin = prm.get_double("Residual"); - max_iterations_lin = prm.get_double("Max iteration multiplier"); use_static_condensation = prm.get_bool("Use static condensation"); preconditioner_type = prm.get("Preconditioner type"); preconditioner_relaxation = prm.get_double("Preconditioner relaxation"); @@ -1574,9 +1567,7 @@ namespace Step44 std::cout << " SLV " << std::flush; if (parameters.type_lin == "CG") { - const auto solver_its = static_cast( - tangent_matrix.block(u_dof, u_dof).m() * - parameters.max_iterations_lin); + const auto solver_its = tangent_matrix.block(u_dof, u_dof).m(); const double tol_sol = parameters.tol_lin * system_rhs.block(u_dof).l2_norm(); SolverControl solver_control(solver_its, tol_sol, false, false); @@ -1657,8 +1648,7 @@ namespace Step44 preconditioner_K_Jp_inv.use_matrix( tangent_matrix.block(J_dof, p_dof)); ReductionControl solver_control_K_Jp_inv( - static_cast(tangent_matrix.block(J_dof, p_dof).m() * - parameters.max_iterations_lin), + tangent_matrix.block(J_dof, p_dof).m(), 1.0e-30, parameters.tol_lin); SolverSelector> solver_K_Jp_inv; @@ -1676,8 +1666,7 @@ namespace Step44 preconditioner_K_con_inv.use_matrix( tangent_matrix.block(u_dof, u_dof)); ReductionControl solver_control_K_con_inv( - static_cast(tangent_matrix.block(u_dof, u_dof).m() * - parameters.max_iterations_lin), + tangent_matrix.block(u_dof, u_dof).m(), 1.0e-30, parameters.tol_lin); SolverSelector> solver_K_con_inv; diff --git a/tests/ad_common_tests/step-44-helper_scalar_01.h b/tests/ad_common_tests/step-44-helper_scalar_01.h index 4e80e4372d..5d2949238d 100644 --- a/tests/ad_common_tests/step-44-helper_scalar_01.h +++ b/tests/ad_common_tests/step-44-helper_scalar_01.h @@ -186,7 +186,6 @@ namespace Step44 { std::string type_lin; double tol_lin; - double max_iterations_lin; bool use_static_condensation; std::string preconditioner_type; double preconditioner_relaxation; @@ -208,11 +207,6 @@ namespace Step44 "1e-6", Patterns::Double(0.0), "Linear solver residual (scaled by residual norm)"); - prm.declare_entry( - "Max iteration multiplier", - "1", - Patterns::Double(0.0), - "Linear solver iterations (multiples of the system matrix size)"); prm.declare_entry("Use static condensation", "true", Patterns::Bool(), @@ -235,7 +229,6 @@ namespace Step44 { type_lin = prm.get("Solver type"); tol_lin = prm.get_double("Residual"); - max_iterations_lin = prm.get_double("Max iteration multiplier"); use_static_condensation = prm.get_bool("Use static condensation"); preconditioner_type = prm.get("Preconditioner type"); preconditioner_relaxation = prm.get_double("Preconditioner relaxation"); @@ -2107,8 +2100,8 @@ namespace Step44 std::cout << " SLV " << std::flush; if (parameters.type_lin == "CG") { - const int solver_its = tangent_matrix.block(u_dof, u_dof).m() * - parameters.max_iterations_lin; + const unsigned int solver_its = + tangent_matrix.block(u_dof, u_dof).m(); const double tol_sol = parameters.tol_lin * system_rhs.block(u_dof).l2_norm(); SolverControl solver_control(solver_its, tol_sol, false, false); @@ -2189,8 +2182,7 @@ namespace Step44 preconditioner_K_Jp_inv.use_matrix( tangent_matrix.block(J_dof, p_dof)); ReductionControl solver_control_K_Jp_inv( - tangent_matrix.block(J_dof, p_dof).m() * - parameters.max_iterations_lin, + tangent_matrix.block(J_dof, p_dof).m(), 1.0e-30, parameters.tol_lin); SolverSelector> solver_K_Jp_inv; @@ -2208,8 +2200,7 @@ namespace Step44 preconditioner_K_con_inv.use_matrix( tangent_matrix.block(u_dof, u_dof)); ReductionControl solver_control_K_con_inv( - tangent_matrix.block(u_dof, u_dof).m() * - parameters.max_iterations_lin, + tangent_matrix.block(u_dof, u_dof).m(), 1.0e-30, parameters.tol_lin); SolverSelector> solver_K_con_inv; diff --git a/tests/ad_common_tests/step-44-helper_var_form_01.h b/tests/ad_common_tests/step-44-helper_var_form_01.h index 8e2da6205b..302053e0d9 100644 --- a/tests/ad_common_tests/step-44-helper_var_form_01.h +++ b/tests/ad_common_tests/step-44-helper_var_form_01.h @@ -184,7 +184,6 @@ namespace Step44 { std::string type_lin; double tol_lin; - double max_iterations_lin; bool use_static_condensation; std::string preconditioner_type; double preconditioner_relaxation; @@ -206,11 +205,6 @@ namespace Step44 "1e-6", Patterns::Double(0.0), "Linear solver residual (scaled by residual norm)"); - prm.declare_entry( - "Max iteration multiplier", - "1", - Patterns::Double(0.0), - "Linear solver iterations (multiples of the system matrix size)"); prm.declare_entry("Use static condensation", "true", Patterns::Bool(), @@ -233,7 +227,6 @@ namespace Step44 { type_lin = prm.get("Solver type"); tol_lin = prm.get_double("Residual"); - max_iterations_lin = prm.get_double("Max iteration multiplier"); use_static_condensation = prm.get_bool("Use static condensation"); preconditioner_type = prm.get("Preconditioner type"); preconditioner_relaxation = prm.get_double("Preconditioner relaxation"); @@ -1500,9 +1493,8 @@ namespace Step44 std::cout << " SLV " << std::flush; if (parameters.type_lin == "CG") { - const auto solver_its = static_cast( - tangent_matrix.block(u_dof, u_dof).m() * - parameters.max_iterations_lin); + const unsigned int solver_its = + tangent_matrix.block(u_dof, u_dof).m(); const double tol_sol = parameters.tol_lin * system_rhs.block(u_dof).l2_norm(); SolverControl solver_control(solver_its, tol_sol, false, false); @@ -1583,8 +1575,7 @@ namespace Step44 preconditioner_K_Jp_inv.use_matrix( tangent_matrix.block(J_dof, p_dof)); ReductionControl solver_control_K_Jp_inv( - static_cast(tangent_matrix.block(J_dof, p_dof).m() * - parameters.max_iterations_lin), + tangent_matrix.block(J_dof, p_dof).m(), 1.0e-30, parameters.tol_lin); SolverSelector> solver_K_Jp_inv; @@ -1602,8 +1593,7 @@ namespace Step44 preconditioner_K_con_inv.use_matrix( tangent_matrix.block(u_dof, u_dof)); ReductionControl solver_control_K_con_inv( - static_cast(tangent_matrix.block(u_dof, u_dof).m() * - parameters.max_iterations_lin), + tangent_matrix.block(u_dof, u_dof).m(), 1.0e-30, parameters.tol_lin); SolverSelector> solver_K_con_inv; diff --git a/tests/ad_common_tests/step-44-helper_vector_01.h b/tests/ad_common_tests/step-44-helper_vector_01.h index a011e3145f..546c449b97 100644 --- a/tests/ad_common_tests/step-44-helper_vector_01.h +++ b/tests/ad_common_tests/step-44-helper_vector_01.h @@ -186,7 +186,6 @@ namespace Step44 { std::string type_lin; double tol_lin; - double max_iterations_lin; bool use_static_condensation; std::string preconditioner_type; double preconditioner_relaxation; @@ -208,11 +207,6 @@ namespace Step44 "1e-6", Patterns::Double(0.0), "Linear solver residual (scaled by residual norm)"); - prm.declare_entry( - "Max iteration multiplier", - "1", - Patterns::Double(0.0), - "Linear solver iterations (multiples of the system matrix size)"); prm.declare_entry("Use static condensation", "true", Patterns::Bool(), @@ -235,7 +229,6 @@ namespace Step44 { type_lin = prm.get("Solver type"); tol_lin = prm.get_double("Residual"); - max_iterations_lin = prm.get_double("Max iteration multiplier"); use_static_condensation = prm.get_bool("Use static condensation"); preconditioner_type = prm.get("Preconditioner type"); preconditioner_relaxation = prm.get_double("Preconditioner relaxation"); @@ -1594,8 +1587,8 @@ namespace Step44 std::cout << " SLV " << std::flush; if (parameters.type_lin == "CG") { - const int solver_its = tangent_matrix.block(u_dof, u_dof).m() * - parameters.max_iterations_lin; + const unsigned int solver_its = + tangent_matrix.block(u_dof, u_dof).m(); const double tol_sol = parameters.tol_lin * system_rhs.block(u_dof).l2_norm(); SolverControl solver_control(solver_its, tol_sol, false, false); @@ -1676,8 +1669,7 @@ namespace Step44 preconditioner_K_Jp_inv.use_matrix( tangent_matrix.block(J_dof, p_dof)); ReductionControl solver_control_K_Jp_inv( - tangent_matrix.block(J_dof, p_dof).m() * - parameters.max_iterations_lin, + tangent_matrix.block(J_dof, p_dof).m(), 1.0e-30, parameters.tol_lin); SolverSelector> solver_K_Jp_inv; @@ -1695,8 +1687,7 @@ namespace Step44 preconditioner_K_con_inv.use_matrix( tangent_matrix.block(u_dof, u_dof)); ReductionControl solver_control_K_con_inv( - tangent_matrix.block(u_dof, u_dof).m() * - parameters.max_iterations_lin, + tangent_matrix.block(u_dof, u_dof).m(), 1.0e-30, parameters.tol_lin); SolverSelector> solver_K_con_inv; diff --git a/tests/ad_common_tests/symmetric_tensor_functions_01.h b/tests/ad_common_tests/symmetric_tensor_functions_01.h index c88c077bf2..4a0bf316fe 100644 --- a/tests/ad_common_tests/symmetric_tensor_functions_01.h +++ b/tests/ad_common_tests/symmetric_tensor_functions_01.h @@ -42,7 +42,7 @@ test_symmetric_tensor() << "Type code: " << static_cast(ad_type_code) << std::endl; const ADNumberType a = 1.0; - const Tensor<1, dim, ADNumberType> v; + const Tensor<1, dim, ADNumberType> v{}; const SymmetricTensor<2, dim, ADNumberType> A( unit_symmetric_tensor()); const SymmetricTensor<2, dim, ADNumberType> B( diff --git a/tests/ad_common_tests/tensor_functions_01.h b/tests/ad_common_tests/tensor_functions_01.h index 4b4c819dca..9a81bb4094 100644 --- a/tests/ad_common_tests/tensor_functions_01.h +++ b/tests/ad_common_tests/tensor_functions_01.h @@ -41,8 +41,8 @@ test_tensor() << "Type code: " << static_cast(ad_type_code) << std::endl; const ADNumberType a = 1.0; - const Tensor<1, dim, ADNumberType> v1; - const Tensor<1, dim, ADNumberType> v2; + const Tensor<1, dim, ADNumberType> v1{}; + const Tensor<1, dim, ADNumberType> v2{}; const Tensor<2, dim, ADNumberType> A( unit_symmetric_tensor()); const Tensor<2, dim, ADNumberType> B( diff --git a/tests/adolc/prm/parameters-step-44.prm b/tests/adolc/prm/parameters-step-44.prm index db26cc1572..de1fa049f6 100644 --- a/tests/adolc/prm/parameters-step-44.prm +++ b/tests/adolc/prm/parameters-step-44.prm @@ -22,10 +22,6 @@ end subsection Linear solver - # Linear solver iterations (multiples of the system matrix size) - # In 2-d, this value is best set at 2. In 3-d, a value of 1 work fine. - set Max iteration multiplier = 2 - # Linear solver residual (scaled by residual norm) set Residual = 1e-6 diff --git a/tests/sacado/prm/parameters-step-44.prm b/tests/sacado/prm/parameters-step-44.prm index db26cc1572..de1fa049f6 100644 --- a/tests/sacado/prm/parameters-step-44.prm +++ b/tests/sacado/prm/parameters-step-44.prm @@ -22,10 +22,6 @@ end subsection Linear solver - # Linear solver iterations (multiples of the system matrix size) - # In 2-d, this value is best set at 2. In 3-d, a value of 1 work fine. - set Max iteration multiplier = 2 - # Linear solver residual (scaled by residual norm) set Residual = 1e-6