]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use make_unique/shared in examples 5885/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 10 Feb 2018 14:15:39 +0000 (15:15 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 15 Feb 2018 21:00:31 +0000 (22:00 +0100)
examples/step-14/step-14.cc
examples/step-20/step-20.cc
examples/step-21/step-21.cc
examples/step-22/step-22.cc
examples/step-31/step-31.cc
examples/step-32/step-32.cc
examples/step-43/step-43.cc
examples/step-44/step-44.cc

index 2dff2148d0cc8b4a6cb59d2a1648df84e0b9c5f3..4b249697987a68041abd4498cc80988199f3c759 100644 (file)
@@ -22,6 +22,7 @@
 #include <deal.II/base/quadrature_lib.h>
 #include <deal.II/base/function.h>
 #include <deal.II/base/logstream.h>
+#include <deal.II/base/std_cxx14/memory.h>
 #include <deal.II/base/thread_management.h>
 #include <deal.II/base/work_stream.h>
 #include <deal.II/lac/vector.h>
@@ -54,7 +55,6 @@
 #include <algorithm>
 #include <numeric>
 #include <sstream>
-#include <memory>
 
 // 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<dim> (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<LaplaceSolver::WeightedResidual<dim>>
+                 (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<dim> (triangulation,
-                                                   primal_fe,
-                                                   quadrature,
-                                                   face_quadrature,
-                                                   descriptor.data->get_right_hand_side(),
-                                                   descriptor.data->get_boundary_values()));
+        solver = std_cxx14::make_unique<LaplaceSolver::RefinementGlobal<dim>>
+                 (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<dim> (triangulation,
-                                                  primal_fe,
-                                                  quadrature,
-                                                  face_quadrature,
-                                                  descriptor.data->get_right_hand_side(),
-                                                  descriptor.data->get_boundary_values()));
+        solver = std_cxx14::make_unique<LaplaceSolver::RefinementKelly<dim>>
+                 (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<dim> (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<LaplaceSolver::RefinementWeightedKelly<dim>>
+                 (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 <code>Exercise_2_3</code>, but you can
       // also use <code>CurvedRidges@<dim@></code>:
-      descriptor.data.reset(new Data::SetUp<Data::Exercise_2_3<dim>,dim> ());
+      descriptor.data = std_cxx14::make_unique<Data::SetUp<Data::Exercise_2_3<dim>,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<dim> evaluation_point (0.75, 0.75);
-      descriptor.dual_functional.reset
-      (new DualFunctional::PointValueEvaluation<dim> (evaluation_point));
+      descriptor.dual_functional = std_cxx14::make_unique<DualFunctional::PointValueEvaluation<dim>>
+                                   (evaluation_point);
 
       Evaluation::PointValueEvaluation<dim>
       postprocessor1 (evaluation_point);
index 76f6ca22ec0383720ce2d10caf826cafd67ed492..64361a5f3faad9fce1fb9d8af75f4f9c8d4fe747 100644 (file)
@@ -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<std::size_t> (200)),
+    SolverControl solver_control (std::max<unsigned int>(src.size(), 200),
                                   1e-8*src.l2_norm());
     SolverCG<>    cg (solver_control);
 
index 15e513e0fc4e813b2e8736db541ab88d67c4fe74..5854ee69c1140e18b4b271b202cabf85d0cde7e3 100644 (file)
@@ -487,7 +487,7 @@ namespace Step21
   void InverseMatrix<MatrixType>::vmult (Vector<double>       &dst,
                                          const Vector<double> &src) const
   {
-    SolverControl solver_control (std::max(src.size(), static_cast<std::size_t> (200)),
+    SolverControl solver_control (std::max<unsigned int>(src.size(), 200),
                                   1e-8*src.l2_norm());
     SolverCG<>    cg (solver_control);
 
index 3e0ba48fae320d38f21b712075abf86e1a1cb02f..20442d8c5b78550a53e66c2ef1f112bda7ac08cd 100644 (file)
@@ -66,6 +66,7 @@
 // This is C++:
 #include <iostream>
 #include <fstream>
+#include <memory>
 #include <sstream>
 
 // 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<typename InnerPreconditioner<dim>::type>(new typename InnerPreconditioner<dim>::type());
+      = std::make_shared<typename InnerPreconditioner<dim>::type>();
     A_preconditioner->initialize (system_matrix.block(0,0),
                                   typename InnerPreconditioner<dim>::type::AdditionalData());
 
index b1ae4fc0e14db5b7ef3e3c38f6280cdc7c4a3907..2684fab57efb07a2fca42050efe11beed39156c8 100644 (file)
@@ -69,6 +69,7 @@
 // the aforelisted header files:
 #include <iostream>
 #include <fstream>
+#include <memory>
 #include <sstream>
 #include <limits>
 
@@ -1185,8 +1186,8 @@ namespace Step31
 
     assemble_stokes_preconditioner ();
 
-    Amg_preconditioner = std::shared_ptr<TrilinosWrappers::PreconditionAMG>
-                         (new TrilinosWrappers::PreconditionAMG());
+    Amg_preconditioner = std::make_shared<TrilinosWrappers::PreconditionAMG>
+                         ();
 
     std::vector<std::vector<bool> > 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<TrilinosWrappers::PreconditionIC>
-                        (new TrilinosWrappers::PreconditionIC());
+    Mp_preconditioner = std::make_shared<TrilinosWrappers::PreconditionIC>
+                        ();
     Mp_preconditioner->initialize(stokes_preconditioner_matrix.block(1,1));
 
     std::cout << std::endl;
index bc88b31738ada12a26569f08f35210efd906fdb4..782bff6766049612cc58cd2bd00c8ac9301e036f 100644 (file)
@@ -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<TrilinosWrappers::PreconditionJacobi>();
+    Amg_preconditioner = std::make_shared<TrilinosWrappers::PreconditionAMG>();
 
     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<TrilinosWrappers::PreconditionJacobi>();
         T_preconditioner->initialize (temperature_matrix);
         rebuild_temperature_preconditioner = false;
       }
index e5cd6bc65329a1f95e9d9ab33131cd345d52cd29..774597185117e0e268066cdd670a74a3c63f9586 100644 (file)
@@ -67,6 +67,7 @@
 
 #include <iostream>
 #include <fstream>
+#include <memory>
 #include <sstream>
 #include <memory>
 
@@ -981,12 +982,10 @@ namespace Step43
   {
     assemble_darcy_preconditioner ();
 
-    Amg_preconditioner = std::shared_ptr<TrilinosWrappers::PreconditionIC>
-                         (new TrilinosWrappers::PreconditionIC());
+    Amg_preconditioner = std::make_shared<TrilinosWrappers::PreconditionIC> ();
     Amg_preconditioner->initialize(darcy_preconditioner_matrix.block(0,0));
 
-    Mp_preconditioner = std::shared_ptr<TrilinosWrappers::PreconditionIC>
-                        (new TrilinosWrappers::PreconditionIC());
+    Mp_preconditioner = std::make_shared<TrilinosWrappers::PreconditionIC> ();
     Mp_preconditioner->initialize(darcy_preconditioner_matrix.block(1,1));
 
   }
index 3ca1c3bd8c332c66b5449b5ddf1216d5b43ad219..3da95953242d2dda7a0676376dc6a9e309f3d9e5 100644 (file)
@@ -710,8 +710,8 @@ namespace Step44
     // dilation $\widetilde{J}$ field values.
     void setup_lqp (const Parameters::AllParameters &parameters)
     {
-      material.reset(new Material_Compressible_Neo_Hook_Three_Field<dim>(parameters.mu,
-                     parameters.nu));
+      material = std::make_shared<Material_Compressible_Neo_Hook_Three_Field<dim>>
+                 (parameters.mu, parameters.nu);
       update_values(Tensor<2, dim>(), 0.0, 1.0);
     }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.