Actual source code: ex31.c
1: static char help[] = "Tests MAIJ matrix for large DOF\n\n";
3: #include <petscdm.h>
4: #include <petscdmda.h>
6: int main(int argc, char *argv[])
7: {
8: Mat M;
9: Vec x, y;
10: DM da, daf;
12: PetscFunctionBeginUser;
13: PetscCall(PetscInitialize(&argc, &argv, 0, help));
14: PetscCall(DMDACreate2d(PETSC_COMM_WORLD, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DMDA_STENCIL_STAR, 4, 5, PETSC_DECIDE, PETSC_DECIDE, 41, 1, 0, 0, &da));
15: PetscCall(DMSetFromOptions(da));
16: PetscCall(DMSetUp(da));
17: PetscCall(DMRefine(da, PETSC_COMM_WORLD, &daf));
18: PetscCall(DMCreateInterpolation(da, daf, &M, NULL));
19: PetscCall(DMCreateGlobalVector(da, &x));
20: PetscCall(DMCreateGlobalVector(daf, &y));
22: PetscCall(MatMult(M, x, y));
23: PetscCall(MatMultTranspose(M, y, x));
24: PetscCall(DMDestroy(&da));
25: PetscCall(DMDestroy(&daf));
26: PetscCall(VecDestroy(&x));
27: PetscCall(VecDestroy(&y));
28: PetscCall(MatDestroy(&M));
29: PetscCall(PetscFinalize());
30: return 0;
31: }
33: /*TEST
35: test:
36: nsize: 2
38: TEST*/