From e47e7211c00841e7c78d0692f1b8f2c171f41b93 Mon Sep 17 00:00:00 2001 From: James Wright Date: Mon, 19 Jun 2023 14:49:22 -0600 Subject: [PATCH] WIP --- examples/fluids/navierstokes.h | 3 ++- examples/fluids/src/misc.c | 9 ++++++--- examples/fluids/src/setupts.c | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/fluids/navierstokes.h b/examples/fluids/navierstokes.h index 8a2058a0e7..d32040de6a 100644 --- a/examples/fluids/navierstokes.h +++ b/examples/fluids/navierstokes.h @@ -397,7 +397,8 @@ 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 int32_t FLUIDS_FILE_TOKEN_64; +extern const int32_t FLUIDS_FILE_TOKEN_32; // Create appropriate mass qfunction based on number of components N PetscErrorCode CreateMassQFunction(Ceed ceed, CeedInt N, CeedInt q_data_size, CeedQFunction *qf); diff --git a/examples/fluids/src/misc.c b/examples/fluids/src/misc.c index f5d6f2bfb1..66de1a2e4b 100644 --- a/examples/fluids/src/misc.c +++ b/examples/fluids/src/misc.c @@ -92,13 +92,15 @@ PetscErrorCode DMPlexInsertBoundaryValues_NS(DM dm, PetscBool insert_essential, // @brief Load vector from binary file, possibly with embedded solution time and step number PetscErrorCode LoadFluidsBinaryVec(MPI_Comm comm, PetscViewer viewer, Vec Q, PetscReal *time, PetscInt *step_number) { - PetscInt token, file_step_number; + PetscInt file_step_number; + int32_t token; PetscReal file_time; PetscFunctionBeginUser; // Attempt PetscCall(PetscViewerBinaryRead(viewer, &token, 1, NULL, PETSC_INT)); - if (token == FLUIDS_FILE_TOKEN) { // New style format; we're reading a file with step number and time in the header + if (token == FLUIDS_FILE_TOKEN_32 || + token == FLUIDS_FILE_TOKEN_64) { // New style format; we're reading a file with step number and time in the header PetscCall(PetscViewerBinaryRead(viewer, &file_step_number, 1, NULL, PETSC_INT)); PetscCall(PetscViewerBinaryRead(viewer, &file_time, 1, NULL, PETSC_REAL)); if (time) *time = file_time; @@ -208,7 +210,8 @@ PetscErrorCode PostProcess_NS(TS ts, CeedData ceed_data, DM dm, ProblemData *pro PetscFunctionReturn(0); } -const PetscInt FLUIDS_FILE_TOKEN = 0xceedf00; +const int32_t FLUIDS_FILE_TOKEN_64 = 0xceedf64; +const int32_t FLUIDS_FILE_TOKEN_32 = 0xceedf32; // Gather initial Q values in case of continuation of simulation PetscErrorCode SetupICsFromBinary(MPI_Comm comm, AppCtx app_ctx, Vec Q) { diff --git a/examples/fluids/src/setupts.c b/examples/fluids/src/setupts.c index f755fe2af5..9f4c74550e 100644 --- a/examples/fluids/src/setupts.c +++ b/examples/fluids/src/setupts.c @@ -365,8 +365,8 @@ PetscErrorCode WriteOutput(User user, Vec Q, PetscInt step_no, PetscScalar time) } PetscCall(PetscViewerBinaryOpen(user->comm, file_path, FILE_MODE_WRITE, &viewer)); - PetscInt token = FLUIDS_FILE_TOKEN; - PetscCall(PetscViewerBinaryWrite(viewer, &token, 1, PETSC_INT)); + // int32_t token = FLUIDS_FILE_TOKEN; + // PetscCall(PetscViewerBinaryWrite(viewer, &token, 1, PETSC_INT)); PetscCall(PetscViewerBinaryWrite(viewer, &step_no, 1, PETSC_INT)); time /= user->units->second; // Dimensionalize time back PetscCall(PetscViewerBinaryWrite(viewer, &time, 1, PETSC_REAL));