4949static 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
6370static 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
0 commit comments