From: Pasquale Africa Date: Fri, 26 Nov 2021 08:57:28 +0000 (+0000) Subject: Use std::vector instead of Table X-Git-Tag: v9.4.0-rc1~796^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12995%2Fhead;p=dealii.git Use std::vector instead of Table --- diff --git a/include/deal.II/base/polynomials_barycentric.h b/include/deal.II/base/polynomials_barycentric.h index c2736486f5..2668640096 100644 --- a/include/deal.II/base/polynomials_barycentric.h +++ b/include/deal.II/base/polynomials_barycentric.h @@ -215,6 +215,31 @@ template class BarycentricPolynomials : public ScalarPolynomialsBase { public: + /** + * Alias for polynomial type. + */ + using PolyType = BarycentricPolynomial; + + /** + * Alias for polynomial gradient type. + */ + using GradType = std::array; + + /** + * Alias for polynomial hessian type. + */ + using HessianType = std::array; + + /** + * Alias for polynomial third derivatives type. + */ + using ThirdDerivativesType = std::array; + + /** + * Alias for polynomial fourth derivatives type. + */ + using FourthDerivativesType = std::array; + /** * Make the dimension available to the outside. */ @@ -314,15 +339,11 @@ public: clone() const override; protected: - std::vector> polys; - - Table<2, BarycentricPolynomial> poly_grads; - - Table<3, BarycentricPolynomial> poly_hessians; - - Table<4, BarycentricPolynomial> poly_third_derivatives; - - Table<5, BarycentricPolynomial> poly_fourth_derivatives; + std::vector polys; + std::vector poly_grads; + std::vector poly_hessians; + std::vector poly_third_derivatives; + std::vector poly_fourth_derivatives; }; // non-member template functions for algebra diff --git a/source/base/polynomials_barycentric.cc b/source/base/polynomials_barycentric.cc index cd5968b168..4c899e2ee2 100644 --- a/source/base/polynomials_barycentric.cc +++ b/source/base/polynomials_barycentric.cc @@ -26,7 +26,8 @@ namespace internal */ template unsigned int - get_degree(const std::vector> &polys) + get_degree( + const std::vector::PolyType> &polys) { // Since the first variable in a simplex polynomial is, e.g., in 2D, // @@ -57,7 +58,7 @@ template BarycentricPolynomials BarycentricPolynomials::get_fe_p_basis(const unsigned int degree) { - std::vector> polys; + std::vector polys; auto M = [](const unsigned int d) { return BarycentricPolynomial::monomial(d); @@ -102,16 +103,16 @@ BarycentricPolynomials::get_fe_p_basis(const unsigned int degree) template BarycentricPolynomials::BarycentricPolynomials( - const std::vector> &polynomials) - : ScalarPolynomialsBase(internal::get_degree(polynomials), + const std::vector &polynomials) + : ScalarPolynomialsBase(internal::get_degree(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::memory_consumption() const for (const auto &poly : polys) poly_memory += poly.memory_consumption(); return ScalarPolynomialsBase::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>;