solstice-solver

Solver library of the solstice app
git clone git://git.meso-star.com/solstice-solver.git
Log | Files | Refs | README | LICENSE

commit c85dbd31863334f945faeeeb536fe5f0fbb62ced
parent fcee059601c6901d5f4592ae3da3e20b9c18df79
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 14 Feb 2017 09:41:56 +0100

Refactor the ssol_estimator_get_receiver_status function

Diffstat:
Msrc/ssol_estimator.c | 40+++++++++++-----------------------------
Msrc/ssol_solver.c | 7++++---
2 files changed, 15 insertions(+), 32 deletions(-)

diff --git a/src/ssol_estimator.c b/src/ssol_estimator.c @@ -148,34 +148,17 @@ ssol_estimator_get_receiver_status status->N = estimator->realisation_count; status->Nf = estimator->failed_count; - status->irradiance.E = data->irradiance.weight / (double)status->N; - status->irradiance.V - = data->irradiance.sqr_weight / (double)status->N - - status->irradiance.E * status->irradiance.E; - status->irradiance.SE - = (status->irradiance.V > 0) ? - sqrt(status->irradiance.V / (double)status->N) : 0; - status->absorptivity_loss.E = data->absorptivity_loss.weight / (double) status->N; - status->absorptivity_loss.V - = data->absorptivity_loss.sqr_weight / (double) status->N - - status->absorptivity_loss.E * status->absorptivity_loss.E; - status->absorptivity_loss.SE - = (status->absorptivity_loss.V > 0) ? - sqrt(status->absorptivity_loss.V / (double) status->N) : 0; - status->reflectivity_loss.E = data->reflectivity_loss.weight / (double) status->N; - status->reflectivity_loss.V - = data->reflectivity_loss.sqr_weight / (double) status->N - - status->reflectivity_loss.E * status->reflectivity_loss.E; - status->reflectivity_loss.SE - = (status->reflectivity_loss.V > 0) ? - sqrt(status->reflectivity_loss.V / (double) status->N) : 0; - status->cos_loss.E = data->cos_loss.weight / (double) status->N; - status->cos_loss.V - = data->cos_loss.sqr_weight / (double) status->N - - status->cos_loss.E * status->cos_loss.E; - status->cos_loss.SE - = (status->cos_loss.V > 0) ? - sqrt(status->cos_loss.V / (double) status->N) : 0; + #define SETUP_MC_STATUS(Name) { \ + const double N = (double)estimator->realisation_count; \ + status->Name.E = data->Name.weight / N; \ + status->Name.V = data->Name.sqr_weight/N - status->Name.E*status->Name.E; \ + status->Name.SE = status->Name.V > 0 ? sqrt(status->Name.V / N) : 0; \ + } (void)0 + SETUP_MC_STATUS(irradiance); + SETUP_MC_STATUS(absorptivity_loss); + SETUP_MC_STATUS(reflectivity_loss); + SETUP_MC_STATUS(cos_loss); + #undef SETUP_MC_STATUS return RES_OK; } @@ -260,4 +243,3 @@ error: goto exit; } - diff --git a/src/ssol_solver.c b/src/ssol_solver.c @@ -69,7 +69,7 @@ struct point { {0, 0, 0}, /* Direction */ \ {0, 0}, /* UV */ \ 0, /* Wavelength */ \ - 0, 0, 0, /* MC weights */ \ + 0, 0, 0, 0, /* MC weights */ \ SSOL_FRONT /* Side */ \ } static const struct point POINT_NULL = POINT_NULL__; @@ -233,7 +233,7 @@ point_shade * the same. Indeed it may be inconsistent only if the two kind of primitives * does not have the same set of parameters. For triangulated meshes, the RT * and sampled shape are the same and thus shared the same attribs. For - * punched surfaces, no attribs are defined on both representation. + * punched surfaces, no attrib is defined on both representation. * Consequently, it seems that there is no specific work to do to ensure the * `surface_fragment_setup' consistency. */ surface_fragment_setup(&frag, pt->pos, pt->dir, pt->N, &pt->prim, pt->uv); @@ -424,7 +424,8 @@ ssol_solve htable_receiver_begin(mc_rcvs + i, &it); htable_receiver_end(mc_rcvs + i, &end); while (!htable_receiver_iterator_eq(&it, &end)) { - struct mc_per_receiver_data* estimator_data = htable_receiver_iterator_data_get(&it); + struct mc_per_receiver_data* estimator_data = + htable_receiver_iterator_data_get(&it); *estimator_data = MC_RECV_DATA_NULL; htable_receiver_iterator_next(&it); }