Skip to content

Commit a653fb1

Browse files
committed
SWE: Update DMPlexCreateSphereMesh() call after change in PETSc's API and add compatibility macro
1 parent 854251d commit a653fb1

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

examples/fluids/shallow-water/qfunctions/geostrophic.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ CEED_QFUNCTION(ICsSW)(void *ctx, CeedInt Q,
8383
const CeedScalar x[] = {X[0][i], X[1][i], X[2][i]};
8484
CeedScalar q[5];
8585

86-
Exact_SW(2, 0., x, 5, q, ctx);
86+
Exact_SW(2, 0., x, 3, q, ctx);
8787

88-
for (CeedInt j=0; j<5; j++)
88+
for (CeedInt j=0; j<3; j++)
8989
q0[j][i] = q[j];
9090
} // End of Quadrature Point Loop
9191

@@ -153,15 +153,15 @@ CEED_QFUNCTION(SWExplicit)(void *ctx, CeedInt Q, const CeedScalar *const *in,
153153
// The Physics
154154
// Explicit spatial terms of G_1(t,q):
155155
// Explicit terms multiplying v
156-
// - (omega + f) * khat curl u - grad(|u|^2/2)
156+
// - (omega + f) * khat curl u - grad(|u|^2/2) // TODO: needs fix with weak form
157157
v[0][i] = - wdetJ*(u[0]*du[0][0] + u[1]*du[0][1] + f*u[1]);
158158
// No explicit terms multiplying dv
159159
dv[0][0][i] = 0;
160160
dv[1][0][i] = 0;
161161

162162
// Explicit spatial terms of G_2(t,q):
163163
// Explicit terms multiplying v
164-
// - (omega + f) * khat curl u - grad(|u|^2/2)
164+
// - (omega + f) * khat curl u - grad(|u|^2/2) // TODO: needs fix with weak form
165165
v[1][i] = - wdetJ*(u[0]*du[1][0] + u[1]*du[1][1] - f*u[0]);
166166
// No explicit terms multiplying dv
167167
dv[0][1][i] = 0;
@@ -210,9 +210,9 @@ CEED_QFUNCTION(SWImplicit)(void *ctx, CeedInt Q, const CeedScalar *const *in,
210210
(*dv)[3][CEED_Q_VLA] = (CeedScalar(*)[3][CEED_Q_VLA])out[1];
211211
// *INDENT-ON*
212212
// Context
213-
const PhysicsContext context = (PhysicsContext)ctx;
214-
const CeedScalar g = context->g;
215-
const CeedScalar H0 = context->H0;
213+
const PhysicsContext context = (PhysicsContext)ctx;
214+
const CeedScalar g = context->g;
215+
const CeedScalar H0 = context->H0;
216216

217217
CeedPragmaSIMD
218218
// Quadrature Point Loop
@@ -299,9 +299,9 @@ CEED_QFUNCTION(SWJacobian)(void *ctx, CeedInt Q, const CeedScalar *const *in,
299299
CeedScalar (*deltadvdX)[3][CEED_Q_VLA] = (CeedScalar(*)[3][CEED_Q_VLA])out[0];
300300
// *INDENT-ON*
301301
// Context
302-
const PhysicsContext context = (PhysicsContext)ctx;
303-
const CeedScalar g = context->g;
304-
const CeedScalar H0 = context->H0;
302+
const PhysicsContext context = (PhysicsContext)ctx;
303+
const CeedScalar g = context->g;
304+
const CeedScalar H0 = context->H0;
305305

306306
CeedPragmaSIMD
307307
// Quadrature Point Loop

examples/fluids/shallow-water/shallowwater.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ int main(int argc, char **argv) {
223223
} else {
224224
// Create the mesh as a 0-refined sphere. This will create a cubic surface, not a box.
225225
PetscBool simplex = PETSC_FALSE;
226-
ierr = DMPlexCreateSphereMesh(PETSC_COMM_WORLD, topodim, simplex, &dm);
226+
ierr = DMPlexCreateSphereMesh(PETSC_COMM_WORLD, topodim, simplex,
227+
phys_ctx.R, &dm);
227228
CHKERRQ(ierr);
228229
// Set the object name
229230
ierr = PetscObjectSetName((PetscObject)dm, "Sphere"); CHKERRQ(ierr);

examples/fluids/shallow-water/src/setup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
# define DMPlexRestoreClosureIndices(a,b,c,d,e,f,g,h,i) DMPlexRestoreClosureIndices(a,b,c,d,f,g,i)
3535
#endif
3636

37+
#if PETSC_VERSION_LT(3,14,0)
38+
# define DMPlexCreateSphereMesh(a,b,c,d,e) DMPlexCreateSphereMesh(a,b,c,e)
39+
#endif
40+
3741
problemData problemOptions[] = {
3842
[SWE_ADVECTION] = {
3943
.topodim = 2,

0 commit comments

Comments
 (0)