Skip to content

Commit

Permalink
SWE: Inside Setup QFunction make sure to project coordinate field ont…
Browse files Browse the repository at this point in the history
…o unit sphere
  • Loading branch information
valeriabarra committed Sep 3, 2020
1 parent 123df56 commit 050b365
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions examples/fluids/shallow-water/qfunctions/setup_geo.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifndef setupgeo_h
#define setupgeo_h

#include "../sw_headers.h"

#ifndef __CUDACC__
# include <math.h>
#endif
Expand Down Expand Up @@ -67,15 +69,23 @@ CEED_QFUNCTION(SetupGeo)(void *ctx, CeedInt Q,
// Outputs
CeedScalar (*qdata)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0];
// *INDENT-ON*
// Context
const PhysicsContext context = (PhysicsContext)ctx;
const CeedScalar R = context->R;

CeedPragmaSIMD
// Quadrature Point Loop
for (CeedInt i=0; i<Q; i++) {
// Read global Cartesian coordinates
const CeedScalar xx[3] = {X[0][i],
X[1][i],
X[2][i]
};
CeedScalar xx[3] = {X[0][i],
X[1][i],
X[2][i]
};
// Project quadrature point coordinates to sphere
CeedScalar rad = sqrt(xx[0]*xx[0] + xx[1]*xx[1] + xx[2]*xx[2]);
xx[0] *= R / rad;
xx[1] *= R / rad;
xx[2] *= R / rad;
// Read dxxdX Jacobian entries, stored in columns
// J_00 J_10
// J_01 J_11
Expand Down
2 changes: 1 addition & 1 deletion examples/fluids/shallow-water/shallowwater.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int main(int argc, char **argv) {
const PetscInt ncompx = 3;
PetscInt viz_refine = 0;
PetscBool read_mesh, simplex, test;
PetscInt topodim = 2, dim = 3, ncompq = 3, lnodes;
PetscInt topodim = 2, ncompq = 3, lnodes;
// libCEED context
char ceedresource[PETSC_MAX_PATH_LEN] = "/cpu/self",
filename[PETSC_MAX_PATH_LEN];
Expand Down

0 comments on commit 050b365

Please sign in to comment.