Commits

Matt Knepley  committed 4669e18 Merge

Merge branch 'knepley/fix-dm-vec-blocksize' into knepley/pylith

* knepley/fix-dm-vec-blocksize:
DMPlex: Fix variable init
DMPlex: Fix coordinate blocksize in uniform refinement
Vec: Fix blocksize determination with VecGetSubVector()

  • Participants
  • Parent commits cf6d85e, 8c85052
  • Branches knepley/pylith

Comments (0)

Files changed (3)

File src/dm/impls/plex/plex.c

   PetscInt       *cone;
   PetscInt        dim, spatialDim, numVertices, v, numCorners, numCells, cell, c;
   hid_t           fileId, groupId;
-  hsize_t         idx;
+  hsize_t         idx = 0;
   herr_t          status;
   PetscErrorCode  ierr;
 

File src/dm/impls/plex/plexrefine.c

   Vec            coordinates, coordinatesNew;
   PetscScalar   *coords, *coordsNew;
   const PetscInt numVertices = depthSize ? depthSize[0] : 0;
-  PetscInt       dim, depth, coordSizeNew, cStart, cEnd, cMax, c, vStart, vStartNew, vEnd, v, eStart, eEnd, eMax, e, fStart, fEnd, fMax, f;
+  PetscInt       dim, depth, bs, coordSizeNew, cStart, cEnd, cMax, c, vStart, vStartNew, vEnd, v, eStart, eEnd, eMax, e, fStart, fEnd, fMax, f;
   PetscErrorCode ierr;
 
   PetscFunctionBegin;
   ierr = VecCreate(PetscObjectComm((PetscObject)dm), &coordinatesNew);CHKERRQ(ierr);
   ierr = PetscObjectSetName((PetscObject) coordinatesNew, "coordinates");CHKERRQ(ierr);
   ierr = VecSetSizes(coordinatesNew, coordSizeNew, PETSC_DETERMINE);CHKERRQ(ierr);
+  ierr = VecGetBlockSize(coordinates, &bs);CHKERRQ(ierr);
+  ierr = VecSetBlockSize(coordinatesNew, bs);CHKERRQ(ierr);
   ierr = VecSetFromOptions(coordinatesNew);CHKERRQ(ierr);
   ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr);
   ierr = VecGetArray(coordinatesNew, &coordsNew);CHKERRQ(ierr);

File src/vec/vec/interface/rvector.c

     ierr = ISContiguousLocal(is,gstart,gend,&start,&contiguous);CHKERRQ(ierr);
     ierr = MPI_Allreduce(&contiguous,&gcontiguous,1,MPIU_BOOL,MPI_LAND,PetscObjectComm((PetscObject)is));CHKERRQ(ierr);
     if (gcontiguous) {          /* We can do a no-copy implementation */
-      PetscInt    n,N;
+      PetscInt    n,N,bs;
       PetscScalar *x;
       PetscMPIInt size;
       ierr = ISGetLocalSize(is,&n);CHKERRQ(ierr);
       ierr = VecGetArray(X,&x);CHKERRQ(ierr);
+      ierr = VecGetBlockSize(X,&bs);CHKERRQ(ierr);
+      if (n%bs) bs = 1;
       ierr = MPI_Comm_size(PetscObjectComm((PetscObject)X),&size);CHKERRQ(ierr);
       if (size == 1) {
-        ierr = VecCreateSeqWithArray(PetscObjectComm((PetscObject)X),1,n,x+start,&Z);CHKERRQ(ierr);
+        ierr = VecCreateSeqWithArray(PetscObjectComm((PetscObject)X),bs,n,x+start,&Z);CHKERRQ(ierr);
       } else {
         ierr = ISGetSize(is,&N);CHKERRQ(ierr);
-        ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)X),1,n,N,x+start,&Z);CHKERRQ(ierr);
+        ierr = VecCreateMPIWithArray(PetscObjectComm((PetscObject)X),bs,n,N,x+start,&Z);CHKERRQ(ierr);
       }
       ierr = VecRestoreArray(X,&x);CHKERRQ(ierr);
     } else {                    /* Have to create a scatter and do a copy */