From b1ac0973a8ede188bd99806206dcbc48e322dc4e Mon Sep 17 00:00:00 2001 From: Gregor Olenik Date: Thu, 7 Nov 2024 13:34:41 +0100 Subject: [PATCH] fix count of interface elments --- include/OGL/MatrixWrapper/HostMatrix.H | 3 ++- src/MatrixWrapper/HostMatrix.C | 22 +++++++++++++--------- unitTests/MatrixWrapper/HostMatrix_p2d.cpp | 16 +++++++++------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/include/OGL/MatrixWrapper/HostMatrix.H b/include/OGL/MatrixWrapper/HostMatrix.H index 13e4da01..7dcd050e 100644 --- a/include/OGL/MatrixWrapper/HostMatrix.H +++ b/include/OGL/MatrixWrapper/HostMatrix.H @@ -175,7 +175,8 @@ private: ** ret = [(1,2,1),(2,20, 2), (3, 20, 2) ...] ** i0 i1, i... */ - [[nodiscard]] std::vector collect_cells_on_interfaces( + [[nodiscard]] std::pair> + collect_cells_on_interfaces( const lduInterfaceFieldPtrsList &interfaces) const; /** Based on OpenFOAMs ldu matrix and interfaces this function computes diff --git a/src/MatrixWrapper/HostMatrix.C b/src/MatrixWrapper/HostMatrix.C index 70fe32a4..c45067d5 100644 --- a/src/MatrixWrapper/HostMatrix.C +++ b/src/MatrixWrapper/HostMatrix.C @@ -318,7 +318,8 @@ HostMatrixWrapper::create_communication_pattern() const } -std::vector HostMatrixWrapper::collect_cells_on_interfaces( +std::pair> HostMatrixWrapper::collect_cells_on_interfaces( const lduInterfaceFieldPtrsList &interfaces) const { // vector of neighbour cell idx connected to interface @@ -327,9 +328,10 @@ std::vector HostMatrixWrapper::collect_cells_on_interfaces( interface_idxs.reserve(interface_nnz); auto rank = get_exec_handler().get_rank(); - label local_ctr = 0; - label interface_ctr = 0; - label interface_id = 0; + label local_ctr = 0; // count local interface element + label interface_ctr = 0; // count non_local interface elment + label interface_id = 0; // count number of interfaces + label total_ctr = 0; for (label i = 0; i < interfaces.size(); i++) { if (interface_getter(interfaces, i) == nullptr) { @@ -338,6 +340,7 @@ std::vector HostMatrixWrapper::collect_cells_on_interfaces( const auto iface{interface_getter(interfaces, i)}; const auto &face_cells{iface->interface().faceCells()}; const label interface_size = face_cells.size(); + total_ctr += interface_size; if (isA(iface->interface())) { const auto &patch = @@ -386,7 +389,7 @@ std::vector HostMatrixWrapper::collect_cells_on_interfaces( word msg = "done collecting neighbouring processor cell id"; LOG_2(verbose_, msg) - return interface_idxs; + return {total_ctr, interface_idxs}; } std::tuple, std::vector