From b706c14d3ad5b5a6744f0737b964916b0f280eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Wed, 10 Mar 2021 15:32:03 +0100 Subject: [PATCH] Add numberOf template functions These functions return the number of items (template parameter) --- src/mesh/Connectivity.hpp | 17 +++++++++++++++++ src/mesh/Mesh.hpp | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/src/mesh/Connectivity.hpp b/src/mesh/Connectivity.hpp index f8e4dafdb..2b25c6e9b 100644 --- a/src/mesh/Connectivity.hpp +++ b/src/mesh/Connectivity.hpp @@ -609,6 +609,23 @@ class Connectivity final : public IConnectivity return cell_to_node_matrix.numRows(); } + template <ItemType item_type> + PUGS_INLINE size_t + numberOf() const + { + if constexpr (item_type == ItemType::cell) { + return this->numberOfCells(); + } else if constexpr (item_type == ItemType::face) { + return this->numberOfFaces(); + } else if constexpr (item_type == ItemType::edge) { + return this->numberOfEdges(); + } else if constexpr (item_type == ItemType::node) { + return this->numberOfNodes(); + } else { + static_assert(is_false_item_type_v<item_type>, "unknown ItemType"); + } + } + CellValue<const double> invCellNbNodes() const { diff --git a/src/mesh/Mesh.hpp b/src/mesh/Mesh.hpp index e78383978..21c100384 100644 --- a/src/mesh/Mesh.hpp +++ b/src/mesh/Mesh.hpp @@ -63,6 +63,13 @@ class Mesh final : public IMesh return m_connectivity->numberOfCells(); } + template <ItemType item_type> + PUGS_INLINE size_t + numberOf() const + { + return m_connectivity->template numberOf<item_type>(); + } + PUGS_INLINE const NodeValue<const Rd>& xr() const -- GitLab