Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fluids: Compatability for PETSc w/ 64bit ints #1234

Merged
merged 3 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/fluids/navierstokes.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ int main(int argc, char **argv) {
}
// Mesh
const PetscInt num_comp_q = 5;
CeedInt glob_dofs, owned_dofs;
PetscInt glob_dofs, owned_dofs;
PetscInt glob_nodes, local_nodes;
const CeedInt num_P = app_ctx->degree + 1, num_Q = num_P + app_ctx->q_extra;
// -- Get global size
Expand Down
11 changes: 7 additions & 4 deletions examples/fluids/navierstokes.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,7 @@ struct ProblemData_private {
CeedScalar dm_scale;
ProblemQFunctionSpec setup_vol, setup_sur, ics, apply_vol_rhs, apply_vol_ifunction, apply_vol_ijacobian, apply_inflow, apply_outflow,
apply_freestream, apply_inflow_jacobian, apply_outflow_jacobian, apply_freestream_jacobian;
bool non_zero_time;
PetscErrorCode (*bc)(PetscInt, PetscReal, const PetscReal[], PetscInt, PetscScalar[], void *);
void *bc_ctx;
bool non_zero_time;
PetscBool bc_from_ics, use_strong_bc_ceed;
PetscErrorCode (*print_info)(ProblemData *, AppCtx);
};
Expand Down Expand Up @@ -399,7 +397,9 @@ PetscErrorCode SetupICsFromBinary(MPI_Comm comm, AppCtx app_ctx, Vec Q);
PetscErrorCode SetBCsFromICs_NS(DM dm, Vec Q, Vec Q_loc);

// Versioning token for binary checkpoints
extern const PetscInt FLUIDS_FILE_TOKEN;
extern const PetscInt32 FLUIDS_FILE_TOKEN; // for backwards compatibility
extern const PetscInt32 FLUIDS_FILE_TOKEN_32;
extern const PetscInt32 FLUIDS_FILE_TOKEN_64;

