tAdd compile-time flag to show parameter values, fig check of sim.dt - cngf-pf - continuum model for granular flows with pore-pressure dynamics (renamed from 1d_fd_simple_shear) (HTM) git clone git://src.adamsgaard.dk/cngf-pf (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit 0dbad4fab057eba02ad5b39be5dbe145983fee64 (DIR) parent 7ab8ed88e89f9bb5f2890264559147c10388a16f (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Mon, 8 Jul 2019 12:49:16 +0200 Add compile-time flag to show parameter values, fig check of sim.dt Diffstat: M simulation.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- (DIR) diff --git a/simulation.c b/simulation.c t@@ -4,6 +4,8 @@ #include "arrays.h" #include "simulation.h" +#define SHOW_PARAMETERS + void prepare_arrays(struct simulation* sim) { t@@ -56,12 +58,16 @@ warn_parameter_value(const char message[], static void check_float(const char name[], const double value, int* return_status) { - char message[100]; +#ifdef SHOW_PARAMETERS + printf("%30s: %.17g\n", name, value); +#endif if (isnan(value)) { + char message[100]; sprintf(message, "%s is NaN", name); warn_parameter_value(message, value, return_status); *return_status = 1; } else if (isinf(value)) { + char message[100]; sprintf(message, "%s is infinite", name); warn_parameter_value(message, value, return_status); *return_status = 1; t@@ -148,7 +154,7 @@ check_simulation_parameters(const struct simulation* sim) warn_parameter_value("sim.t_end is smaller than sim.t", sim->t, &return_status); - check_float("sim.dt", sim->t_end, &return_status); + check_float("sim.dt", sim->dt, &return_status); if (sim->dt <= 0.0) warn_parameter_value("sim.dt is not a positive number", sim->dt, &return_status); t@@ -173,7 +179,7 @@ check_simulation_parameters(const struct simulation* sim) if (sim->p_f_mod_ampl < 0.0) warn_parameter_value("sim.p_f_mod_ampl is not a zero or positive", sim->p_f_mod_ampl, &return_status); - + if (sim->P_wall - sim->p_f_mod_ampl < 0.0) warn_parameter_value("sim.P_wall - sim.p_f_mod_ampl is negative", sim->P_wall - sim->p_f_mod_ampl,