Commits

BarryFSmith  committed 0acb5be

added support for dfill for DMCreateMatrix_1d_MPIAIJ for DMDA

  • Participants
  • Parent commits e7df43c

Comments (0)

Files changed (2)

File src/dm/impls/da/fdda.c

   DM_DA                  *dd = (DM_DA*)da->data;
   PetscInt               xs,nx,i,j,gxs,gnx,row,k,l;
   PetscInt               m,dim,s,*cols = NULL,nc,col,cnt,*ocols;
-  PetscInt               *ofill = dd->ofill;
+  PetscInt               *ofill = dd->ofill,*dfill = dd->dfill;
   PetscScalar            *values;
   DMDABoundaryType       bx;
   ISLocalToGlobalMapping ltog,ltogb;
   for (i=0; i<s; i++) {
     for (j=0; j<nc; j++) {
       ocols[cnt] = ((!rank) ? 0 : (s - i)*(ofill[j+1] - ofill[j]));
-      cols[cnt]  = nc + (s + i)*(ofill[j+1] - ofill[j]);
+      cols[cnt]  = dfill[j+1] - dfill[j] + (s + i)*(ofill[j+1] - ofill[j]);
       cnt++;
     }
   }
   for (i=s; i<nx-s; i++) {
     for (j=0; j<nc; j++) {
-      cols[cnt] = nc + 2*s*(ofill[j+1] - ofill[j]);
+      cols[cnt] = dfill[j+1] - dfill[j] + 2*s*(ofill[j+1] - ofill[j]);
       cnt++;
     }
   }
   for (i=nx-s; i<nx; i++) {
     for (j=0; j<nc; j++) {
       ocols[cnt] = ((rank == (size-1)) ? 0 : (i - nx + s + 1)*(ofill[j+1] - ofill[j]));
-      cols[cnt]  = nc + (s + nx - i - 1)*(ofill[j+1] - ofill[j]);
+      cols[cnt]  = dfill[j+1] - dfill[j] + (s + nx - i - 1)*(ofill[j+1] - ofill[j]);
       cnt++;
     }
   }
             for (k=ofill[j]; k<ofill[j+1]; k++) cols[cnt++] = (i - s + l)*nc + ofill[k];
           }
         }
-        for (k=0; k<nc; k++) {
-          cols[cnt++] = i*nc + k;
+        if (dfill) {
+          for (k=dfill[j]; k<dfill[j+1]; k++) {
+            cols[cnt++] = i*nc + dfill[k];
+          }
+        } else {
+          for (k=0; k<nc; k++) {
+            cols[cnt++] = i*nc + k;
+          }
         }
         for (l=0; l<s; l++) {
           for (k=ofill[j]; k<ofill[j+1]; k++) cols[cnt++] = (i + s - l)*nc + ofill[k];
         for (l=0; l<s; l++) {
           for (k=ofill[j]; k<ofill[j+1]; k++) cols[cnt++] = (i - s + l)*nc + ofill[k];
         }
-        for (k=0; k<nc; k++) {
-          cols[cnt++] = i*nc + k;
+        if (dfill) {
+          for (k=dfill[j]; k<dfill[j+1]; k++) {
+            cols[cnt++] = i*nc + dfill[k];
+          }
+        } else {
+          for (k=0; k<nc; k++) {
+            cols[cnt++] = i*nc + k;
+          }
         }
         for (l=0; l<s; l++) {
           for (k=ofill[j]; k<ofill[j+1]; k++) cols[cnt++] = (i + s - l)*nc + ofill[k];
         for (l=0; l<s; l++) {
           for (k=ofill[j]; k<ofill[j+1]; k++) cols[cnt++] = (i - s + l)*nc + ofill[k];
         }
-        for (k=0; k<nc; k++) {
-          cols[cnt++] = i*nc + k;
+        if (dfill) {
+          for (k=dfill[j]; k<dfill[j+1]; k++) {
+            cols[cnt++] = i*nc + dfill[k];
+          }
+        } else {
+          for (k=0; k<nc; k++) {
+            cols[cnt++] = i*nc + k;
+          }
         }
         if (rank < size-1) {
           for (l=0; l<s; l++) {

File src/ts/examples/tutorials/advection-diffusion-reaction/ex10.c

 #include <petscts.h>
 
 /*    Hard wire the number of cluster sizes for He, V, and I */
-#define N 15
+#define N 3
 
 /*
      Define all the concentrations (there is one of these unions at each grid point)
   for (He=0; He<PetscMin(N,5); He++) ofill[He*dof + He] = 1;
   ofill[N*dof + N] = ofill[2*N*dof + 2*N] = 1;
 
-  ierr = DMDASetBlockFills(da,NULL,ofill);CHKERRQ(ierr);
-  ierr = PetscFree(ofill);CHKERRQ(ierr);
   ierr = GetDfill(dfill,&ctx);CHKERRQ(ierr);
+  ierr = DMDASetBlockFills(da,dfill,ofill);CHKERRQ(ierr);
+  ierr = PetscFree(ofill);CHKERRQ(ierr);
   ierr = PetscFree(dfill);CHKERRQ(ierr);
 
- 
-
   /*  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Extract global vector from DMDA to hold solution
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
 #undef __FUNCT__
 #define __FUNCT__ "GetDfill"
-
 PetscErrorCode GetDfill(PetscInt *dfill, void *ptr)
 {
   AppCtx         *ctx = (AppCtx*) ptr;