Actual source code: ex45.c

petsc-3.9.4 2018-09-11
Report Typos and Errors
  1: /* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.

  3:   Detected bug in DMCreateMatrix() for skinny domains with periodic boundary conditions in overestimating nonzero preallocation

  5: * Creation Date : 08-12-2016

  7: * Last Modified : Thu 08 Dec 2016 10:46:02 AM CET

  9: * Created By : Davide Monsorno

 11: _._._._._._._._._._._._._._._._._._._._._.*/

 13:  #include <petscdmda.h>

 15: int main(int argc, char *argv[])
 16: {
 18:   PetscInt       nx = 2;
 19:   PetscInt       ny = 2;
 20:   PetscInt       nz = 128;
 21:   DM             da;
 22:   Mat            A;

 24:   PetscInitialize(&argc,&argv,NULL,NULL);if (ierr) return ierr;

 26:   DMDACreate3d(PETSC_COMM_WORLD,DM_BOUNDARY_PERIODIC,DM_BOUNDARY_PERIODIC,DM_BOUNDARY_GHOSTED,DMDA_STENCIL_BOX,nx,ny,nz,
 27:                       PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,1,2,NULL,NULL,NULL,&da);

 29:   DMSetFromOptions(da);
 30:   DMSetUp(da);
 31:   DMView(da,PETSC_VIEWER_STDOUT_WORLD);
 32:   DMCreateMatrix(da,&A);

 34:   MatDestroy(&A);
 35:   DMDestroy(&da);
 36:   PetscFinalize();
 37:   return ierr;
 38: }


 41: /*TEST

 43:    test:
 44:       nsize: 5

 46: TEST*/