Skip to content

Commit

Permalink
combine "problem->convert_error.qfunction" in one QFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
LeilaGhaffari committed Jul 11, 2023
1 parent 71306b6 commit 81a3eae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
30 changes: 14 additions & 16 deletions examples/fluids/problems/newtonian.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,20 @@ PetscErrorCode NS_NEWTONIAN_IG(ProblemData *problem, DM dm, void *ctx, SimpleBC
// ------------------------------------------------------
// Setup Generic Newtonian IG Problem
// ------------------------------------------------------
problem->dim = 3;
problem->q_data_size_vol = 10;
problem->q_data_size_sur = 10;
problem->jac_data_size_sur = 11;
problem->setup_vol.qfunction = Setup;
problem->setup_vol.qfunction_loc = Setup_loc;
problem->setup_sur.qfunction = SetupBoundary;
problem->setup_sur.qfunction_loc = SetupBoundary_loc;
problem->error.qfunction = Newtonian_L2Error;
problem->error.qfunction_loc = Newtonian_L2Error_loc;
problem->non_zero_time = PETSC_FALSE;
problem->print_info = PRINT_NEWTONIAN;
problem->dim = 3;
problem->q_data_size_vol = 10;
problem->q_data_size_sur = 10;
problem->jac_data_size_sur = 11;
problem->setup_vol.qfunction = Setup;
problem->setup_vol.qfunction_loc = Setup_loc;
problem->setup_sur.qfunction = SetupBoundary;
problem->setup_sur.qfunction_loc = SetupBoundary_loc;
problem->error.qfunction = Newtonian_L2Error;
problem->error.qfunction_loc = Newtonian_L2Error_loc;
problem->convert_error.qfunction = Newtonian_ConvertL2Error;
problem->convert_error.qfunction_loc = Newtonian_ConvertL2Error_loc;
problem->non_zero_time = PETSC_FALSE;
problem->print_info = PRINT_NEWTONIAN;

// ------------------------------------------------------
// Create the libCEED context
Expand Down Expand Up @@ -151,8 +153,6 @@ PetscErrorCode NS_NEWTONIAN_IG(ProblemData *problem, DM dm, void *ctx, SimpleBC
problem->apply_inflow.qfunction_loc = BoundaryIntegral_Conserv_loc;
problem->apply_inflow_jacobian.qfunction = BoundaryIntegral_Jacobian_Conserv;
problem->apply_inflow_jacobian.qfunction_loc = BoundaryIntegral_Jacobian_Conserv_loc;
problem->convert_error.qfunction = Newtonian_L2ErrorAsPrimitive;
problem->convert_error.qfunction_loc = Newtonian_L2ErrorAsPrimitive_loc;
break;

case STATEVAR_PRIMITIVE:
Expand All @@ -166,8 +166,6 @@ PetscErrorCode NS_NEWTONIAN_IG(ProblemData *problem, DM dm, void *ctx, SimpleBC
problem->apply_inflow.qfunction_loc = BoundaryIntegral_Prim_loc;
problem->apply_inflow_jacobian.qfunction = BoundaryIntegral_Jacobian_Prim;
problem->apply_inflow_jacobian.qfunction_loc = BoundaryIntegral_Jacobian_Prim_loc;
problem->convert_error.qfunction = Newtonian_L2ErrorAsConservative;
problem->convert_error.qfunction_loc = Newtonian_L2ErrorAsConservative_loc;
break;
}

Expand Down
9 changes: 1 addition & 8 deletions examples/fluids/qfunctions/newtonian.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ CEED_QFUNCTION(Newtonian_L2Error)(void *ctx, CeedInt Q, const CeedScalar *const
// Source state variable: STATEVAR_CONSERVATIVE or STATEVAR_PRIMITIVE
// Target state variable: STATEVAR_PRIMITIVE or STATEVAR_CONSERVATIVE
// *****************************************************************************
CEED_QFUNCTION_HELPER int Newtonian_ConvertL2Error(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
CEED_QFUNCTION(Newtonian_ConvertL2Error)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
// Inputs
const CeedScalar(*X)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0];
const CeedScalar(*q_data)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[1];
Expand Down Expand Up @@ -130,13 +130,6 @@ CEED_QFUNCTION_HELPER int Newtonian_ConvertL2Error(void *ctx, CeedInt Q, const C
return 0;
}

CEED_QFUNCTION(Newtonian_L2ErrorAsPrimitive)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
return Newtonian_ConvertL2Error(ctx, Q, in, out);
}
CEED_QFUNCTION(Newtonian_L2ErrorAsConservative)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
return Newtonian_ConvertL2Error(ctx, Q, in, out);
}

// *****************************************************************************
// This QFunction implements the following formulation of Navier-Stokes with explicit time stepping method
//
Expand Down

0 comments on commit 81a3eae

Please sign in to comment.