Skip to content

Commit 050b365

Browse files
committed
SWE: Inside Setup QFunction make sure to project coordinate field onto unit sphere
1 parent 123df56 commit 050b365

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#ifndef setupgeo_h
2121
#define setupgeo_h
2222

23+
#include "../sw_headers.h"
24+
2325
#ifndef __CUDACC__
2426
# include <math.h>
2527
#endif
@@ -67,15 +69,23 @@ CEED_QFUNCTION(SetupGeo)(void *ctx, CeedInt Q,
6769
// Outputs
6870
CeedScalar (*qdata)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0];
6971
// *INDENT-ON*
72+
// Context
73+
const PhysicsContext context = (PhysicsContext)ctx;
74+
const CeedScalar R = context->R;
7075

7176
CeedPragmaSIMD
7277
// Quadrature Point Loop
7378
for (CeedInt i=0; i<Q; i++) {
7479
// Read global Cartesian coordinates
75-
const CeedScalar xx[3] = {X[0][i],
76-
X[1][i],
77-
X[2][i]
78-
};
80+
CeedScalar xx[3] = {X[0][i],
81+
X[1][i],
82+
X[2][i]
83+
};
84+
// Project quadrature point coordinates to sphere
85+
CeedScalar rad = sqrt(xx[0]*xx[0] + xx[1]*xx[1] + xx[2]*xx[2]);
86+
xx[0] *= R / rad;
87+
xx[1] *= R / rad;
88+
xx[2] *= R / rad;
7989
// Read dxxdX Jacobian entries, stored in columns
8090
// J_00 J_10
8191
// J_01 J_11

examples/fluids/shallow-water/shallowwater.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int main(int argc, char **argv) {
6363
const PetscInt ncompx = 3;
6464
PetscInt viz_refine = 0;
6565
PetscBool read_mesh, simplex, test;
66-
PetscInt topodim = 2, dim = 3, ncompq = 3, lnodes;
66+
PetscInt topodim = 2, ncompq = 3, lnodes;
6767
// libCEED context
6868
char ceedresource[PETSC_MAX_PATH_LEN] = "/cpu/self",
6969
filename[PETSC_MAX_PATH_LEN];

0 commit comments

Comments
 (0)