From e7cceb1fd419eedf855f2a5d10295c57abb355a4 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sat, 10 Feb 2018 15:15:39 +0100 Subject: [PATCH] Use make_unique/shared in examples --- examples/step-14/step-14.cc | 70 ++++++++++++++++++------------------- examples/step-20/step-20.cc | 2 +- examples/step-21/step-21.cc | 2 +- examples/step-22/step-22.cc | 3 +- examples/step-31/step-31.cc | 9 ++--- examples/step-32/step-32.cc | 6 ++-- examples/step-43/step-43.cc | 7 ++-- examples/step-44/step-44.cc | 4 +-- 8 files changed, 52 insertions(+), 51 deletions(-) diff --git a/examples/step-14/step-14.cc b/examples/step-14/step-14.cc index 2dff2148d0..4b24969798 100644 --- a/examples/step-14/step-14.cc +++ b/examples/step-14/step-14.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -54,7 +55,6 @@ #include #include #include -#include // The last step is as in all previous programs: namespace Step14 @@ -2894,52 +2894,52 @@ namespace Step14 { case ProblemDescription::dual_weighted_error_estimator: { - solver.reset - (new LaplaceSolver::WeightedResidual (triangulation, - primal_fe, - dual_fe, - quadrature, - face_quadrature, - descriptor.data->get_right_hand_side(), - descriptor.data->get_boundary_values(), - *descriptor.dual_functional)); + solver = std_cxx14::make_unique> + (triangulation, + primal_fe, + dual_fe, + quadrature, + face_quadrature, + descriptor.data->get_right_hand_side(), + descriptor.data->get_boundary_values(), + *descriptor.dual_functional); break; } case ProblemDescription::global_refinement: { - solver.reset - (new LaplaceSolver::RefinementGlobal (triangulation, - primal_fe, - quadrature, - face_quadrature, - descriptor.data->get_right_hand_side(), - descriptor.data->get_boundary_values())); + solver = std_cxx14::make_unique> + (triangulation, + primal_fe, + quadrature, + face_quadrature, + descriptor.data->get_right_hand_side(), + descriptor.data->get_boundary_values()); break; } case ProblemDescription::kelly_indicator: { - solver.reset - (new LaplaceSolver::RefinementKelly (triangulation, - primal_fe, - quadrature, - face_quadrature, - descriptor.data->get_right_hand_side(), - descriptor.data->get_boundary_values())); + solver = std_cxx14::make_unique> + (triangulation, + primal_fe, + quadrature, + face_quadrature, + descriptor.data->get_right_hand_side(), + descriptor.data->get_boundary_values()); break; } case ProblemDescription::weighted_kelly_indicator: { - solver.reset - (new LaplaceSolver::RefinementWeightedKelly (triangulation, - primal_fe, - quadrature, - face_quadrature, - descriptor.data->get_right_hand_side(), - descriptor.data->get_boundary_values(), - *descriptor.kelly_weight)); + solver = std_cxx14::make_unique> + (triangulation, + primal_fe, + quadrature, + face_quadrature, + descriptor.data->get_right_hand_side(), + descriptor.data->get_boundary_values(), + *descriptor.kelly_weight); break; } @@ -3025,7 +3025,7 @@ int main () // values, and right hand side. These are prepackaged in classes. We // take here the description of Exercise_2_3, but you can // also use CurvedRidges@: - descriptor.data.reset(new Data::SetUp,dim> ()); + descriptor.data = std_cxx14::make_unique,dim>>(); // Next set first a dual functional, then a list of evaluation // objects. We choose as default the evaluation of the value at an @@ -3041,8 +3041,8 @@ int main () // each step. One such additional evaluation is to output the grid in // each step. const Point evaluation_point (0.75, 0.75); - descriptor.dual_functional.reset - (new DualFunctional::PointValueEvaluation (evaluation_point)); + descriptor.dual_functional = std_cxx14::make_unique> + (evaluation_point); Evaluation::PointValueEvaluation postprocessor1 (evaluation_point); diff --git a/examples/step-20/step-20.cc b/examples/step-20/step-20.cc index 76f6ca22ec..64361a5f3f 100644 --- a/examples/step-20/step-20.cc +++ b/examples/step-20/step-20.cc @@ -598,7 +598,7 @@ namespace Step20 // efficient choice because SolverCG instances allocate memory whenever // they are created; this is just a tutorial so such inefficiencies are // acceptable for the sake of exposition. - SolverControl solver_control (std::max(src.size(), static_cast (200)), + SolverControl solver_control (std::max(src.size(), 200), 1e-8*src.l2_norm()); SolverCG<> cg (solver_control); diff --git a/examples/step-21/step-21.cc b/examples/step-21/step-21.cc index 15e513e0fc..5854ee69c1 100644 --- a/examples/step-21/step-21.cc +++ b/examples/step-21/step-21.cc @@ -487,7 +487,7 @@ namespace Step21 void InverseMatrix::vmult (Vector &dst, const Vector &src) const { - SolverControl solver_control (std::max(src.size(), static_cast (200)), + SolverControl solver_control (std::max(src.size(), 200), 1e-8*src.l2_norm()); SolverCG<> cg (solver_control); diff --git a/examples/step-22/step-22.cc b/examples/step-22/step-22.cc index 3e0ba48fae..20442d8c5b 100644 --- a/examples/step-22/step-22.cc +++ b/examples/step-22/step-22.cc @@ -66,6 +66,7 @@ // This is C++: #include #include +#include #include // As in all programs, the namespace dealii is included: @@ -715,7 +716,7 @@ namespace Step22 std::cout << " Computing preconditioner..." << std::endl << std::flush; A_preconditioner - = std::shared_ptr::type>(new typename InnerPreconditioner::type()); + = std::make_shared::type>(); A_preconditioner->initialize (system_matrix.block(0,0), typename InnerPreconditioner::type::AdditionalData()); diff --git a/examples/step-31/step-31.cc b/examples/step-31/step-31.cc index b1ae4fc0e1..2684fab57e 100644 --- a/examples/step-31/step-31.cc +++ b/examples/step-31/step-31.cc @@ -69,6 +69,7 @@ // the aforelisted header files: #include #include +#include #include #include @@ -1185,8 +1186,8 @@ namespace Step31 assemble_stokes_preconditioner (); - Amg_preconditioner = std::shared_ptr - (new TrilinosWrappers::PreconditionAMG()); + Amg_preconditioner = std::make_shared + (); std::vector > constant_modes; FEValuesExtractors::Vector velocity_components(0); @@ -1232,8 +1233,8 @@ namespace Step31 Amg_preconditioner->initialize(stokes_preconditioner_matrix.block(0,0), amg_data); - Mp_preconditioner = std::shared_ptr - (new TrilinosWrappers::PreconditionIC()); + Mp_preconditioner = std::make_shared + (); Mp_preconditioner->initialize(stokes_preconditioner_matrix.block(1,1)); std::cout << std::endl; diff --git a/examples/step-32/step-32.cc b/examples/step-32/step-32.cc index bc88b31738..782bff6766 100644 --- a/examples/step-32/step-32.cc +++ b/examples/step-32/step-32.cc @@ -2328,8 +2328,8 @@ namespace Step32 stokes_fe.component_mask(velocity_components), constant_modes); - Mp_preconditioner.reset (new TrilinosWrappers::PreconditionJacobi()); - Amg_preconditioner.reset (new TrilinosWrappers::PreconditionAMG()); + Mp_preconditioner = std::make_shared(); + Amg_preconditioner = std::make_shared(); TrilinosWrappers::PreconditionAMG::AdditionalData Amg_data; Amg_data.constant_modes = constant_modes; @@ -2854,7 +2854,7 @@ namespace Step32 if (rebuild_temperature_preconditioner == true) { - T_preconditioner.reset (new TrilinosWrappers::PreconditionJacobi()); + T_preconditioner = std::make_shared(); T_preconditioner->initialize (temperature_matrix); rebuild_temperature_preconditioner = false; } diff --git a/examples/step-43/step-43.cc b/examples/step-43/step-43.cc index e5cd6bc653..7745971851 100644 --- a/examples/step-43/step-43.cc +++ b/examples/step-43/step-43.cc @@ -67,6 +67,7 @@ #include #include +#include #include #include @@ -981,12 +982,10 @@ namespace Step43 { assemble_darcy_preconditioner (); - Amg_preconditioner = std::shared_ptr - (new TrilinosWrappers::PreconditionIC()); + Amg_preconditioner = std::make_shared (); Amg_preconditioner->initialize(darcy_preconditioner_matrix.block(0,0)); - Mp_preconditioner = std::shared_ptr - (new TrilinosWrappers::PreconditionIC()); + Mp_preconditioner = std::make_shared (); Mp_preconditioner->initialize(darcy_preconditioner_matrix.block(1,1)); } diff --git a/examples/step-44/step-44.cc b/examples/step-44/step-44.cc index 3ca1c3bd8c..3da9595324 100644 --- a/examples/step-44/step-44.cc +++ b/examples/step-44/step-44.cc @@ -710,8 +710,8 @@ namespace Step44 // dilation $\widetilde{J}$ field values. void setup_lqp (const Parameters::AllParameters ¶meters) { - material.reset(new Material_Compressible_Neo_Hook_Three_Field(parameters.mu, - parameters.nu)); + material = std::make_shared> + (parameters.mu, parameters.nu); update_values(Tensor<2, dim>(), 0.0, 1.0); } -- 2.39.5