solstice

Compute collected power and efficiencies of a solar plant
git clone git://git.meso-star.com/solstice.git
Log | Files | Refs | README | LICENSE

commit bac0e2a65d1c3306463c1a2112607063e4aff1ab
parent 23a0f784333e50b0299ace85216a458a8c4e7fa8
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 22 Feb 2017 17:43:48 +0100

Plug the -O option to the dump_obj process

Diffstat:
Msrc/solstice.c | 41+++++++++++++++++++++++------------------
Msrc/solstice.h | 1+
Msrc/solstice_args.c | 9+++++----
3 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/src/solstice.c b/src/solstice.c @@ -520,6 +520,7 @@ solstice_init solstice->nrealisations = args->nrealisations; solstice->output_hits = args->output_hits; + solstice->dump_obj = args->dump_obj; exit: return res; @@ -567,22 +568,15 @@ solstice_run(struct solstice* solstice) ASSERT(nsun_dirs%3 == 0); nsun_dirs /= 3/*#dims*/; - if(!solstice->framebuffer) { /* Solstice integration */ - FOR_EACH(i, 0, nsun_dirs) { - const double* sun_dir = sun_dirs + i*3/*#dims*/; - res = ssol_sun_set_direction(solstice->sun, sun_dir); - if(res != RES_OK) { - fprintf(stderr, "Could not update the sun direction.\n"); - goto error; - } - res = solstice_update_entities(solstice, sun_dir); + if(!nsun_dirs) { + if(solstice->dump_obj) { + res = solstice_dump_obj(solstice); if(res != RES_OK) goto error; - res = solstice_solve(solstice); + } else { + ASSERT(solstice->framebuffer); + res = solstice_draw(solstice); if(res != RES_OK) goto error; } - } else if(!nsun_dirs) { - res = solstice_draw(solstice); - if(res != RES_OK) goto error; } else { FOR_EACH(i, 0, nsun_dirs) { const double* sun_dir = sun_dirs + i*3/*#dims*/; @@ -590,11 +584,22 @@ solstice_run(struct solstice* solstice) res = solstice_update_entities(solstice, sun_dir); if(res != RES_OK) goto error; - res = solstice_draw(solstice); - if(res != RES_OK) goto error; - - fprintf(solstice->output, - "# Sun direction: %g %g %g\n", SPLIT3(sun_dir)); + if(solstice->framebuffer) { + res = solstice_draw(solstice); + if(res != RES_OK) goto error; + } else if(solstice->dump_obj) { + res = solstice_dump_obj(solstice); + if(res != RES_OK) goto error; + } else { + res = ssol_sun_set_direction(solstice->sun, sun_dir); + if(res != RES_OK) { + fprintf(stderr, "Could not update the sun direction.\n"); + goto error; + } + res = solstice_solve(solstice); + if(res != RES_OK) goto error; + } + fprintf(solstice->output, "# Sun direction: %g %g %g\n", SPLIT3(sun_dir)); } } diff --git a/src/solstice.h b/src/solstice.h @@ -91,6 +91,7 @@ struct solstice { size_t nrealisations; /* # realisations */ FILE* output; /* Output stream */ + int dump_obj; /* Dump the geometry */ int output_hits; /* Output per receiver hits */ struct mem_allocator* allocator; diff --git a/src/solstice_args.c b/src/solstice_args.c @@ -54,6 +54,8 @@ print_help(const char* program) " -n REALISATIONS number of realisations. Default is %lu.\n", SOLSTICE_ARGS_DEFAULT.nrealisations); printf( +" -O switch in dump geometry mode.\n"); + printf( " -o OUTPUT write results to OUTPUT. If not defined, write results to\n" " standard output.\n"); printf( @@ -306,7 +308,7 @@ solstice_args_init(struct solstice_args* args, const int argc, char** argv) *args = SOLSTICE_ARGS_DEFAULT; optind = 0; - while((opt = getopt(argc, argv, "D:fHhn:O:o:qR:r:t:")) != -1) { + while((opt = getopt(argc, argv, "D:fHhn:Oo:qR:r:t:")) != -1) { switch(opt) { case 'D': res = parse_sun_dir_list(optarg, args); @@ -342,15 +344,14 @@ solstice_args_init(struct solstice_args* args, const int argc, char** argv) } } - if(!args->rendering && !args->nsun_dirs) { + if(!args->rendering && !args->dump_obj && !args->nsun_dirs) { fprintf(stderr, "Missing sun direction.\n"); res = RES_BAD_ARG; goto error; } if(args->dump_obj && args->rendering) { - fprintf(stderr, - "The '-O' and '-r' options cannot be defined simultaneously.\n"); + fprintf(stderr, "The '-O' and '-r' options are exclusive\n"); res = RES_BAD_ARG; goto error; }