[petsc-dev] DACreate3d should work for 1 node in Z

Ethan Coon ecoon at lanl.gov
Tue Apr 19 16:21:16 CDT 2011


The attached patch fixes the errors to error in the correct cases.


Ethan

On Tue, 2011-04-19 at 22:48 +0200, Jed Brown wrote:
> On Tue, Apr 19, 2011 at 22:44, Ethan Coon <ecoon at lanl.gov> wrote:
>         The short answer -- make the z-size = s.  It's not that huge
>         of a hit --
>         the local arrays are 6*NX*NY*ndofs instead of 5*NX*NY*ndofs.
>         
> 
> 
> Indeed, though it is potentially about twice as much work because you
> only have to evaluate residuals on the owned nodes.
>  
>         
>         Otherwise, I'll try to implement the special-special case of
>         DMDA_BOUNDARY_PERIODIC, P=1, zl=1, and s > 1 soon.
> 
> Great, thanks.

-- 
------------------------------------
Ethan Coon
Post-Doctoral Researcher
Applied Mathematics - T-5
Los Alamos National Laboratory
505-665-8289

http://www.ldeo.columbia.edu/~ecoon/
------------------------------------
-------------- next part --------------
fixed errors about local size when s > x to error when the code would actually error

diff -r da7041f275a3 src/dm/impls/da/da1.c
--- a/src/dm/impls/da/da1.c	Tue Apr 19 09:29:49 2011 -0500
+++ b/src/dm/impls/da/da1.c	Tue Apr 19 15:18:30 2011 -0600
@@ -201,6 +201,14 @@
     if (left != M) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Sum of lx across processors not equal to M %D %D",left,M);
   }
 
+  /*
+   check if the scatter requires more than one process neighbor or wraps around
+   the domain more than once
+  */
+  if ((x < s) & ((M > 1) | (bx == DMDA_BOUNDARY_PERIODIC))) {
+    SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Local x-width of domain x %D is smaller than stencil width s %D",x,s);
+  }
+
   /* From now on x,xs,xe,Xs,Xe are the exact location in the array */
   x  *= dof;
   xs *= dof;
diff -r da7041f275a3 src/dm/impls/da/da2.c
--- a/src/dm/impls/da/da2.c	Tue Apr 19 09:29:49 2011 -0500
+++ b/src/dm/impls/da/da2.c	Tue Apr 19 15:18:30 2011 -0600
@@ -1346,8 +1346,16 @@
   if (left != N) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Sum of ly across processors not equal to N: %D %D",left,N);
 #endif
 
-  if (x < s) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Local x-width of domain x %D is smaller than stencil width s %D",x,s);
-  if (y < s) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Local y-width of domain y %D is smaller than stencil width s %D",y,s);
+  /*
+   check if the scatter requires more than one process neighbor or wraps around
+   the domain more than once
+  */
+  if ((x < s) && ((m > 1) || (bx == DMDA_BOUNDARY_PERIODIC))) {
+    SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Local x-width of domain x %D is smaller than stencil width s %D",x,s);
+  }
+  if ((y < s) && ((n > 1) || (by == DMDA_BOUNDARY_PERIODIC))) {
+    SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Local y-width of domain y %D is smaller than stencil width s %D",y,s);
+  }
   xe = xs + x;
   ye = ys + y;
 
diff -r da7041f275a3 src/dm/impls/da/da3.c
--- a/src/dm/impls/da/da3.c	Tue Apr 19 09:29:49 2011 -0500
+++ b/src/dm/impls/da/da3.c	Tue Apr 19 15:18:30 2011 -0600
@@ -304,7 +304,9 @@
   x  = lx[rank % m];
   xs = 0;
   for (i=0; i<(rank%m); i++) { xs += lx[i];}
-  if (m > 1 && x < s) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Column width is too thin for stencil! %D %D",x,s);
+  if ((x < s) && ((m > 1) || (bx == DMDA_BOUNDARY_PERIODIC))) {
+    SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Local x-width of domain x %D is smaller than stencil width s %D",x,s);
+  }
 
   if (!ly) {
     ierr = PetscMalloc(n*sizeof(PetscInt), &dd->ly);CHKERRQ(ierr);
@@ -314,7 +316,9 @@
     }
   }
   y  = ly[(rank % (m*n))/m];
-  if (n > 1 && y < s) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Row width is too thin for stencil! %D %D",y,s);      
+  if ((y < s) && ((n > 1) || (by == DMDA_BOUNDARY_PERIODIC))) {
+    SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Local y-width of domain y %D is smaller than stencil width s %D",y,s);
+  }
   ys = 0;
   for (i=0; i<(rank % (m*n))/m; i++) { ys += ly[i];}
 
@@ -326,7 +330,10 @@
     }
   }
   z  = lz[rank/(m*n)];
-  if (p > 1 && z < s) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Plane width is too thin for stencil! %D %D",z,s);      
+
+  if ((z < s) && ((p > 1) || bz == DMDA_BOUNDARY_PERIODIC)) {
+    SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Local z-width of domain z %D is smaller than stencil width s %D",z,s);
+  }
   zs = 0;
   for (i=0; i<(rank/(m*n)); i++) { zs += lz[i];}
   ye = ys + y;


More information about the petsc-dev mailing list