star-gf

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

commit edcb49d51b3fc7ec8d9f400e9b2c8994467c7014
parent 98d2cae91d6da5083aca2d6f82f363573fa620ab
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 22 Jul 2015 17:29:47 +0200

Minor update of the profile of the get_triangle function in the sgf_context

Minor changes on the README file and other comments. Break the
integration if too many radiative paths failed (avoid infinite loop).

Diffstat:
MREADME.md | 6+++---
Mcmake/CMakeLists.txt | 3---
Msrc/sgf.c | 23++++++++++++++++-------
Msrc/sgf.h | 2+-
Msrc/test_sgf.c | 6++++--
5 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/README.md b/README.md @@ -13,9 +13,9 @@ The *Star-GF* library relies on the [CMake](http://www.cmake.org) and the [Star-SP](https://gitlab.com/meso-star/star-sp/) libraries. First ensure that CMake is installed on your system. Then install the RCMake -package as well as all prerequisites. Then generate the project from the -`cmake/CMakeLists.txt` file by appending to the `CMAKE_PREFIX_PATH` variable the -install directories of the RCMake package and its dependencies. +package as well as all the *Star-GF* prerequisites. Then generate the project +from the `cmake/CMakeLists.txt` file by appending to the `CMAKE_PREFIX_PATH` +variable the install directories of its dependencies and the RCMake package. ## Licenses diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,8 +1,5 @@ # Copyright (C) |Meso|Star> 2015 (contact@meso-star.com) # -# This software is a computer program whose purpose is to generate files -# used to build the Star-MC library. -# # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/or redistribute the software under the terms of the CeCILL diff --git a/src/sgf.c b/src/sgf.c @@ -32,6 +32,9 @@ #include <star/s3d.h> #include <star/ssp.h> +/* Define how many failures are handled until an error occurs */ +#define MAX_FAILURES 10 + /******************************************************************************* * Helper function ******************************************************************************/ @@ -146,8 +149,6 @@ gebhart_radiative_path f3_normalize(dir, dir); } - /* Ensure that the radiative path vertex lies on or slightly above the - * triangle plane */ ctx->get_triangle(ctx->geometry, iprim, triangle); } #ifndef NDEBUG @@ -169,15 +170,23 @@ gebhart_factor_integrand void* context) { struct sgf_context* ctx = context; + size_t nfailures = 0; res_T res = RES_OK; do { accum_buffer_clear(result); res = gebhart_radiative_path(darray_gfacc_data_get(result), rng, ctx); - } while(res == RES_BAD_OP); - - if(res != RES_OK && ctx->verbose) { - logger_print(ctx->logger, LOG_ERROR, - "Critical error in the computation of the gebhart factor\n"); + } while(res == RES_BAD_OP && (++nfailures < MAX_FAILURES)); + + if(ctx->verbose) { + if(nfailures >= MAX_FAILURES) { + logger_print(ctx->logger, LOG_ERROR, +"Too many radiative path failures. The geometry might be wrongly setuped. The\n" +"geometry should be closed and 2D-manifold. In addition its normals must point\n" +"*into* the volume with respect to a Clock Wise vertex ordering\n"); + } else if(res != RES_OK) { + logger_print(ctx->logger, LOG_ERROR, + "Critical error in the computation of the gebhart factor\n"); + } } } diff --git a/src/sgf.h b/src/sgf.h @@ -55,7 +55,7 @@ struct sgf_context { /* Retrieve the triangle from the client side memory */ void (*get_triangle) (void* geometry, /* Client side geometry */ - size_t primitive_id, /* Triangle identifier */ + const size_t primitive_id, /* Triangle identifier */ float triangle[3/*#vertices*/][3/*#coords*/]); /* Output data */ void* geometry; /* Client side geometry */ diff --git a/src/test_sgf.c b/src/test_sgf.c @@ -35,7 +35,7 @@ #include <star/s3d.h> #include <star/smc.h> -#define NSTEPS 100000L +#define NSTEPS 10000L /* * Matrix of Gebhart factors @@ -96,6 +96,7 @@ static const double specularity[] = { 0.0, 0.0, /* Bottom */ }; +#if 0 static void dump_mesh(void) { @@ -109,6 +110,7 @@ dump_mesh(void) indices[i*3 + 2] + 1); } } +#endif static void get_ids(const unsigned itri, unsigned ids[3], void* data) @@ -189,7 +191,7 @@ main(int argc, char** argv) CHECK(s3d_shape_create_mesh(s3d, &shape), RES_OK); CHECK(s3d_scene_create(s3d, &scn), RES_OK); CHECK(s3d_scene_attach_shape(scn, shape), RES_OK); - CHECK(smc_device_create(NULL, NULL, 1, &smc), RES_OK); + CHECK(smc_device_create(NULL, NULL, SMC_NTHREADS_DEFAULT, &smc), RES_OK); attribs[0].type = S3D_FLOAT3; attribs[0].usage = S3D_POSITION;