Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jrwrigh committed Jun 19, 2023
1 parent 5023bc1 commit e47e721
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion examples/fluids/navierstokes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions examples/fluids/src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions examples/fluids/src/setupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit e47e721

Please sign in to comment.