tCheck simulation size before initializing arrays - 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 a4b9b3cadad2a9cc40ea76c202bfebb91fecdeb5
(DIR) parent 3c032ad517b519a8b500dc877e3a6ce2067b770b
(HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Wed, 11 Dec 2019 13:09:50 +0100
Check simulation size before initializing arrays
Diffstat:
M max_depth_simple_shear.c | 1 +
M simulation.c | 5 +++++
2 files changed, 6 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/max_depth_simple_shear.c b/max_depth_simple_shear.c
t@@ -187,6 +187,7 @@ main(int argc, char* argv[])
return 1;
}*/
+ sim.nz = 1;
prepare_arrays(&sim);
if (!isnan(new_phi))
(DIR) diff --git a/simulation.c b/simulation.c
t@@ -9,6 +9,11 @@
void
prepare_arrays(struct simulation* sim)
{
+ if (sim->nz < 2) {
+ fprintf(stderr, "error: grid size (nz) must be at least 2 but is %d\n",
+ sim->nz);
+ exit(1);
+ }
sim->z = linspace(sim->origo_z, /* spatial coordinates */
sim->origo_z + sim->L_z,
sim->nz);