Skip to content

Commit 31f2588

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

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
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

0 commit comments

Comments
 (0)