stardis-solver

Solve coupled heat transfers
git clone git://git.meso-star.fr/stardis-solver.git
Log | Files | Refs | README | LICENSE

commit 4b18ad5ad58f68ee58a58fc475971eea5e8464e2
parent cb7d1e3f924e821fdd0a88da97df2fdd1f96336a
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 22 Jun 2018 12:38:14 +0200

Add the "nfailures" attribute to the sdis_accum structure

Diffstat:
Msrc/sdis.h | 1+
Msrc/sdis_solve.c | 1+
Msrc/test_sdis_solve_camera.c | 20+++++++++++++++++---
3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/sdis.h b/src/sdis.h @@ -106,6 +106,7 @@ struct sdis_accum { double sum_weights; /* Sum of Monte-Carlo weights */ double sum_weights_sqr; /* Sum of Monte-Carlo square weights */ size_t nweights; /* #accumulated weights */ + size_t nfailures; /* #failures */ }; /* Monte-Carlo estimation */ diff --git a/src/sdis_solve.c b/src/sdis_solve.c @@ -98,6 +98,7 @@ solve_pixel accum->sum_weights = sum_weights; accum->sum_weights_sqr = sum_weights_sqr; accum->nweights = N; + accum->nfailures = nrealisations - N; exit: return res; diff --git a/src/test_sdis_solve_camera.c b/src/test_sdis_solve_camera.c @@ -30,7 +30,7 @@ #define UNKOWN_TEMPERATURE -1 #define IMG_WIDTH 640 #define IMG_HEIGHT 480 -#define SPP 4 /* #Samples per pixel, i.e. #realisations per pixel */ +#define SPP 4 /* #Samples per pixel, i.e. #realisations per pixel */ /* * The scene is composed of a solid cube whose temperature is unknown. The @@ -442,7 +442,7 @@ dump_image(const struct sdis_accum_buffer* buf) double Tmax = -DBL_MAX; double Tmin = DBL_MAX; double norm; - size_t ix, iy; + size_t i, ix, iy; CHK(buf != NULL); CHK(sdis_accum_buffer_get_layout(buf, &layout) == RES_OK); @@ -450,8 +450,17 @@ dump_image(const struct sdis_accum_buffer* buf) temps = mem_alloc(layout.width*layout.height*sizeof(double)); CHK(temps != NULL); - /* Compute the per pixel temperature */ CHK(sdis_accum_buffer_map(buf, &accums) == RES_OK); + + /* Check the results validity */ + FOR_EACH(i, 0, layout.height * layout.width) { + CHK(accums[i].nweights + accums[i].nfailures == SPP); + CHK(accums[i].nfailures <= SPP/100); + CHK(accums[i].sum_weights >= 0); + CHK(accums[i].sum_weights_sqr >= 0); + } + + /* Compute the per pixel temperature */ FOR_EACH(iy, 0, layout.height) { const struct sdis_accum* row_accums = accums + iy * layout.width; double* row = temps + iy * layout.width; @@ -596,6 +605,11 @@ main(int argc, char** argv) /* Create the accum buffer */ CHK(sdis_accum_buffer_create(dev, IMG_WIDTH, IMG_HEIGHT, &buf) == RES_OK); +#if 0 + dump_mesh(stdout, geom.positions, npos, geom.indices, ntris); + exit(0); +#endif + /* Launch the simulation */ CHK(sdis_solve_camera(scn, cam, INF, 1, 300, 300, IMG_WIDTH, IMG_HEIGHT, SPP, sdis_accum_buffer_write, buf) == RES_OK);