]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Wrap some more calls to delete with unique_ptr. 10860/head
authorDavid Wells <drwells@email.unc.edu>
Sat, 29 Aug 2020 23:16:29 +0000 (19:16 -0400)
committerDavid Wells <drwells@email.unc.edu>
Mon, 31 Aug 2020 13:01:44 +0000 (09:01 -0400)
source/fe/fe_abf.cc
source/grid/grid_out.cc

index 0b11c719cf7876577a4e35f212f48e3c78ace016..c520643813e9f9e37d22cc80e2b7807bbb73a45a 100644 (file)
@@ -177,7 +177,7 @@ FE_ABF<dim>::initialize_support_points(const unsigned int deg)
 
   // These might be required when the faces contribution is computed
   // Therefore they will be initialized at this point.
-  std::vector<AnisotropicPolynomials<dim> *> polynomials_abf(dim);
+  std::array<std::unique_ptr<AnisotropicPolynomials<dim>>, dim> polynomials_abf;
 
   // Generate x_1^{i} x_2^{r+1} ...
   for (unsigned int dd = 0; dd < dim; ++dd)
@@ -187,7 +187,7 @@ FE_ABF<dim>::initialize_support_points(const unsigned int deg)
         poly[d].push_back(Polynomials::Monomial<double>(deg + 1));
       poly[dd] = Polynomials::Monomial<double>::generate_complete_basis(deg);
 
-      polynomials_abf[dd] = new AnisotropicPolynomials<dim>(poly);
+      polynomials_abf[dd] = std::make_unique<AnisotropicPolynomials<dim>>(poly);
     }
 
   // Number of the point being entered
@@ -253,7 +253,7 @@ FE_ABF<dim>::initialize_support_points(const unsigned int deg)
   // space D_xi Q_k
   if (deg > 0)
     {
-      std::vector<AnisotropicPolynomials<dim> *> polynomials(dim);
+      std::array<std::unique_ptr<AnisotropicPolynomials<dim>>, dim> polynomials;
 
       for (unsigned int dd = 0; dd < dim; ++dd)
         {
@@ -262,7 +262,7 @@ FE_ABF<dim>::initialize_support_points(const unsigned int deg)
             poly[d] = Polynomials::Legendre::generate_complete_basis(deg);
           poly[dd] = Polynomials::Legendre::generate_complete_basis(deg - 1);
 
-          polynomials[dd] = new AnisotropicPolynomials<dim>(poly);
+          polynomials[dd] = std::make_unique<AnisotropicPolynomials<dim>>(poly);
         }
 
       interior_weights.reinit(
@@ -276,9 +276,6 @@ FE_ABF<dim>::initialize_support_points(const unsigned int deg)
                 cell_quadrature.weight(k) *
                 polynomials[d]->compute_value(i, cell_quadrature.point(k));
         }
-
-      for (unsigned int d = 0; d < dim; ++d)
-        delete polynomials[d];
     }
 
 
@@ -311,9 +308,6 @@ FE_ABF<dim>::initialize_support_points(const unsigned int deg)
         }
     }
 
-  for (unsigned int d = 0; d < dim; ++d)
-    delete polynomials_abf[d];
-
   Assert(current == this->generalized_support_points.size(),
          ExcInternalError());
 }
@@ -421,7 +415,7 @@ FE_ABF<dim>::initialize_restriction()
   // Create Legendre basis for the
   // space D_xi Q_k. Here, we cannot
   // use the shape functions
-  std::vector<AnisotropicPolynomials<dim> *> polynomials(dim);
+  std::array<std::unique_ptr<AnisotropicPolynomials<dim>>, dim> polynomials;
   for (unsigned int dd = 0; dd < dim; ++dd)
     {
       std::vector<std::vector<Polynomials::Polynomial<double>>> poly(dim);
@@ -429,7 +423,7 @@ FE_ABF<dim>::initialize_restriction()
         poly[d] = Polynomials::Legendre::generate_complete_basis(rt_order);
       poly[dd] = Polynomials::Legendre::generate_complete_basis(rt_order - 1);
 
-      polynomials[dd] = new AnisotropicPolynomials<dim>(poly);
+      polynomials[dd] = std::make_unique<AnisotropicPolynomials<dim>>(poly);
     }
 
   // TODO: the implementation makes the assumption that all faces have the
@@ -475,9 +469,6 @@ FE_ABF<dim>::initialize_restriction()
                   polynomials[d]->compute_value(i_weight, q_sub.point(k));
               }
     }
-
-  for (unsigned int d = 0; d < dim; ++d)
-    delete polynomials[d];
 }
 
 
index 2462f1ab7d33011e7b1d30f671111d1f467eaa58..c7beaca1440a1f067bdb8cb4d8469d486ee964e0 100644 (file)
@@ -4131,8 +4131,8 @@ namespace internal
 
       // If we need to plot curved lines then generate a quadrature formula to
       // place points via the mapping
-      Quadrature<dim> *     q_projector = nullptr;
-      std::vector<Point<1>> boundary_points;
+      std::unique_ptr<Quadrature<dim>> q_projector;
+      std::vector<Point<1>>            boundary_points;
       if (mapping != nullptr)
         {
           boundary_points.resize(n_points);
@@ -4146,7 +4146,7 @@ namespace internal
 
           // tensor product of points, only one copy
           QIterated<dim - 1> quadrature(quadrature1d, 1);
-          q_projector = new Quadrature<dim>(
+          q_projector = std::make_unique<Quadrature<dim>>(
             QProjector<dim>::project_to_all_faces(quadrature));
         }
 
@@ -4304,10 +4304,6 @@ namespace internal
             }
         }
 
-      if (q_projector != nullptr)
-        delete q_projector;
-
-
       // make sure everything now gets to disk
       out.flush();
 

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.