Skip to content

Commit

Permalink
SWE: Fix set context bug after change in the interface
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriabarra committed Sep 23, 2020
1 parent c1af3ac commit 821e46b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
13 changes: 11 additions & 2 deletions examples/fluids/shallow-water/shallowwater.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,19 @@ int main(int argc, char **argv) {
// Free edgenodes structure array
ierr = PetscFree(edgenodes); CHKERRQ(ierr);

// Setup libCEED's objects
// Setup libCEED's objects and contexts
ierr = PetscMalloc1(1, &ceeddata); CHKERRQ(ierr);
CeedQFunctionContextCreate(ceed, &ceeddata->physCtx);
CeedQFunctionContextSetData(ceeddata->physCtx, CEED_MEM_HOST,
CEED_USE_POINTER, sizeof physCtxData,
&physCtxData);
CeedQFunctionContextCreate(ceed, &ceeddata->problCtx);
CeedQFunctionContextSetData(ceeddata->problCtx, CEED_MEM_HOST,
CEED_USE_POINTER, sizeof problCtxData,
&problCtxData);

ierr = SetupLibceed(dm, ceed, degree, qextra, ncompx, ncompq, user,
ceeddata, problem, &physCtxData, &problCtxData);
ceeddata, problem);
CHKERRQ(ierr);

// Set up PETSc context
Expand Down
10 changes: 1 addition & 9 deletions examples/fluids/shallow-water/src/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,7 @@ PetscErrorCode VectorPlacePetscVec(CeedVector c, Vec p) {

PetscErrorCode SetupLibceed(DM dm, Ceed ceed, CeedInt degree, CeedInt qextra,
PetscInt ncompx, PetscInt ncompq, User user,
CeedData data, problemData *problem,
PhysicsContext physCtxData,
ProblemContext problCtxData) {
CeedData data, problemData *problem) {
int ierr;
DM dmcoord;
Vec Xloc;
Expand Down Expand Up @@ -831,13 +829,7 @@ PetscErrorCode SetupLibceed(DM dm, Ceed ceed, CeedInt degree, CeedInt qextra,
user->op_jacobian = op_jacobian;

// Set up the libCEED context
CeedQFunctionContextCreate(ceed, &data->physCtx);
CeedQFunctionContextSetData(data->physCtx, CEED_MEM_HOST, CEED_USE_POINTER,
sizeof physCtxData, &physCtxData);
CeedQFunctionSetContext(qf_ics, data->physCtx);
CeedQFunctionContextCreate(ceed, &data->problCtx);
CeedQFunctionContextSetData(data->problCtx, CEED_MEM_HOST, CEED_USE_POINTER,
sizeof problCtxData, &problCtxData);
CeedQFunctionSetContext(qf_explicit, data->problCtx);
CeedQFunctionSetContext(qf_implicit, data->problCtx);
CeedQFunctionSetContext(qf_jacobian, data->problCtx);
Expand Down
4 changes: 1 addition & 3 deletions examples/fluids/shallow-water/sw_headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ PetscErrorCode CreateRestrictionPlex(Ceed ceed, DM dm, CeedInt P, CeedInt ncomp,
// Auxiliary function to set up libCEED objects for a given degree
PetscErrorCode SetupLibceed(DM dm, Ceed ceed, CeedInt degree, CeedInt qextra,
const PetscInt ncompx, PetscInt ncompq, User user,
CeedData data, problemData *problem,
PhysicsContext physCtxData,
ProblemContext problCtxData);
CeedData data, problemData *problem);

// -----------------------------------------------------------------------------
// RHS (Explicit part in time-stepper) function setup
Expand Down

0 comments on commit 821e46b

Please sign in to comment.