Compiles and runs again.
Now to actual testing. Can we read and cotinue from and old file?
This commit is contained in:
@@ -14,6 +14,7 @@ uniform int AC_max_steps;
|
|||||||
uniform int AC_save_steps;
|
uniform int AC_save_steps;
|
||||||
uniform int AC_bin_steps;
|
uniform int AC_bin_steps;
|
||||||
uniform int AC_bc_type;
|
uniform int AC_bc_type;
|
||||||
|
uniform int AC_start_step;
|
||||||
|
|
||||||
// Real params
|
// Real params
|
||||||
uniform Scalar AC_dt;
|
uniform Scalar AC_dt;
|
||||||
|
@@ -23,6 +23,10 @@ AC_save_steps = 10
|
|||||||
AC_bin_steps = 1000
|
AC_bin_steps = 1000
|
||||||
AC_bin_save_t = 1e666
|
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
|
// Hydro
|
||||||
AC_cdt = 0.4
|
AC_cdt = 0.4
|
||||||
AC_cdtv = 0.3
|
AC_cdtv = 0.3
|
||||||
|
@@ -96,6 +96,7 @@ write_mesh_info(const AcMeshInfo* config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This funtion writes a run state into a set of C binaries.
|
// 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)
|
save_mesh(const AcMesh& save_mesh, const int step, const AcReal t_step)
|
||||||
{
|
{
|
||||||
FILE* save_ptr;
|
FILE* save_ptr;
|
||||||
@@ -134,9 +135,10 @@ 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)
|
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) {
|
for (int w = 0; w < NUM_VTXBUF_HANDLES; ++w) {
|
||||||
const size_t n = acVertexBufferSize(read_mesh.info);
|
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");
|
read_ptr = fopen(bin_filename, "rb");
|
||||||
|
|
||||||
// Start file with time stamp
|
// 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
|
// Read grid data
|
||||||
AcReal read_buf;
|
AcReal read_buf;
|
||||||
for (size_t i = 0; i < n; ++i) {
|
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;
|
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);
|
fclose(read_ptr);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user