From 51b88dc892e53b241cece3bfb8c7820272f45c6b Mon Sep 17 00:00:00 2001
From: Daniel Winklehner <Daniel Winklehner>
Date: Mon, 3 Mar 2025 21:57:43 +0100
Subject: [PATCH] First commit to test. Fixed getCoord and constant
 interpolation -DW

---
 src/Solvers/ArbitraryDomain.cpp | 12 ++++++------
 src/Solvers/IrregularDomain.cpp |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/Solvers/ArbitraryDomain.cpp b/src/Solvers/ArbitraryDomain.cpp
index 499f872eb..25cf1394f 100644
--- a/src/Solvers/ArbitraryDomain.cpp
+++ b/src/Solvers/ArbitraryDomain.cpp
@@ -256,19 +256,19 @@ void ArbitraryDomain::constantInterpolation(int idx, int idy, int idz,
     value.back = -1/(hr_m[2]*hr_m[2]);
     value.center = 2/(hr_m[0]*hr_m[0]) + 2/(hr_m[1]*hr_m[1]) + 2/(hr_m[2]*hr_m[2]);
 
-    if(!isInside(idx-1,idy,idz))
+    if (idx == 0 || !isInside(idx - 1, idy, idz))
         value.west = 0.0;
-    if(!isInside(idx+1,idy,idz))
+    if (idx == (nr_m[0] - 1) || !isInside(idx + 1, idy, idz))
         value.east = 0.0;
 
-    if(!isInside(idx,idy+1,idz))
+    if (idy == (nr_m[1] - 1) || !isInside(idx, idy + 1, idz))
         value.north = 0.0;
-    if(!isInside(idx,idy-1,idz))
+    if (idy == 0 || !isInside(idx, idy - 1, idz))
         value.south = 0.0;
 
-    if(!isInside(idx,idy,idz-1))
+    if (idz == 0 || !isInside(idx, idy, idz - 1))
         value.front = 0.0;
-    if(!isInside(idx,idy,idz+1))
+    if (idz == (nr_m[2] - 1) || !isInside(idx, idy, idz + 1))
         value.back = 0.0;
 }
 
diff --git a/src/Solvers/IrregularDomain.cpp b/src/Solvers/IrregularDomain.cpp
index 471679aba..70868ef59 100644
--- a/src/Solvers/IrregularDomain.cpp
+++ b/src/Solvers/IrregularDomain.cpp
@@ -82,8 +82,8 @@ void IrregularDomain::getNeighbours(int id, StencilIndex_t& index) const {
 void IrregularDomain::getCoord(int idx, int& x, int& y, int& z) const {
     int xy = coordAccess(idx);
     x = xy % nr_m[0];
-    y = (xy - x) / nr_m[0];
-    z = idx / getNumXY();
+    y = ((xy - x) / nr_m[0]) % nr_m[1];
+    z = ((xy - x) / nr_m[0] - y) / nr_m[1];
 }
 
 int IrregularDomain::getIdx(int x, int y, int z) const {
-- 
GitLab