// Create appropriate mass qfunction based on number of components N
PetscErrorCode CreateMassQFunction(Ceed ceed, CeedInt N, CeedInt q_data_size, CeedQFunction *qf);
Expand All @@ -415,6 +415,9 @@ PetscErrorCode PHASTADatFileGetNRows(const MPI_Comm comm, const char path[PETSC_

PetscErrorCode PHASTADatFileReadToArrayReal(const MPI_Comm comm, const char path[PETSC_MAX_PATH_LEN], PetscReal array[]);

PetscErrorCode IntArrayC2P(PetscInt num_entries, CeedInt **array_ceed, PetscInt **array_petsc);
PetscErrorCode IntArrayP2C(PetscInt num_entries, PetscInt **array_petsc, CeedInt **array_ceed);

// -----------------------------------------------------------------------------
// Turbulence Statistics Collection Functions
// -----------------------------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions examples/fluids/problems/advection.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ PetscErrorCode NS_ADVECTION(ProblemData *problem, DM dm, void *ctx, SimpleBC bc)
problem->apply_vol_ifunction.qfunction_loc = IFunction_Advection_loc;
problem->apply_inflow.qfunction = Advection_InOutFlow;
problem->apply_inflow.qfunction_loc = Advection_InOutFlow_loc;
problem->bc = Exact_Advection;
problem->bc_ctx = setup_context;
problem->non_zero_time = PETSC_FALSE;
problem->print_info = PRINT_ADVECTION;

Expand Down
2 changes: 0 additions & 2 deletions examples/fluids/problems/advection2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ PetscErrorCode NS_ADVECTION2D(ProblemData *problem, DM dm, void *ctx, SimpleBC b
problem->apply_vol_ifunction.qfunction_loc = IFunction_Advection2d_loc;
problem->apply_inflow.qfunction = Advection2d_InOutFlow;
problem->apply_inflow.qfunction_loc = Advection2d_InOutFlow_loc;
problem->bc = Exact_Advection2d;
problem->bc_ctx = setup_context;
problem->non_zero_time = PETSC_TRUE;
problem->print_info = PRINT_ADVECTION2D;

Expand Down
14 changes: 7 additions & 7 deletions examples/fluids/problems/blasius.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ PetscErrorCode ComputeChebyshevCoefficients(BlasiusContext blasius) {
}

static PetscErrorCode GetYNodeLocs(const MPI_Comm comm, const char path[PETSC_MAX_PATH_LEN], PetscReal **pynodes, PetscInt *nynodes) {
PetscInt ndims, dims[2];
int ndims, dims[2];
FILE *fp;
const PetscInt char_array_len = 512;
char line[char_array_len];
Expand All @@ -132,8 +132,7 @@ static PetscErrorCode GetYNodeLocs(const MPI_Comm comm, const char path[PETSC_MA
PetscCall(PetscSynchronizedFGets(comm, fp, char_array_len, line));
PetscCall(PetscStrToArray(line, ' ', &ndims, &array));
PetscCheck(ndims == dims[1], comm, PETSC_ERR_FILE_UNEXPECTED,
"Line %" PetscInt_FMT " of %s does not contain correct number of columns (%" PetscInt_FMT " instead of %" PetscInt_FMT ")", i, path,
ndims, dims[1]);
"Line %" PetscInt_FMT " of %s does not contain correct number of columns (%d instead of %d)", i, path, ndims, dims[1]);

node_locs[i] = (PetscReal)atof(array[0]);
}
Expand Down Expand Up @@ -207,11 +206,12 @@ static PetscErrorCode ModifyMesh(MPI_Comm comm, DM dm, PetscInt dim, PetscReal g
*node_locs = temp_node_locs;
} else {
PetscCheck(*num_node_locs >= faces[1] + 1, comm, PETSC_ERR_FILE_UNEXPECTED,
"The y_node_locs_path has too few locations; There are %d + 1 nodes, but only %d locations given", faces[1] + 1, *num_node_locs);
"The y_node_locs_path has too few locations; There are %" PetscInt_FMT " + 1 nodes, but only %" PetscInt_FMT " locations given",
faces[1] + 1, *num_node_locs);
if (*num_node_locs > faces[1] + 1) {
PetscCall(PetscPrintf(comm,
"WARNING: y_node_locs_path has more locations (%d) "
"than the mesh has nodes (%d). This maybe unintended.\n",
"WARNING: y_node_locs_path has more locations (%" PetscInt_FMT ") "
"than the mesh has nodes (%" PetscInt_FMT "). This maybe unintended.\n",
*num_node_locs, faces[1] + 1));
}
PetscScalar max_y = (*node_locs)[faces[1]];
Expand Down Expand Up @@ -252,7 +252,7 @@ PetscErrorCode NS_BLASIUS(ProblemData *problem, DM dm, void *ctx, SimpleBC bc) {
CeedScalar T_wall = 288.; // K
CeedScalar delta0 = 4.2e-3; // m
CeedScalar P0 = 1.01e5; // Pa
CeedInt N = 20; // Number of Chebyshev terms
PetscInt N = 20; // Number of Chebyshev terms
PetscBool weakT = PETSC_FALSE; // weak density or temperature
PetscReal mesh_refine_height = 5.9e-4; // m
PetscReal mesh_growth = 1.08; // [-]
Expand Down
2 changes: 0 additions & 2 deletions examples/fluids/problems/eulervortex.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ PetscErrorCode NS_EULER_VORTEX(ProblemData *problem, DM dm, void *ctx, SimpleBC
problem->apply_inflow.qfunction_loc = TravelingVortex_Inflow_loc;
problem->apply_outflow.qfunction = Euler_Outflow;
problem->apply_outflow.qfunction_loc = Euler_Outflow_loc;
problem->bc = Exact_Euler;
problem->bc_ctx = euler_ctx;
problem->non_zero_time = PETSC_TRUE;
problem->print_info = PRINT_EULER_VORTEX;

Expand Down
2 changes: 0 additions & 2 deletions examples/fluids/problems/newtonian.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ PetscErrorCode NS_NEWTONIAN_IG(ProblemData *problem, DM dm, void *ctx, SimpleBC
problem->setup_vol.qfunction_loc = Setup_loc;
problem->setup_sur.qfunction = SetupBoundary;
problem->setup_sur.qfunction_loc = SetupBoundary_loc;
problem->bc = NULL;
problem->bc_ctx = NULL;
problem->non_zero_time = PETSC_FALSE;
problem->print_info = PRINT_NEWTONIAN;

Expand Down
6 changes: 4 additions & 2 deletions examples/fluids/problems/sgs_dd_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ PetscErrorCode SGS_DD_ModelSetupNodalEvaluation(Ceed ceed, User user, CeedData c
SGS_DD_Data sgs_dd_data = user->sgs_dd_data;
CeedQFunction qf_multiplicity, qf_sgs_dd_nodal;
CeedOperator op_multiplicity, op_sgs_dd_nodal;
CeedInt num_elem, elem_size, num_comp_q, dim, num_qpts_1d, num_comp_grad_velo, num_comp_x, num_comp_grid_aniso;
CeedInt num_elem, elem_size, num_comp_q, num_qpts_1d, num_comp_grad_velo, num_comp_x, num_comp_grid_aniso;
PetscInt dim;
CeedVector multiplicity, inv_multiplicity;
CeedElemRestriction elem_restr_inv_multiplicity, elem_restr_grad_velo, elem_restr_sgs;

Expand Down Expand Up @@ -160,7 +161,8 @@ PetscErrorCode SGS_DD_ModelSetupNodalEvaluation(Ceed ceed, User user, CeedData c
// @brief Create CeedOperator to compute SGS contribution to the residual
PetscErrorCode SGS_ModelSetupNodalIFunction(Ceed ceed, User user, CeedData ceed_data, SGS_DD_ModelSetupData sgs_dd_setup_data) {
SGS_DD_Data sgs_dd_data = user->sgs_dd_data;
CeedInt dim, num_comp_q, num_comp_qd, num_comp_x, num_qpts_1d, num_nodes_1d;
CeedInt num_comp_q, num_comp_qd, num_comp_x, num_qpts_1d, num_nodes_1d;
PetscInt dim;
CeedQFunction qf_sgs_apply;
CeedOperator op_sgs_apply;
CeedBasis basis_sgs;
Expand Down
2 changes: 0 additions & 2 deletions examples/fluids/problems/shocktube.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ PetscErrorCode NS_SHOCKTUBE(ProblemData *problem, DM dm, void *ctx, SimpleBC bc)
problem->apply_vol_rhs.qfunction_loc = EulerShockTube_loc;
problem->apply_vol_ifunction.qfunction = NULL;
problem->apply_vol_ifunction.qfunction_loc = NULL;
problem->bc = Exact_ShockTube;
problem->bc_ctx = setup_context;
problem->non_zero_time = PETSC_FALSE;
problem->print_info = PRINT_SHOCKTUBE;

Expand Down
16 changes: 8 additions & 8 deletions examples/fluids/problems/stg_shur14.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ PetscErrorCode CalcCholeskyDecomp(MPI_Comm comm, PetscInt nprofs, const CeedScal
* @param[in,out] stg_ctx STGShur14Context where the data will be loaded into
*/
static PetscErrorCode ReadSTGInflow(const MPI_Comm comm, const char path[PETSC_MAX_PATH_LEN], STGShur14Context stg_ctx) {
PetscInt ndims, dims[2];
PetscInt dims[2];
int ndims;
FILE *fp;
const PetscInt char_array_len = 512;
char line[char_array_len];
Expand All @@ -81,8 +82,7 @@ static PetscErrorCode ReadSTGInflow(const MPI_Comm comm, const char path[PETSC_M
PetscCall(PetscSynchronizedFGets(comm, fp, char_array_len, line));
PetscCall(PetscStrToArray(line, ' ', &ndims, &array));
PetscCheck(ndims == dims[1], comm, PETSC_ERR_FILE_UNEXPECTED,
"Line %" PetscInt_FMT " of %s does not have correct number of columns (%" PetscInt_FMT " instead of %" PetscInt_FMT ")", i, path,
ndims, dims[1]);
"Line %" PetscInt_FMT " of %s does not have correct number of columns (%d instead of %" PetscInt_FMT ")", i, path, ndims, dims[1]);

wall_dist[i] = (CeedScalar)atof(array[0]);
ubar[0][i] = (CeedScalar)atof(array[1]);
Expand Down Expand Up @@ -119,7 +119,8 @@ static PetscErrorCode ReadSTGInflow(const MPI_Comm comm, const char path[PETSC_M
* @param[in,out] stg_ctx STGShur14Context where the data will be loaded into
*/
static PetscErrorCode ReadSTGRand(const MPI_Comm comm, const char path[PETSC_MAX_PATH_LEN], STGShur14Context stg_ctx) {
PetscInt ndims, dims[2];
PetscInt dims[2];
int ndims;
FILE *fp;
const PetscInt char_array_len = 512;
char line[char_array_len];
Expand All @@ -136,8 +137,7 @@ static PetscErrorCode ReadSTGRand(const MPI_Comm comm, const char path[PETSC_MAX
PetscCall(PetscSynchronizedFGets(comm, fp, char_array_len, line));
PetscCall(PetscStrToArray(line, ' ', &ndims, &array));
PetscCheck(ndims == dims[1], comm, PETSC_ERR_FILE_UNEXPECTED,
"Line %" PetscInt_FMT " of %s does not have correct number of columns (%" PetscInt_FMT " instead of %" PetscInt_FMT ")", i, path,
ndims, dims[1]);
"Line %" PetscInt_FMT " of %s does not have correct number of columns (%d instead of %" PetscInt_FMT ")", i, path, ndims, dims[1]);

d[0][i] = (CeedScalar)atof(array[0]);
d[1][i] = (CeedScalar)atof(array[1]);
Expand Down Expand Up @@ -173,8 +173,8 @@ PetscErrorCode GetSTGContextData(const MPI_Comm comm, const DM dm, char stg_infl
PetscCall(PHASTADatFileGetNRows(comm, stg_rand_path, &nmodes));
PetscCall(PHASTADatFileGetNRows(comm, stg_inflow_path, &nprofs));
PetscCheck(nmodes < STG_NMODES_MAX, comm, PETSC_ERR_SUP,
"Number of wavemodes in %s (%" PetscInt_FMT ") exceeds STG_NMODES_MAX (%" PetscInt_FMT "). Change size of STG_NMODES_MAX and recompile",
stg_rand_path, nmodes, STG_NMODES_MAX);
"Number of wavemodes in %s (%" PetscInt_FMT ") exceeds STG_NMODES_MAX (%d). Change size of STG_NMODES_MAX and recompile", stg_rand_path,
nmodes, STG_NMODES_MAX);

{
STGShur14Context temp_ctx;
Expand Down
9 changes: 6 additions & 3 deletions examples/fluids/src/differential_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
PetscErrorCode DifferentialFilterCreateOperators(Ceed ceed, User user, CeedData ceed_data, CeedQFunctionContext diff_filter_qfctx) {
DiffFilterData diff_filter = user->diff_filter;
DM dm_filter = diff_filter->dm_filter;
CeedInt num_comp_q, num_comp_qd, dim, num_qpts_1d, num_nodes_1d, num_comp_x;
CeedInt num_comp_q, num_comp_qd, num_qpts_1d, num_nodes_1d, num_comp_x;
PetscInt dim;

PetscFunctionBeginUser;
PetscCall(DMGetDimension(user->dm, &dim));
Expand Down Expand Up @@ -81,7 +82,8 @@ PetscErrorCode DifferentialFilterCreateOperators(Ceed ceed, User user, CeedData
CeedOperator op_lhs;
OperatorApplyContext mat_ctx;
Mat mat_lhs;
CeedInt num_comp_qd, dim, num_comp_grid_aniso;
CeedInt num_comp_qd;
PetscInt dim, num_comp_grid_aniso;
CeedElemRestriction elem_restr_grid_aniso;
CeedVector grid_aniso_ceed;

Expand Down Expand Up @@ -113,7 +115,8 @@ PetscErrorCode DifferentialFilterCreateOperators(Ceed ceed, User user, CeedData
CeedQFunctionCreateInterior(ceed, 1, DifferentialFilter_LHS_11, DifferentialFilter_LHS_11_loc, &qf_lhs);
break;
default:
SETERRQ(PetscObjectComm((PetscObject)user->dm), PETSC_ERR_SUP, "Differential filtering not available for (%d) components", num_comp_filter);
SETERRQ(PetscObjectComm((PetscObject)user->dm), PETSC_ERR_SUP, "Differential filtering not available for (%" PetscInt_FMT ") components",
num_comp_filter);
}

CeedQFunctionSetContext(qf_lhs, diff_filter_qfctx);
Expand Down
18 changes: 10 additions & 8 deletions examples/fluids/src/grid_anisotropy_tensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ PetscErrorCode GridAnisotropyTensorProjectionSetupApply(Ceed ceed, User user, Ce
CeedOperator op_rhs_assemble, op_mass;
CeedQFunction qf_rhs_assemble, qf_mass;
CeedBasis basis_grid_aniso;
PetscInt dim, q_data_size, num_qpts_1d, num_nodes_1d;
PetscInt dim;
CeedInt num_qpts_1d, num_nodes_1d, q_data_size;
MPI_Comm comm = PetscObjectComm((PetscObject)user->dm);
KSP ksp;

Expand Down Expand Up @@ -133,33 +134,34 @@ PetscErrorCode GridAnisotropyTensorProjectionSetupApply(Ceed ceed, User user, Ce
}

PetscErrorCode GridAnisotropyTensorCalculateCollocatedVector(Ceed ceed, User user, CeedData ceed_data, CeedElemRestriction *elem_restr_grid_aniso,
CeedVector *aniso_colloc_ceed, PetscInt *num_comp_grid_aniso) {
PetscInt dim, q_data_size, num_qpts_1d, num_nodes_1d, loc_num_elem;
CeedVector *aniso_colloc_ceed, PetscInt *num_comp_aniso) {
PetscInt dim;
CeedInt q_data_size, num_qpts_1d, num_nodes_1d, loc_num_elem;
CeedQFunction qf_colloc;
CeedOperator op_colloc;
CeedBasis basis_grid_aniso;

PetscFunctionBeginUser;
// -- Get Pre-requisite things
*num_comp_grid_aniso = 7;
*num_comp_aniso = 7;
PetscCall(DMGetDimension(user->dm, &dim));
CeedBasisGetNumQuadraturePoints1D(ceed_data->basis_q, &num_qpts_1d);
CeedBasisGetNumNodes1D(ceed_data->basis_q, &num_nodes_1d);
CeedElemRestrictionGetNumComponents(ceed_data->elem_restr_qd_i, &q_data_size);

PetscCall(GetRestrictionForDomain(ceed, user->dm, 0, 0, 0, 0, num_qpts_1d, *num_comp_grid_aniso, NULL, NULL, elem_restr_grid_aniso));
PetscCall(GetRestrictionForDomain(ceed, user->dm, 0, 0, 0, 0, num_qpts_1d, *num_comp_aniso, NULL, NULL, elem_restr_grid_aniso));

CeedInt Q_dim = CeedIntPow(num_qpts_1d, dim);
CeedElemRestrictionGetNumElements(ceed_data->elem_restr_q, &loc_num_elem);
CeedElemRestrictionCreateStrided(ceed, loc_num_elem, Q_dim, *num_comp_grid_aniso, *num_comp_grid_aniso * loc_num_elem * Q_dim, CEED_STRIDES_BACKEND,
CeedElemRestrictionCreateStrided(ceed, loc_num_elem, Q_dim, *num_comp_aniso, *num_comp_aniso * loc_num_elem * Q_dim, CEED_STRIDES_BACKEND,
elem_restr_grid_aniso);

CeedBasisCreateTensorH1Lagrange(ceed, dim, *num_comp_grid_aniso, num_nodes_1d, num_qpts_1d, CEED_GAUSS, &basis_grid_aniso);
CeedBasisCreateTensorH1Lagrange(ceed, dim, *num_comp_aniso, num_nodes_1d, num_qpts_1d, CEED_GAUSS, &basis_grid_aniso);

// -- Build collocation operator
CeedQFunctionCreateInterior(ceed, 1, AnisotropyTensorCollocate, AnisotropyTensorCollocate_loc, &qf_colloc);
CeedQFunctionAddInput(qf_colloc, "qdata", q_data_size, CEED_EVAL_NONE);
CeedQFunctionAddOutput(qf_colloc, "v", *num_comp_grid_aniso, CEED_EVAL_NONE);
CeedQFunctionAddOutput(qf_colloc, "v", *num_comp_aniso, CEED_EVAL_NONE);

CeedOperatorCreate(ceed, qf_colloc, NULL, NULL, &op_colloc);
CeedOperatorSetField(op_colloc, "qdata", ceed_data->elem_restr_qd_i, CEED_BASIS_COLLOCATED, ceed_data->q_data);
Expand Down
Loading