Dear Matt,

    I am trying to translate the local nCell numbers returned by swarm particle location routines into the global (i,j,k) indices in the dmda and I have run into some oddities in the 3d case. I have dug into the private_DMDALocatePointsIS_2D_Regular and private_DMDALocatePointsIS_3D_Regular routines and, using 14 points per direction and 1 ghost for the DMDA, on 2 cpus:

- the 2d routine thinks to have 13x6 Q1 elements on cpu0 and 13x7 on cpu 1 (which looks correct to me as 6+7 makes 13 elements in the y direction)

- the 2d routine thinks to have 13x13x6 elements on cpu0 and 13x13x8 on cpu1 (which looks one too many)

Removing lines 155-157 from src/dm/impls/da/dageometry.c (patch attached) seems to fix some things in my code. I have not studied in depth the code of private_DMDALocatePointsIS_3D_Regular, but I have seen that the left shift of xs,ys,zs are already performed at lines 137-139.

Could you have a look, please?

(This looked more appropriate for petsc-dev than petsc-users, but I am not a subscriber, so could you please reply to me directly as well?)

Thanks

    Matteo
diff --git a/src/dm/impls/da/dageometry.c b/src/dm/impls/da/dageometry.c
index fbf320aadfa..7e288f8c5ed 100644
--- a/src/dm/impls/da/dageometry.c
+++ b/src/dm/impls/da/dageometry.c
@@ -152,9 +152,9 @@ PetscErrorCode private_DMDALocatePointsIS_3D_Regular(DM dmregular, Vec pos, IS *
   gmax_l[2] = PetscRealPart(_coor[3 * c1 + 2]);
   PetscCall(VecRestoreArrayRead(coor, &_coor));
 
-  if (xs != Xs) xs -= 1;
-  if (ys != Ys) ys -= 1;
-  if (zs != Zs) zs -= 1;
+  //if (xs != Xs) xs -= 1;
+  //if (ys != Ys) ys -= 1;
+  //if (zs != Zs) zs -= 1;
 
   mxlocal = xe - xs - 1;
   mylocal = ye - ys - 1;

Reply via email to