From 7d5961dc690844458293571a94b6d85fb9f4319b Mon Sep 17 00:00:00 2001
From: labourasse <labourassee@gmail.com>
Date: Thu, 23 Feb 2023 19:48:03 +0100
Subject: [PATCH] correct bug

---
 src/mesh/MeshSmoother.cpp | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/mesh/MeshSmoother.cpp b/src/mesh/MeshSmoother.cpp
index 5b77dcdf7..8d81332b7 100644
--- a/src/mesh/MeshSmoother.cpp
+++ b/src/mesh/MeshSmoother.cpp
@@ -173,10 +173,10 @@ class MeshSmootherHandler::MeshSmoother
       m_given_mesh.numberOfNodes(), PUGS_LAMBDA(const NodeId node_id) {
         const auto& node_cell_list = node_to_cell_matrix[node_id];
 
-        Rd mean_position(zero);
-        size_t number_of_neighbours = 0;
         for (size_t i_cell = 0; i_cell < node_cell_list.size(); ++i_cell) {
           const size_t i_cell_node = node_number_in_their_cells(node_id, i_cell);
+          Rd mean_position(zero);
+          size_t number_of_neighbours = 0;
 
           const CellId cell_id       = node_cell_list[i_cell];
           const auto& cell_node_list = cell_to_node_matrix[cell_id];
@@ -187,13 +187,13 @@ class MeshSmootherHandler::MeshSmoother
               number_of_neighbours++;
             }
           }
+          mean_position    = 1. / number_of_neighbours * mean_position;
+          shift_r[node_id] = mean_position - given_xr[node_id];
         }
-        mean_position    = 1 / number_of_neighbours * mean_position;
-        shift_r[node_id] = mean_position - given_xr[node_id];
-        double nshift    = sqrt(dot(shift_r[node_id], shift_r[node_id]));
-        if (nshift > max_delta_xr[node_id]) {
-          shift_r[node_id] = max_delta_xr[node_id] / nshift * shift_r[node_id];
-        }
+        // double nshift    = sqrt(dot(shift_r[node_id], shift_r[node_id]));
+        // if (nshift > max_delta_xr[node_id]) {
+        //   shift_r[node_id] = max_delta_xr[node_id] / nshift * shift_r[node_id];
+        // }
       });
 
     this->_applyBC(shift_r);
-- 
GitLab