1 const char help[] = "Test distribution with overlap using DMForest"; 2 3 #include <petscdmplex.h> 4 #include <petscdmforest.h> 5 6 int main(int argc, char **argv) 7 { 8 DM forest, plex; 9 Vec CoordVec; 10 MPI_Comm comm; 11 12 PetscCall(PetscInitialize(&argc, &argv, NULL, help)); 13 comm = PETSC_COMM_WORLD; 14 PetscCall(DMCreate(comm, &forest)); 15 PetscCall(PetscObjectSetName((PetscObject)forest, "forest")); 16 PetscCall(DMSetType(forest, DMP8EST)); 17 PetscCall(DMSetBasicAdjacency(forest, PETSC_TRUE, PETSC_TRUE)); 18 { 19 DM dm_base; 20 21 PetscCall(DMCreate(comm, &dm_base)); 22 PetscCall(DMSetType(dm_base, DMPLEX)); 23 PetscCall(PetscObjectSetOptionsPrefix((PetscObject)dm_base, "base_")); 24 PetscCall(DMSetFromOptions(dm_base)); 25 PetscCall(DMViewFromOptions(dm_base, NULL, "-dm_view")); 26 PetscCall(DMCopyFields(dm_base, PETSC_DETERMINE, PETSC_DETERMINE, forest)); 27 PetscCall(DMForestSetBaseDM(forest, dm_base)); 28 PetscCall(DMDestroy(&dm_base)); 29 } 30 PetscCall(DMForestSetPartitionOverlap(forest, 1)); 31 PetscCall(DMSetFromOptions(forest)); 32 PetscCall(DMSetUp(forest)); 33 PetscCall(DMViewFromOptions(forest, NULL, "-dm_forest_view")); 34 35 PetscCall(DMConvert(forest, DMPLEX, &plex)); 36 PetscCall(DMGetCoordinates(plex, &CoordVec)); 37 PetscCall(DMViewFromOptions(forest, NULL, "-dm_plex_view")); 38 39 PetscCall(DMDestroy(&plex)); 40 PetscCall(DMDestroy(&forest)); 41 PetscCall(PetscFinalize()); 42 return 0; 43 } 44 45 /*TEST 46 47 testset: 48 requires: p4est 49 args: -base_dm_plex_dim 3 -base_dm_plex_simplex 0 -base_dm_plex_box_faces 3,3,3 -base_dm_distribute_overlap 1 \ 50 -base_dm_plex_adj_cone true -base_dm_plex_adj_closure true \ 51 -base_dm_view -dm_forest_view -dm_plex_view 52 53 test: 54 suffix: 0 55 56 test: 57 suffix: 1 58 nsize: 3 59 args: -petscpartitioner_type simple 60 61 TEST*/ 62