From 4a973e02b8e174b9566afa2d39939a96eb780b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Fri, 4 Mar 2022 11:37:47 +0100 Subject: [PATCH] Get ride of Connectivity::invCellNbNodes() This was a marginal optimization that - is too specific (was used only once ...) - generate no measurable performance change --- src/mesh/Connectivity.hpp | 20 -------------------- src/mesh/MeshData.hpp | 4 +--- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/mesh/Connectivity.hpp b/src/mesh/Connectivity.hpp index 51cda4227..4411e728d 100644 --- a/src/mesh/Connectivity.hpp +++ b/src/mesh/Connectivity.hpp @@ -103,8 +103,6 @@ class Connectivity final : public IConnectivity std::vector<RefEdgeList> m_ref_edge_list_vector; std::vector<RefNodeList> m_ref_node_list_vector; - WeakCellValue<const double> m_inv_cell_nb_nodes; - void _computeCellFaceAndFaceNodeConnectivities(); void _buildIsBoundaryFace() const; @@ -685,24 +683,6 @@ class Connectivity final : public IConnectivity } } - CellValue<const double> - invCellNbNodes() const - { - if (not m_inv_cell_nb_nodes.isBuilt()) { - const auto& cell_to_node_matrix = m_item_to_item_matrix[itemTId(ItemType::cell)][itemTId(ItemType::node)]; - - WeakCellValue<double> inv_cell_nb_nodes(*this); - parallel_for( - this->numberOfCells(), PUGS_LAMBDA(CellId j) { - const auto& cell_nodes = cell_to_node_matrix.rowConst(j); - inv_cell_nb_nodes[j] = 1. / cell_nodes.length; - }); - const_cast<WeakCellValue<const double>&>(m_inv_cell_nb_nodes) = inv_cell_nb_nodes; - } - - return m_inv_cell_nb_nodes; - } - Connectivity(const Connectivity&) = delete; private: diff --git a/src/mesh/MeshData.hpp b/src/mesh/MeshData.hpp index 8842fd8ac..ada0f8fbd 100644 --- a/src/mesh/MeshData.hpp +++ b/src/mesh/MeshData.hpp @@ -174,8 +174,6 @@ class MeshData : public IMeshData } else { const NodeValue<const Rd>& xr = m_mesh.xr(); - const CellValue<const double>& inv_cell_nb_nodes = m_mesh.connectivity().invCellNbNodes(); - const auto& cell_to_node_matrix = m_mesh.connectivity().cellToNodeMatrix(); CellValue<Rd> cell_iso_barycenter{m_mesh.connectivity()}; parallel_for( @@ -185,7 +183,7 @@ class MeshData : public IMeshData for (size_t R = 0; R < cell_nodes.size(); ++R) { X += xr[cell_nodes[R]]; } - cell_iso_barycenter[j] = inv_cell_nb_nodes[j] * X; + cell_iso_barycenter[j] = (1. / cell_nodes.size()) * X; }); m_cell_iso_barycenter = cell_iso_barycenter; } -- GitLab