Actual source code: ex45.c

  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: {
 17:   PetscInt nx = 2;
 18:   PetscInt ny = 2;
 19:   PetscInt nz = 128;
 20:   DM       da;
 21:   Mat      A;

 23:   PetscFunctionBeginUser;
 24:   PetscCall(PetscInitialize(&argc, &argv, NULL, NULL));
 25:   PetscCall(DMDACreate3d(PETSC_COMM_WORLD, DM_BOUNDARY_PERIODIC, DM_BOUNDARY_PERIODIC, DM_BOUNDARY_GHOSTED, DMDA_STENCIL_BOX, nx, ny, nz, PETSC_DECIDE, PETSC_DECIDE, PETSC_DECIDE, 1, 2, NULL, NULL, NULL, &da));
 26:   PetscCall(DMSetFromOptions(da));
 27:   PetscCall(DMSetUp(da));
 28:   PetscCall(DMView(da, PETSC_VIEWER_STDOUT_WORLD));
 29:   PetscCall(DMCreateMatrix(da, &A));

 31:   PetscCall(MatDestroy(&A));
 32:   PetscCall(DMDestroy(&da));
 33:   PetscCall(PetscFinalize());
 34:   return 0;
 35: }

 37: /*TEST

 39:    test:
 40:       nsize: 5

 42: TEST*/