star-gf

Compute Gebhart factors
git clone git://git.meso-star.fr/star-gf.git
Log | Files | Refs | README | LICENSE

commit e06d3e5e9c3ed748172bbd14eb5f2e7101ac5b01
parent 34fa20a0f072059f098580c4a8c0a38d6847fe1c
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Sat, 12 Sep 2015 16:03:02 +0200

Update the Gebhart Factor integrand

The SMC library does not accumulate the realisations anymore. It is now
performed into the Gebhart Factor integrand.

Diffstat:
Msrc/sgf.c | 23+++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/sgf.c b/src/sgf.c @@ -66,6 +66,9 @@ gebhart_radiative_path double emissivity; double reflectivity; double specularity; +#ifndef NDEBUG + double sum_radiative_flux = 0.f; +#endif const double trans_min = 1.e-8; size_t nprims; float vec0[3]; @@ -135,6 +138,9 @@ gebhart_radiative_path gebfac = result + prim.prim_id * ctx->spectral_bands_count; if(transmissivity > trans_min) { const double weight = transmissivity * emissivity; +#ifndef NDEBUG + sum_radiative_flux += weight; +#endif gebfac[ispectral_band].radiative_flux += weight; gebfac[ispectral_band].sqr_radiative_flux += weight * weight; transmissivity = transmissivity * (1.0 - emissivity); @@ -144,6 +150,9 @@ gebhart_radiative_path const double weight = transmissivity; gebfac[ispectral_band].radiative_flux += weight; gebfac[ispectral_band].sqr_radiative_flux += weight * weight; +#ifndef NDEBUG + sum_radiative_flux += weight; +#endif break; } } @@ -165,17 +174,8 @@ gebhart_radiative_path } } #if !defined(NDEBUG) - { /* Ensure the energy conservation property */ - double sum_radiative_flux = 0.0; - size_t iprim; - gebfac = result; - FOR_EACH(iprim, 0, nprims) { - sum_radiative_flux += gebfac[ispectral_band].radiative_flux; - gebfac += ctx->spectral_bands_count; - } - sum_radiative_flux += sky_gebhart; - ASSERT(eq_eps(sum_radiative_flux, 1.0, 1.e-6)); - } + /* Check the energy conservation property */ + ASSERT(eq_eps(sum_radiative_flux + sky_gebhart, 1.0, 1.e6)); #endif return RES_OK; } @@ -194,7 +194,6 @@ gebhart_factor_integrand buf = darray_gfacc_data_get(result); FOR_EACH(iband, 0, ctx->spectral_bands_count) { - accum_buffer_clear(result); res = gebhart_radiative_path(buf, rng, ctx, iband); ASSERT(res == RES_OK); }