tTake simulation name as command line argument - 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 ebe53df39f23493052516d89a237feb50c065f0b (DIR) parent 03ccad01366b146793639c634b0e109a70492598 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Mon, 15 Apr 2019 15:57:38 +0200 Take simulation name as command line argument Diffstat: M main.c | 18 +++++++++++++++++- M parameter_defaults.h | 3 +++ M simulation.c | 2 +- M simulation.h | 3 +++ 4 files changed, 24 insertions(+), 2 deletions(-) --- (DIR) diff --git a/main.c b/main.c t@@ -55,7 +55,7 @@ int main(int argc, char* argv[]) int normalize = 0; int opt; - const char* optstring = "hvNn:G:P:m:V:A:b:f:Fp:d:r:o:L:c:i:R:"; + const char* optstring = "hvNn:G:P:m:V:A:b:f:Fp:d:r:o:L:c:i:R:k:"; const struct option longopts[] = { {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, t@@ -76,10 +76,12 @@ int main(int argc, char* argv[]) {"fluid-compressiblity", required_argument, NULL, 'c'}, {"fluid-viscosity", required_argument, NULL, 'i'}, {"fluid-density", required_argument, NULL, 'R'}, + {"fluid-permeability", required_argument, NULL, 'R'}, {NULL, 0, NULL, 0} }; double new_phi = NAN; + double new_k = NAN; while ((opt = getopt_long(argc, argv, optstring, longopts, NULL)) != -1) { switch (opt) { case -1: /* no more arguments */ t@@ -146,6 +148,9 @@ int main(int argc, char* argv[]) case 'R': sim.rho_f = atof(optarg); break; + case 'k': + new_k = atof(optarg); + break; default: fprintf(stderr, "%s: invalid option -- %c\n", argv[0], opt); t@@ -154,12 +159,23 @@ int main(int argc, char* argv[]) return -2; } } + for (int i=optind; i<argc; ++i) { + if (i>optind) { + fprintf(stderr, "error: more than one simulation name specified\n"); + return 1; + } + sprintf(sim.name, "%s", argv[i]); + } + prepare_arrays(&sim); if (!isnan(new_phi)) for (int i=0; i<sim.nz; ++i) sim.phi[i] = new_phi; + if (!isnan(new_k)) + for (int i=0; i<sim.nz; ++i) + sim.k[i] = new_k; double filetimeclock = 0.0; while (sim.t <= sim.t_end) { (DIR) diff --git a/parameter_defaults.h b/parameter_defaults.h t@@ -14,6 +14,8 @@ struct simulation init_sim(void) { struct simulation sim; + sprintf(sim.name, "unnamed"); + sim.G = 9.81; sim.P_wall = 120e3; /* larger normal stress deepens the shear depth */ t@@ -58,6 +60,7 @@ struct simulation init_sim(void) sim.beta_f = 4.5e-10; /* Water, Goren et al 2011 */ sim.mu_f = 1e-3; /* Water, Goren et al 2011 */ sim.rho_f = 1e3; /* Water */ + sim.k = initval(1.9e-15, sim.nz); /* Damsgaard et al 2015 */ return sim; } (DIR) diff --git a/simulation.c b/simulation.c t@@ -380,7 +380,7 @@ void write_output_file(struct simulation* sim) char outfile[200]; FILE *fp; - sprintf(outfile, "%s.output%05d.txt", "testrun", sim->n_file++); + sprintf(outfile, "%s.output%05d.txt", sim->name, sim->n_file++); fp = fopen(outfile, "w"); fprint_three_arrays(fp, sim->z, sim->v_x, sim->sigma_n_eff, sim->nz); (DIR) diff --git a/simulation.h b/simulation.h t@@ -7,6 +7,9 @@ /* Simulation settings */ struct simulation { + /* simulation name to use for output files */ + char name[100]; + /* gravitational acceleration magnitude [m/s^2] */ double G;