Compiles and runs again.

Now to actual testing. Can we read and cotinue from and old file?
This commit is contained in:
Miikka Vaisala
2019-10-02 13:52:38 +08:00
parent 54d89f7a46
commit 1b0e9803b0
3 changed files with 13 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ uniform int AC_max_steps;
uniform int AC_save_steps;
uniform int AC_bin_steps;
uniform int AC_bc_type;
uniform int AC_start_step;
// Real params
uniform Scalar AC_dt;

View File

@@ -23,6 +23,10 @@ AC_save_steps = 10
AC_bin_steps = 1000
AC_bin_save_t = 1e666
// Set to 0 if you want to run the simulation from the beginning, or just a new
// simulation. If continuing from a saved step, specify the step number here.
AC_start_step = 0
// Hydro
AC_cdt = 0.4
AC_cdtv = 0.3

View File

@@ -96,6 +96,7 @@ write_mesh_info(const AcMeshInfo* config)
}
// This funtion writes a run state into a set of C binaries.
static inline void
save_mesh(const AcMesh& save_mesh, const int step, const AcReal t_step)
{
FILE* save_ptr;
@@ -133,10 +134,11 @@ save_mesh(const AcMesh& save_mesh, const int step, const AcReal t_step)
}
}
// This funtion reads a run state from a set of C binaries.
// This funtion reads a run state from a set of C binaries.
static inline void
read_mesh(AcMesh& read_mesh, const int step, AcReal* t_step)
{
FILE* save_ptr;
FILE* read_ptr;
for (int w = 0; w < NUM_VTXBUF_HANDLES; ++w) {
const size_t n = acVertexBufferSize(read_mesh.info);
@@ -159,12 +161,14 @@ read_mesh(AcMesh& read_mesh, const int step, AcReal* t_step)
read_ptr = fopen(bin_filename, "rb");
// Start file with time stamp
fread(t_step, sizeof(AcReal), 1, read_ptr);
size_t result;
result = fread(t_step, sizeof(AcReal), 1, read_ptr);
// Read grid data
AcReal read_buf;
for (size_t i = 0; i < n; ++i) {
fread(&read_buf, sizeof(AcReal), 1, read_ptr);
result = fread(&read_buf, sizeof(AcReal), 1, read_ptr);
read_mesh.vertex_buffer[VertexBufferHandle(w)][i] = read_buf;
if (result != sizeof(AcReal)) {fprintf(stderr, "Reading error in %s, element %i\n", vtxbuf_names[w], int(i));}
}
fclose(read_ptr);
}