Skip to content

Commit 79b2e52

Browse files
committed
Update petsc examples in this branch after PR #538 with different argument list for DMPlexGetClosureIndices and DMPlexRestoreClosureIndices
1 parent ced8808 commit 79b2e52

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

examples/petsc/area.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@
4949
static const char help[] =
5050
"Compute surface area of a cube or a cubed-sphere using DMPlex in PETSc\n";
5151

52+
5253
#include <string.h>
5354
#include <petscdmplex.h>
55+
#include <petsc.h>
5456
#include <ceed.h>
5557
#include "qfunctions/area/areacube.h"
5658
#include "qfunctions/area/areasphere.h"
@@ -59,6 +61,11 @@ static const char help[] =
5961
# define M_PI 3.14159265358979323846
6062
#endif
6163

64+
#if PETSC_VERSION_LT(3,14,0)
65+
# define DMPlexGetClosureIndices(a,b,c,d,e,f,g,h,i) DMPlexGetClosureIndices(a,b,c,d,f,g,i)
66+
# define DMPlexRestoreClosureIndices(a,b,c,d,e,f,g,h,i) DMPlexRestoreClosureIndices(a,b,c,d,f,g,i)
67+
#endif
68+
6269
// Auxiliary function to define CEED restrictions from DMPlex data
6370
static int CreateRestrictionPlex(Ceed ceed, CeedInt P, CeedInt ncomp,
6471
CeedElemRestriction *Erestrict, DM dm) {
@@ -78,8 +85,9 @@ static int CreateRestrictionPlex(Ceed ceed, CeedInt P, CeedInt ncomp,
7885
ierr = PetscMalloc1(nelem*P*P, &erestrict); CHKERRQ(ierr);
7986
for (c=cStart, eoffset = 0; c<cEnd; c++) {
8087
PetscInt numindices, *indices, i;
81-
ierr = DMPlexGetClosureIndices(dm, section, section, c, &numindices,
82-
&indices, NULL); CHKERRQ(ierr);
88+
ierr = DMPlexGetClosureIndices(dm, section, section, c, PETSC_TRUE,
89+
&numindices, &indices, NULL, NULL);
90+
CHKERRQ(ierr);
8391
for (i=0; i<numindices; i+=ncomp) {
8492
for (PetscInt j=0; j<ncomp; j++) {
8593
if (indices[i+j] != indices[i] + (PetscInt)(copysign(j, indices[i])))
@@ -90,8 +98,9 @@ static int CreateRestrictionPlex(Ceed ceed, CeedInt P, CeedInt ncomp,
9098
PetscInt loc = indices[i];
9199
erestrict[eoffset++] = loc;
92100
}
93-
ierr = DMPlexRestoreClosureIndices(dm, section, section, c, &numindices,
94-
&indices, NULL); CHKERRQ(ierr);
101+
ierr = DMPlexRestoreClosureIndices(dm, section, section, c, PETSC_TRUE,
102+
&numindices, &indices, NULL, NULL);
103+
CHKERRQ(ierr);
95104
}
96105

97106
// Setup CEED restriction

examples/petsc/setup.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
#endif
3939
#endif
4040

41+
#if PETSC_VERSION_LT(3,14,0)
42+
# define DMPlexGetClosureIndices(a,b,c,d,e,f,g,h,i) DMPlexGetClosureIndices(a,b,c,d,f,g,i)
43+
# define DMPlexRestoreClosureIndices(a,b,c,d,e,f,g,h,i) DMPlexRestoreClosureIndices(a,b,c,d,f,g,i)
44+
#endif
45+
4146
// -----------------------------------------------------------------------------
4247
// PETSc Operator Structs
4348
// -----------------------------------------------------------------------------
@@ -450,8 +455,9 @@ static int CreateRestrictionPlex(Ceed ceed, CeedInt P, CeedInt ncomp,
450455
ierr = PetscMalloc1(nelem*P*P*P, &erestrict); CHKERRQ(ierr);
451456
for (c=cStart, eoffset=0; c<cEnd; c++) {
452457
PetscInt numindices, *indices, i;
453-
ierr = DMPlexGetClosureIndices(dm, section, section, c, &numindices,
454-
&indices, NULL); CHKERRQ(ierr);
458+
ierr = DMPlexGetClosureIndices(dm, section, section, c, PETSC_TRUE,
459+
&numindices, &indices, NULL, NULL);
460+
CHKERRQ(ierr);
455461
for (i=0; i<numindices; i+=ncomp) {
456462
for (PetscInt j=0; j<ncomp; j++) {
457463
if (indices[i+j] != indices[i] + (PetscInt)(copysign(j, indices[i])))
@@ -462,8 +468,9 @@ static int CreateRestrictionPlex(Ceed ceed, CeedInt P, CeedInt ncomp,
462468
PetscInt loc = indices[i] >= 0 ? indices[i] : -(indices[i] + 1);
463469
erestrict[eoffset++] = loc;
464470
}
465-
ierr = DMPlexRestoreClosureIndices(dm, section, section, c, &numindices,
466-
&indices, NULL); CHKERRQ(ierr);
471+
ierr = DMPlexRestoreClosureIndices(dm, section, section, c, PETSC_TRUE,
472+
&numindices, &indices, NULL, NULL);
473+
CHKERRQ(ierr);
467474
}
468475

469476
// Setup CEED restriction

examples/petsc/setupsphere.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
#include "qfunctions/bps/bp3sphere.h"
3030
#include "qfunctions/bps/bp4sphere.h"
3131

32+
#if PETSC_VERSION_LT(3,14,0)
33+
# define DMPlexGetClosureIndices(a,b,c,d,e,f,g,h,i) DMPlexGetClosureIndices(a,b,c,d,f,g,i)
34+
# define DMPlexRestoreClosureIndices(a,b,c,d,e,f,g,h,i) DMPlexRestoreClosureIndices(a,b,c,d,f,g,i)
35+
#endif
36+
3237
// -----------------------------------------------------------------------------
3338
// PETSc Operator Structs
3439
// -----------------------------------------------------------------------------
@@ -382,8 +387,9 @@ static int CreateRestrictionPlex(Ceed ceed, CeedInt P, CeedInt ncomp,
382387
ierr = PetscMalloc1(nelem*P*P, &erestrict); CHKERRQ(ierr);
383388
for (c=cStart, eoffset = 0; c<cEnd; c++) {
384389
PetscInt numindices, *indices, i;
385-
ierr = DMPlexGetClosureIndices(dm, section, section, c, &numindices,
386-
&indices, NULL); CHKERRQ(ierr);
390+
ierr = DMPlexGetClosureIndices(dm, section, section, c, PETSC_TRUE,
391+
&numindices, &indices, NULL, NULL);
392+
CHKERRQ(ierr);
387393
for (i=0; i<numindices; i+=ncomp) {
388394
for (PetscInt j=0; j<ncomp; j++) {
389395
if (indices[i+j] != indices[i] + copysign(j, indices[i]))
@@ -394,8 +400,9 @@ static int CreateRestrictionPlex(Ceed ceed, CeedInt P, CeedInt ncomp,
394400
PetscInt loc = indices[i];
395401
erestrict[eoffset++] = loc;
396402
}
397-
ierr = DMPlexRestoreClosureIndices(dm, section, section, c, &numindices,
398-
&indices, NULL); CHKERRQ(ierr);
403+
ierr = DMPlexRestoreClosureIndices(dm, section, section, c, PETSC_TRUE,
404+
&numindices, &indices, NULL, NULL);
405+
CHKERRQ(ierr);
399406
}
400407

401408
// Setup CEED restriction

0 commit comments

Comments
 (0)