-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgmshVolumeCheck.c
34 lines (25 loc) · 944 Bytes
/
gmshVolumeCheck.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
static const char help[] = "Debug Code";
#include <petsc.h>
int main(int argc, char **argv) {
DM dm;
PetscCall(PetscInitialize(&argc, &argv, NULL, help));
PetscCall(DMCreate(PETSC_COMM_WORLD, &dm));
PetscCall(DMSetType(dm, DMPLEX));
PetscCall(DMSetFromOptions(dm));
PetscCall(DMViewFromOptions(dm, NULL, "-dm_init"));
PetscCall(DMGetCoordinatesLocalSetUp(dm));
// March over each cell
PetscInt cStart, cEnd;
PetscCall(DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd));
for(PetscInt c = cStart; c < cEnd; ++c){
// compute the volume for this cell
PetscReal volume;
PetscCall(DMPlexComputeCellGeometryFVM(dm, c, &volume, NULL, NULL));
if(volume < 0){
PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Negative Volume in Cell %" PetscInt_FMT " is %f\n", c, volume));
}
}
PetscCall(DMDestroy(&dm));
PetscCall(PetscFinalize());
return 0;
}