From e51fe6de666112680225471ea4155e6d5dd20762 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Tue, 26 Feb 2019 14:47:35 +0100
Subject: [PATCH] Fix faces and nodes new owner

Comparison is now performed on the cell number and not on the cell id (should
fix call of MeshDispatcher on an already partitioned mesh)
---
 src/mesh/GmshReader.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mesh/GmshReader.cpp b/src/mesh/GmshReader.cpp
index b3aa5e182..6f3d10539 100644
--- a/src/mesh/GmshReader.cpp
+++ b/src/mesh/GmshReader.cpp
@@ -359,6 +359,7 @@ class MeshDispatcher
   {
     const auto& face_to_cell_matrix
         = m_mesh.connectivity().faceToCellMatrix();
+    const auto& cell_number = m_mesh.connectivity().cellNumber();
 
 #warning could use a better policy
     FaceValue<int> face_new_owner(m_mesh.connectivity());
@@ -368,7 +369,7 @@ class MeshDispatcher
 
         for (size_t j=1; j<face_to_cell.size(); ++j) {
           const CellId J = face_to_cell[j];
-          if (J<Jmin) {
+          if (cell_number[J] < cell_number[Jmin]) {
             Jmin=J;
           }
         }
@@ -383,6 +384,7 @@ class MeshDispatcher
   {
     const auto& node_to_cell_matrix
         = m_mesh.connectivity().nodeToCellMatrix();
+    const auto& cell_number = m_mesh.connectivity().cellNumber();
 
 #warning could use a better policy
     NodeValue<int> node_new_owner(m_mesh.connectivity());
@@ -392,7 +394,7 @@ class MeshDispatcher
 
         for (size_t j=1; j<node_to_cell.size(); ++j) {
           const CellId J = node_to_cell[j];
-          if (J<Jmin) {
+          if (cell_number[J] < cell_number[Jmin]) {
             Jmin=J;
           }
         }
-- 
GitLab