From: Martin Kronbichler Date: Thu, 13 Aug 2020 10:49:51 +0000 (+0200) Subject: Improve performance of ReferenceCell::Info::get_cell X-Git-Tag: v9.3.0-rc1~1186^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15714871713c65ea11080016323339c51731a8d7;p=dealii.git Improve performance of ReferenceCell::Info::get_cell --- diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index a17be580e2..98cf416d3c 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -1000,43 +1000,23 @@ namespace ReferenceCell }; /** - * Return for a given reference-cell type @p the right Info. + * Return for a given reference-cell type the right Info. */ inline const ReferenceCell::internal::Info::Base & get_cell(const ReferenceCell::Type &type) { - static ReferenceCell::internal::Info::Base gei_invalid; - static ReferenceCell::internal::Info::Vertex gei_vertex; - static ReferenceCell::internal::Info::Line gei_line; - static ReferenceCell::internal::Info::Tri gei_tri; - static ReferenceCell::internal::Info::Quad gei_quad; - static ReferenceCell::internal::Info::Tet gei_tet; - static ReferenceCell::internal::Info::Pyramid gei_pyramid; - static ReferenceCell::internal::Info::Wedge gei_wedge; - static ReferenceCell::internal::Info::Hex gei_hex; - - switch (type) - { - case ReferenceCell::Type::Vertex: - return gei_vertex; - case ReferenceCell::Type::Line: - return gei_line; - case ReferenceCell::Type::Tri: - return gei_tri; - case ReferenceCell::Type::Quad: - return gei_quad; - case ReferenceCell::Type::Tet: - return gei_tet; - case ReferenceCell::Type::Pyramid: - return gei_pyramid; - case ReferenceCell::Type::Wedge: - return gei_wedge; - case ReferenceCell::Type::Hex: - return gei_hex; - default: - Assert(false, StandardExceptions::ExcNotImplemented()); - return gei_invalid; - } + static const std:: + array, 8> + gei{{std::make_unique(), + std::make_unique(), + std::make_unique(), + std::make_unique(), + std::make_unique(), + std::make_unique(), + std::make_unique(), + std::make_unique()}}; + AssertIndexRange(static_cast(type), 8); + return *gei[static_cast(type)]; } /**