tOnly write intermediate output files to disk if a simulation name is specified… | |
git clone git://src.adamsgaard.dk/cngf-pf | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 4d51b11991631dd7cb45ee6395c5288268bab329 | |
parent e700e8e26323a391f374c70d5c659dd8f2420a1c | |
Author: Anders Damsgaard <[email protected]> | |
Date: Sat, 6 Jul 2019 11:09:08 +0200 | |
Only write intermediate output files to disk if a simulation name is specified | |
Diffstat: | |
M main.c | 7 ++++--- | |
M parameter_defaults.h | 4 +++- | |
2 files changed, 7 insertions(+), 4 deletions(-) | |
--- | |
diff --git a/main.c b/main.c | |
t@@ -2,6 +2,7 @@ | |
#include <stdlib.h> | |
#include <math.h> | |
#include <getopt.h> | |
+#include <string.h> | |
#include "simulation.h" | |
#include "fluid.h" | |
t@@ -17,7 +18,7 @@ usage(void) | |
struct simulation sim = init_sim(); | |
printf("%s: %s [OPTIONS] [NAME]\n" | |
"runs a simulation and outputs state in files prefixed with NA… | |
- "If NAME is not specified, the default value '%s' is used.\n" | |
+ "If NAME is not specified, intermediate output are not written… | |
"\nOptional arguments:\n" | |
" -v, --version show version information\n" | |
" -h, --help show this message\n" | |
t@@ -49,7 +50,6 @@ usage(void) | |
" -T, --time-end VAL simulation end time [s] (def… | |
" -I, --file-interval VAL interval between output file… | |
__func__, PROGNAME, | |
- sim.name, | |
sim.G, | |
sim.P_wall, | |
sim.mu_wall, | |
t@@ -288,7 +288,8 @@ main(int argc, char* argv[]) | |
filetimeclock += sim.dt; | |
iter++; | |
- if (filetimeclock >= sim.file_dt || iter == 0) { | |
+ if ((filetimeclock >= sim.file_dt || iter == 0) && | |
+ strcmp(sim.name, DEFAULT_SIMULATION_NAME) != 0) { | |
write_output_file(&sim, norm); | |
filetimeclock = 0.0; | |
} | |
diff --git a/parameter_defaults.h b/parameter_defaults.h | |
t@@ -6,12 +6,14 @@ | |
#include "arrays.h" | |
#include "simulation.h" | |
+#define DEFAULT_SIMULATION_NAME "unnamed_simulation" | |
+ | |
/* Simulation settings */ | |
struct simulation init_sim(void) | |
{ | |
struct simulation sim; | |
- sprintf(sim.name, "unnamed"); | |
+ sprintf(sim.name, DEFAULT_SIMULATION_NAME); | |
sim.G = 9.81; | |