solstice-solver

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

commit 4f90c2c5fb4a354b26e69a728fedc631dab99468
parent 15c7a495a60062811aafd7907b6efb0cacc99842
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 10 Oct 2016 09:59:12 +0200

Minor refactoring

Make consistent the coding style

Diffstat:
Msrc/ssol_ranst_sun_dir.c | 12++++++------
Msrc/ssol_ranst_sun_dir.h | 34+++++++++++++++++-----------------
Msrc/ssol_ranst_sun_wl.c | 43++++++++++++++++++++++---------------------
Msrc/ssol_ranst_sun_wl.h | 20++++++++++----------
4 files changed, 55 insertions(+), 54 deletions(-)

diff --git a/src/ssol_ranst_sun_dir.c b/src/ssol_ranst_sun_dir.c @@ -257,9 +257,9 @@ ran_pillbox_get ******************************************************************************/ static double* ran_dirac_get -(const struct ranst_sun_dir* ran, - struct ssp_rng* rng, - double dir[3]) + (const struct ranst_sun_dir* ran, + struct ssp_rng* rng, + double dir[3]) { (void) rng; ASSERT(d3_is_normalized(ran->state.dirac.dir)); @@ -356,9 +356,9 @@ ranst_sun_dir_dirac_setup const double dir[3]) { if (!ran || !dir) return RES_BAD_ARG; - if (0 == d3_normalize(ran->state.dirac.dir, dir)) - /* zero vector */ - return RES_BAD_ARG; + if (0 == d3_normalize(ran->state.dirac.dir, dir)) { + return RES_BAD_ARG; /* zero vector */ + } ran->get = ran_dirac_get; return RES_OK; } diff --git a/src/ssol_ranst_sun_dir.h b/src/ssol_ranst_sun_dir.h @@ -16,19 +16,33 @@ #ifndef SSOL_RANST_SUN_DIR_H #define SSOL_RANST_SUN_DIR_H -/* Random variate state of a sun direction */ -struct ranst_sun_dir; - /* External types */ struct ssp_rng; struct mem_allocator; +/* Random variate state of a sun direction */ +struct ranst_sun_dir; + extern LOCAL_SYM res_T ranst_sun_dir_create (struct mem_allocator* allocator, struct ranst_sun_dir** ran); extern LOCAL_SYM res_T +ranst_sun_dir_ref_get + (struct ranst_sun_dir* ran); + +extern LOCAL_SYM res_T +ranst_sun_dir_ref_put + (struct ranst_sun_dir* ran); + +extern LOCAL_SYM double* +ranst_sun_dir_get + (const struct ranst_sun_dir* ran, + struct ssp_rng* rng, + double dir[3]); + +extern LOCAL_SYM res_T ranst_sun_dir_buie_setup (struct ranst_sun_dir* ran, const double param, @@ -45,19 +59,5 @@ ranst_sun_dir_dirac_setup (struct ranst_sun_dir* ran, const double dir[3]); -extern LOCAL_SYM res_T -ranst_sun_dir_ref_get - (struct ranst_sun_dir* ran); - -extern LOCAL_SYM res_T -ranst_sun_dir_ref_put - (struct ranst_sun_dir* ran); - -extern LOCAL_SYM double* -ranst_sun_dir_get - (const struct ranst_sun_dir* ran, - struct ssp_rng* rng, - double dir[3]); - #endif /* SSOL_RANST_SUN_DIR_H */ diff --git a/src/ssol_ranst_sun_wl.c b/src/ssol_ranst_sun_wl.c @@ -24,7 +24,7 @@ #include <rsys/rsys.h> #include <rsys/ref_count.h> - /******************************************************************************* +/******************************************************************************* * Distributions types for wavelengths ******************************************************************************/ struct ran_piecewise_wl_state { @@ -42,7 +42,7 @@ enum wl_ran_type { }; /* One single type for all distributions. Only the state type depends on the -* distribution type */ + * distribution type */ struct ranst_sun_wl { double(*get) (const struct ranst_sun_wl* ran, struct ssp_rng* rng); @@ -66,13 +66,13 @@ distrib_sun_wl_release(ref_T* ref) ASSERT(ref); ran = CONTAINER_OF(ref, struct ranst_sun_wl, ref); switch (ran->type) { - case WL_DIRAC: - break; - case WL_PIECEWISE: - SSP(ranst_piecewise_linear_ref_put(ran->state.piecewise.spectrum)); - ran->state.piecewise.spectrum = NULL; - break; - default: FATAL("Unreachable code\n"); break; + case WL_DIRAC: + break; + case WL_PIECEWISE: + SSP(ranst_piecewise_linear_ref_put(ran->state.piecewise.spectrum)); + ran->state.piecewise.spectrum = NULL; + break; + default: FATAL("Unreachable code\n"); break; } MEM_RM(ran->allocator, ran); } @@ -85,7 +85,8 @@ ran_piecewise_get (const struct ranst_sun_wl* ran, struct ssp_rng* rng) { - ASSERT(ran && rng && ran->type == WL_PIECEWISE && ran->state.piecewise.spectrum); + ASSERT(ran && rng && ran->type == WL_PIECEWISE); + ASSERT(ran->state.piecewise.spectrum); return ssp_ranst_piecewise_linear_get(ran->state.piecewise.spectrum, rng); } @@ -94,8 +95,8 @@ ran_piecewise_get ******************************************************************************/ static double ran_dirac_get -(const struct ranst_sun_wl* ran, - struct ssp_rng* rng) + (const struct ranst_sun_wl* ran, + struct ssp_rng* rng) { (void) rng; ASSERT(ran && rng && ran->type == WL_DIRAC); @@ -164,24 +165,24 @@ ranst_sun_wl_setup if (sz > 1) { ran->type = WL_PIECEWISE; ran->get = &ran_piecewise_get; - res = ssp_ranst_piecewise_linear_create( - ran->allocator, &ran->state.piecewise.spectrum); + res = ssp_ranst_piecewise_linear_create + (ran->allocator, &ran->state.piecewise.spectrum); if (res != RES_OK) goto error; res = ssp_ranst_piecewise_linear_setup - (ran->state.piecewise.spectrum, wavelengths, intensities, sz); + (ran->state.piecewise.spectrum, wavelengths, intensities, sz); if (res != RES_OK) goto error; - } - else { + } else { ran->type = WL_DIRAC; ran->get = &ran_dirac_get; ran->state.dirac.wavelength = wavelengths[0]; } -end: +exit: return res; error: - if (ran->state.piecewise.spectrum) + if(ran->state.piecewise.spectrum) { SSP(ranst_piecewise_linear_ref_put(ran->state.piecewise.spectrum)); - ran->state.piecewise.spectrum = NULL; - goto end; + ran->state.piecewise.spectrum = NULL; + } + goto exit; } diff --git a/src/ssol_ranst_sun_wl.h b/src/ssol_ranst_sun_wl.h @@ -16,26 +16,19 @@ #ifndef SSOL_RANST_SUN_WL_H #define SSOL_RANST_SUN_WL_H -/* Random variate state of a sun direction */ -struct ranst_sun_wl; - /* External types */ struct ssp_rng; struct mem_allocator; +/* Random variate state of a sun direction */ +struct ranst_sun_wl; + extern LOCAL_SYM res_T ranst_sun_wl_create (struct mem_allocator* allocator, struct ranst_sun_wl** ran); extern LOCAL_SYM res_T -ranst_sun_wl_setup - (struct ranst_sun_wl* ran, - const double* wavelengths, - const double* intensities, - const size_t sz); - -extern LOCAL_SYM res_T ranst_sun_wl_ref_get (struct ranst_sun_wl* ran); @@ -48,5 +41,12 @@ ranst_sun_wl_get (const struct ranst_sun_wl* ran, struct ssp_rng* rng); +extern LOCAL_SYM res_T +ranst_sun_wl_setup + (struct ranst_sun_wl* ran, + const double* wavelengths, + const double* intensities, + const size_t sz); + #endif /* SSOL_RANST_SUN_WL_H */