]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use std::vector instead of Table 12995/head
authorPasquale Africa <pasqualeclaudio.africa@polimi.it>
Fri, 26 Nov 2021 08:57:28 +0000 (08:57 +0000)
committerPasquale Africa <pasqualeclaudio.africa@polimi.it>
Fri, 26 Nov 2021 16:01:46 +0000 (16:01 +0000)
include/deal.II/base/polynomials_barycentric.h
source/base/polynomials_barycentric.cc

index c2736486f51f6a9238588b2090704d6c4045937f..2668640096466dca5a8c74be31119091e2f59c79 100644 (file)
@@ -215,6 +215,31 @@ template <int dim>
 class BarycentricPolynomials : public ScalarPolynomialsBase<dim>
 {
 public:
+  /**
+   * Alias for polynomial type.
+   */
+  using PolyType = BarycentricPolynomial<dim>;
+
+  /**
+   * Alias for polynomial gradient type.
+   */
+  using GradType = std::array<PolyType, dim>;
+
+  /**
+   * Alias for polynomial hessian type.
+   */
+  using HessianType = std::array<GradType, dim>;
+
+  /**
+   * Alias for polynomial third derivatives type.
+   */
+  using ThirdDerivativesType = std::array<HessianType, dim>;
+
+  /**
+   * Alias for polynomial fourth derivatives type.
+   */
+  using FourthDerivativesType = std::array<ThirdDerivativesType, dim>;
+
   /**
    * Make the dimension available to the outside.
    */
@@ -314,15 +339,11 @@ public:
   clone() const override;
 
 protected:
-  std::vector<BarycentricPolynomial<dim>> polys;
-
-  Table<2, BarycentricPolynomial<dim>> poly_grads;
-
-  Table<3, BarycentricPolynomial<dim>> poly_hessians;
-
-  Table<4, BarycentricPolynomial<dim>> poly_third_derivatives;
-
-  Table<5, BarycentricPolynomial<dim>> poly_fourth_derivatives;
+  std::vector<PolyType>              polys;
+  std::vector<GradType>              poly_grads;
+  std::vector<HessianType>           poly_hessians;
+  std::vector<ThirdDerivativesType>  poly_third_derivatives;
+  std::vector<FourthDerivativesType> poly_fourth_derivatives;
 };
 
 // non-member template functions for algebra
index cd5968b16804ec97c6654c6408821336e6bf602e..4c899e2ee21542145ed8089b0785e94fcfb5dc6b 100644 (file)
@@ -26,7 +26,8 @@ namespace internal
    */
   template <int dim>
   unsigned int
-  get_degree(const std::vector<BarycentricPolynomial<dim>> &polys)
+  get_degree(
+    const std::vector<typename BarycentricPolynomials<dim>::PolyType> &polys)
   {
     // Since the first variable in a simplex polynomial is, e.g., in 2D,
     //
@@ -57,7 +58,7 @@ template <int dim>
 BarycentricPolynomials<dim>
 BarycentricPolynomials<dim>::get_fe_p_basis(const unsigned int degree)
 {
-  std::vector<BarycentricPolynomial<dim>> polys;
+  std::vector<PolyType> polys;
 
   auto M = [](const unsigned int d) {
     return BarycentricPolynomial<dim, double>::monomial(d);
@@ -102,16 +103,16 @@ BarycentricPolynomials<dim>::get_fe_p_basis(const unsigned int degree)
 
 template <int dim>
 BarycentricPolynomials<dim>::BarycentricPolynomials(
-  const std::vector<BarycentricPolynomial<dim>> &polynomials)
-  : ScalarPolynomialsBase<dim>(internal::get_degree(polynomials),
+  const std::vector<PolyType> &polynomials)
+  : ScalarPolynomialsBase<dim>(internal::get_degree<dim>(polynomials),
                                polynomials.size())
 {
   polys = polynomials;
 
-  poly_grads.reinit({polynomials.size(), dim});
-  poly_hessians.reinit({polynomials.size(), dim, dim});
-  poly_third_derivatives.reinit({polynomials.size(), dim, dim, dim});
-  poly_fourth_derivatives.reinit({polynomials.size(), dim, dim, dim, dim});
+  poly_grads.resize(polynomials.size());
+  poly_hessians.resize(polynomials.size());
+  poly_third_derivatives.resize(polynomials.size());
+  poly_fourth_derivatives.resize(polynomials.size());
 
   for (std::size_t i = 0; i < polynomials.size(); ++i)
     {
@@ -321,9 +322,10 @@ BarycentricPolynomials<dim>::memory_consumption() const
   for (const auto &poly : polys)
     poly_memory += poly.memory_consumption();
   return ScalarPolynomialsBase<dim>::memory_consumption() + poly_memory +
-         poly_grads.memory_consumption() + poly_hessians.memory_consumption() +
-         poly_third_derivatives.memory_consumption() +
-         poly_fourth_derivatives.memory_consumption();
+         MemoryConsumption::memory_consumption(poly_grads) +
+         MemoryConsumption::memory_consumption(poly_hessians) +
+         MemoryConsumption::memory_consumption(poly_third_derivatives) +
+         MemoryConsumption::memory_consumption(poly_fourth_derivatives);
 }
 
 template class BarycentricPolynomials<1>;

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.