stardis-solver

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

commit 12dc9a305bbc417e37988d3b0e69690b3491f816
parent 1dfc9e764907a00b25cfc4eabf909948d8161eed
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 13 Feb 2024 15:12:08 +0100

Add an optional function to search for the nearest point

The user can set their own filter function to manage the candidate
points to be closest. This gives the caller a fine control during the
inquiry to access the geometry and traversal of the accelerating
structure.

Note that this commit breaks the sdis_scene_find_closest_point API. Its
input arguments are now grouped into a structure to simplify the
addition or deletion of input parameters and the definition of a default
value using a constant defined in the header file.

Finally, we rework the generic implementation of a scene. We no longer
use the SDIS_SCENE_DIMENSION macro. We now use the same generation
mechanics to the dimension used throughout the library. The previous
implementation was only an historical artifact.

Diffstat:
Msdis.pc.in | 6++++--
Msrc/sdis.h | 18++++++++++++++++--
Msrc/sdis_Xd_begin.h | 11+++++++++++
Msrc/sdis_Xd_end.h | 6++++++
Msrc/sdis_heat_path_boundary_Xd_solid_fluid_picard1.h | 13++-----------
Msrc/sdis_scene.c | 21+++++++++------------
Msrc/sdis_scene_Xd.h | 127+++++++++++++++++++++++++++++++++++--------------------------------------------
Msrc/sdis_scene_c.h | 9++++++++-
Msrc/test_sdis_scene.c | 67+++++++++++++++++++++++++++++++++++++++++++++++++------------------
Msrc/test_sdis_solve_probe_boundary_list.c | 11++++++++---
10 files changed, 169 insertions(+), 120 deletions(-)

diff --git a/sdis.pc.in b/sdis.pc.in @@ -2,10 +2,12 @@ prefix=@PREFIX@ includedir=${prefix}/include libdir=${prefix}/lib -Requires: rsys >= @RSYS_VERSION@, star-sp >= @SSP_VERSION@ -Requires.private:\ +Requires: \ + rsys >= @RSYS_VERSION@,\ s2d >= @S2D_VERSION@,\ s3d >= @S3D_VERSION@,\ + star-sp >= @SSP_VERSION@ +Requires.private:\ senc2d >= @SENC3D_VERSION@,\ senc3d >= @SENC3D_VERSION@ @MPI@ Name: sdis diff --git a/src/sdis.h b/src/sdis.h @@ -16,6 +16,8 @@ #ifndef SDIS_H #define SDIS_H +#include <star/s2d.h> +#include <star/s3d.h> #include <star/ssp.h> #include <rsys/hash.h> @@ -165,6 +167,19 @@ static const struct sdis_spherical_source_create_args SDIS_SPHERICAL_SOURCE_CREATE_ARGS_NULL = SDIS_SPHERICAL_SOURCE_CREATE_ARGS_NULL__; +struct sdis_scene_find_closest_point_args { + double position[3]; /* Query position */ + double radius; /* Maxium search distance around pos */ + + /* User defined filter function */ + s2d_hit_filter_function_T filter_2d; + s3d_hit_filter_function_T filter_3d; + void* filter_data; /* Filter function data */ +}; +#define SDIS_SCENE_FIND_CLOSEST_POINT_ARGS_NULL__ {{0,0,0}, 0, NULL, NULL, NULL} +static const struct sdis_scene_find_closest_point_args +SDIS_SCENE_FIND_CLOSEST_POINT_ARGS_NULL = SDIS_SCENE_FIND_CLOSEST_POINT_ARGS_NULL__; + /******************************************************************************* * Estimation data types ******************************************************************************/ @@ -1118,8 +1133,7 @@ sdis_scene_set_temperature_range SDIS_API res_T sdis_scene_find_closest_point (const struct sdis_scene* scn, - const double pos[], /* Query position */ - const double radius, /* Maximum search distance around pos */ + const struct sdis_scene_find_closest_point_args* args, size_t* iprim, /* Primitive index onto which the closest point lies */ double uv[]); /* Parametric cordinate onto the primitive */ diff --git a/src/sdis_Xd_begin.h b/src/sdis_Xd_begin.h @@ -85,10 +85,18 @@ get_picard_order(const struct rwalk_context* ctx) #include <rsys/double2.h> #include <rsys/float2.h> #include <star/s2d.h> + + #define FORMAT_VECX "%g, %g" + #define SPLITX(V) SPLIT2(V) + #elif SDIS_XD_DIMENSION == 3 #include <rsys/double3.h> #include <rsys/float3.h> #include <star/s3d.h> + + #define FORMAT_VECX "%g, %g, %g" + #define SPLITX(V) SPLIT3(V) + #else #error "Invalid dimension." #endif @@ -108,13 +116,16 @@ get_picard_order(const struct rwalk_context* ctx) #define SXD_FLOAT2 CONCAT(CONCAT(S, DIM), D_FLOAT2) #define SXD_FLOAT3 CONCAT(CONCAT(S, DIM), D_FLOAT3) #define SXD_FLOATX CONCAT(CONCAT(CONCAT(S,DIM), D_FLOAT), DIM) +#define SXD_GET_PRIMITIVE CONCAT(CONCAT(S, DIM), D_GET_PRIMITIVE) #define SXD_SAMPLE CONCAT(CONCAT(S, DIM), D_SAMPLE) +#define SXD_TRACE CONCAT(CONCAT(S, DIM), D_TRACE) #define SXD_PRIMITIVE_EQ CONCAT(CONCAT(S, DIM), D_PRIMITIVE_EQ) /* Vector macros generic to SDIS_XD_DIMENSION */ #define dX(Func) CONCAT(CONCAT(CONCAT(d, DIM), _), Func) #define fX(Func) CONCAT(CONCAT(CONCAT(f, DIM), _), Func) #define fX_set_dX CONCAT(CONCAT(CONCAT(f, DIM), _set_d), DIM) +#define fXX_mulfX CONCAT(CONCAT(CONCAT(CONCAT(f, DIM), DIM), _mulf), DIM) #define dX_set_fX CONCAT(CONCAT(CONCAT(d, DIM), _set_f), DIM) /* Macro making generic its submitted name to SDIS_XD_DIMENSION */ diff --git a/src/sdis_Xd_end.h b/src/sdis_Xd_end.h @@ -31,11 +31,17 @@ #undef SXD_FLOAT2 #undef SXD_FLOAT3 #undef SXD_FLOATX +#undef SXD_GET_PRIMITIVE #undef SXD_SAMPLE +#undef SXD_TRACE #undef dX #undef fX #undef fX_set_dX +#undef fXX_mulfX #undef dX_set_fX +#undef FORMAT_VECX +#undef SPLITX + #undef SDIS_XD_BEGIN_H__ diff --git a/src/sdis_heat_path_boundary_Xd_solid_fluid_picard1.h b/src/sdis_heat_path_boundary_Xd_solid_fluid_picard1.h @@ -36,28 +36,19 @@ XD(check_Tref) { ASSERT(scn && pos && func_name); -#if DIM == 2 - #define STR_VECX "%g %g" - #define SPLITX SPLIT2 -#else - #define STR_VECX "%g %g %g" - #define SPLITX SPLIT3 -#endif if(Tref < 0) { log_err(scn->dev, - "%s: invalid reference temperature `%gK' at the position `"STR_VECX"'.\n", + "%s: invalid reference temperature `%gK' at the position `"FORMAT_VECX"'.\n", func_name, Tref, SPLITX(pos)); return RES_BAD_OP_IRRECOVERABLE; } if(Tref > scn->tmax) { log_err(scn->dev, "%s: invalid maximum temperature `%gK'. The reference temperature `%gK' " - "at the position `"STR_VECX"' is greater than this temperature.\n", + "at the position `"FORMAT_VECX"' is greater than this temperature.\n", func_name, scn->tmax, Tref, SPLITX(pos)); return RES_BAD_OP_IRRECOVERABLE; } -#undef STR_VECX -#undef SPLITX return RES_OK; } diff --git a/src/sdis_scene.c b/src/sdis_scene.c @@ -13,14 +13,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "sdis_scene_Xd.h" - -/* Generate the Generic functions of the scene */ -#define SDIS_SCENE_DIMENSION 2 -#include "sdis_scene_Xd.h" -#define SDIS_SCENE_DIMENSION 3 -#include "sdis_scene_Xd.h" - #include "sdis.h" #include "sdis_interface_c.h" #include "sdis_scene_c.h" @@ -29,6 +21,12 @@ #include <float.h> #include <limits.h> +/* Generate the Generic functions of the scene */ +#define SDIS_XD_DIMENSION 2 +#include "sdis_scene_Xd.h" +#define SDIS_XD_DIMENSION 3 +#include "sdis_scene_Xd.h" + /******************************************************************************* * Helper function ******************************************************************************/ @@ -240,16 +238,15 @@ sdis_scene_set_temperature_range res_T sdis_scene_find_closest_point (const struct sdis_scene* scn, - const double pos[], - const double radius, + const struct sdis_scene_find_closest_point_args* args, size_t* iprim, double uv[]) { if(!scn) return RES_BAD_ARG; if(scene_is_2d(scn)) { - return scene_find_closest_point_2d(scn, pos, radius, iprim, uv); + return scene_find_closest_point_2d(scn, args, iprim, uv); } else { - return scene_find_closest_point_3d(scn, pos, radius, iprim, uv); + return scene_find_closest_point_3d(scn, args, iprim, uv); } } diff --git a/src/sdis_scene_Xd.h b/src/sdis_scene_Xd.h @@ -13,8 +13,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef SDIS_SCENE_DIMENSION - #ifndef SDIS_SCENE_XD_H #define SDIS_SCENE_XD_H @@ -123,8 +121,20 @@ check_sdis_scene_create_args(const struct sdis_scene_create_args* args) && args->fp_to_meter > 0; } +static INLINE res_T +check_sdis_scene_find_closest_point_args + (const struct sdis_scene_find_closest_point_args* args) +{ + /* Undefined input arguments */ + if(!args) return RES_BAD_ARG; + + /* Invalid radius */ + if(args->radius <= 0) return RES_BAD_ARG; + + return RES_OK; +} + #endif /* SDIS_SCENE_XD_H */ -#else /* !SDIS_SCENE_DIMENSION */ #include "sdis_device_c.h" @@ -137,39 +147,18 @@ check_sdis_scene_create_args(const struct sdis_scene_create_args* args) #include <limits.h> /* Check the submitted dimension and include its specific headers */ -#define SENCXD_DIM SDIS_SCENE_DIMENSION -#if (SDIS_SCENE_DIMENSION == 2) +#define SENCXD_DIM SDIS_XD_DIMENSION +#if (SDIS_XD_DIMENSION == 2) #include <star/sencX2d.h> #include <star/s2d.h> -#elif (SDIS_SCENE_DIMENSION == 3) +#elif (SDIS_XD_DIMENSION == 3) #include <star/sencX3d.h> #include <star/s3d.h> #else - #error "Invalid SDIS_SCENE_DIMENSION value." + #error "Invalid SDIS_XD_DIMENSION value." #endif -/* Syntactic sugar */ -#define DIM SDIS_SCENE_DIMENSION - -/* Star-XD macros generic to SDIS_SCENE_DIMENSION */ -#define sXd(Name) CONCAT(CONCAT(CONCAT(s, DIM), d_), Name) -#define SXD CONCAT(CONCAT(S, DIM), D) -#define SXD_VERTEX_DATA_NULL CONCAT(CONCAT(S,DIM),D_VERTEX_DATA_NULL) -#define SXD_POSITION CONCAT(CONCAT(S, DIM), D_POSITION) -#define SXD_TRACE CONCAT(CONCAT(S,DIM), D_TRACE) -#define SXD_SAMPLE CONCAT(CONCAT(S,DIM), D_SAMPLE) -#define SXD_GET_PRIMITIVE CONCAT(CONCAT(S,DIM), D_GET_PRIMITIVE) -#define SXD_HIT_NONE CONCAT(CONCAT(S,DIM), D_HIT_NONE) -#define SXD_PRIMITIVE_EQ CONCAT(CONCAT(S,DIM), D_PRIMITIVE_EQ) -#define SXD_FLOATX CONCAT(CONCAT(CONCAT(S,DIM), D_FLOAT), DIM) - -/* Vector macros generic to SDIS_SCENE_DIMENSION */ -#define fX(Func) CONCAT(CONCAT(CONCAT(f, DIM), _), Func) -#define fX_set_dX CONCAT(CONCAT(CONCAT(f, DIM), _set_d), DIM) -#define fXX_mulfX CONCAT(CONCAT(CONCAT(CONCAT(f, DIM), DIM), _mulf), DIM) - -/* Macro making generic its subimitted name to SDIS_SCENE_DIMENSION */ -#define XD(Name) CONCAT(CONCAT(CONCAT(Name, _), DIM), d) +#include "sdis_Xd_begin.h" #if DIM == 2 #define HIT_ON_BOUNDARY hit_on_vertex @@ -454,15 +443,22 @@ XD(hit_filter_function) const float org[DIM], const float dir[DIM], const float range[2], - void* ray_data, + void* query_data, void* global_data) { - const struct hit_filter_data* filter_data = ray_data; + const struct hit_filter_data* filter_data = query_data; const struct sXd(hit)* hit_from = &filter_data->XD(hit); (void)org, (void)dir, (void)global_data, (void)range; /* No user defined data. Do not filter */ - if(!ray_data || SXD_HIT_NONE(hit_from)) return 0; + if(!filter_data || SXD_HIT_NONE(hit_from)) return 0; + + /* Call the custom filter function if it exists + * or perform regular filtering otherwise */ + if(filter_data->XD(custom_filter)) { + return filter_data->XD(custom_filter) + (hit, org, dir, range, filter_data->custom_filter_data, global_data); + } if(SXD_PRIMITIVE_EQ(&hit_from->prim, &hit->prim)) return 1; @@ -988,8 +984,7 @@ error: static res_T XD(scene_find_closest_point) (const struct sdis_scene* scn, - const double pos[3], - const double radius, + const struct sdis_scene_find_closest_point_args* args, size_t* iprim, double uv[2]) { @@ -998,30 +993,37 @@ XD(scene_find_closest_point) float query_radius; res_T res = RES_OK; - if(!scn || !pos || radius <= 0 || !iprim || !uv - || scene_is_2d(scn) != (DIM == 2)) { + if(!scn || !iprim || !uv || scene_is_2d(scn) != (DIM == 2)) { res = RES_BAD_ARG; goto error; } + res = check_sdis_scene_find_closest_point_args(args); + if(res != RES_OK) goto error; /* Avoid a null query radius due to casting in single-precision */ - query_radius = MMAX((float)radius, FLT_MIN); + query_radius = MMAX((float)args->radius, FLT_MIN); + + fX_set_dX(query_pos, args->position); + + /* Do not filter anything */ + if(!args->XD(filter)) { + res = sXd(scene_view_closest_point) + (scn->sXd(view), query_pos, query_radius, NULL, &hit); + + /* Filter points according to user-defined filter function */ + } else { + struct hit_filter_data filter_data = HIT_FILTER_DATA_NULL; + filter_data.XD(custom_filter) = args->XD(filter); + filter_data.custom_filter_data = args->filter_data; + res = sXd(scene_view_closest_point) + (scn->sXd(view), query_pos, query_radius, &filter_data, &hit); + } - fX_set_dX(query_pos, pos); - res = sXd(scene_view_closest_point) - (scn->sXd(view), query_pos, query_radius, NULL, &hit); if(res != RES_OK) { -#if DIM == 2 log_err(scn->dev, - "%s: error querying the closest position at {%g, %g} " + "%s: error querying the closest position at `"FORMAT_VECX"' " "for a radius of %g -- %s.\n", - FUNC_NAME, SPLIT2(query_pos), query_radius, res_to_cstr(res)); -#else - log_err(scn->dev, - "%s: error querying the closest position at {%g, %g, %g} " - "for a radius of %g -- %s.\n", - FUNC_NAME, SPLIT3(query_pos), query_radius, res_to_cstr(res)); -#endif + FUNC_NAME, SPLITX(query_pos), query_radius, res_to_cstr(res)); goto error; } @@ -1250,29 +1252,12 @@ error: goto exit; } -#if (SDIS_SCENE_DIMENSION == 2) -#include <star/sencX2d_undefs.h> -#else /* SDIS_SCENE_DIMENSION == 3 */ -#include <star/sencX3d_undefs.h> +#if (SDIS_XD_DIMENSION == 2) + #include <star/sencX2d_undefs.h> +#else /* SDIS_XD_DIMENSION == 3 */ + #include <star/sencX3d_undefs.h> #endif -#undef SDIS_SCENE_DIMENSION -#undef DIM -#undef sXd -#undef SXD -#undef SXD_VERTEX_DATA_NULL -#undef SXD_POSITION -#undef SXD_FLOAT3 -#undef SXD_TRACE -#undef SXD_TRACE -#undef SXD_GET_PRIMITIVE -#undef SXD_HIT_NONE -#undef SXD_PRIMITIVE_EQ -#undef SXD_FLOATX -#undef fX -#undef fX_set_dX -#undef fXX_mulfX -#undef XD #undef HIT_ON_BOUNDARY -#endif /* !SDIS_SCENE_DIMENSION */ +#include "sdis_Xd_end.h" diff --git a/src/sdis_scene_c.h b/src/sdis_scene_c.h @@ -36,8 +36,15 @@ struct hit_filter_data { struct s2d_hit hit_2d; struct s3d_hit hit_3d; double epsilon; /* Threshold defining roughly equal intersections */ + + /* Bypass the regular filter function */ + s2d_hit_filter_function_T custom_filter_2d; + s3d_hit_filter_function_T custom_filter_3d; + + /* Custom filter query data. It is ignored if custom_filter is NULL */ + void* custom_filter_data; }; -#define HIT_FILTER_DATA_NULL__ {S2D_HIT_NULL__, S3D_HIT_NULL__, 0} +#define HIT_FILTER_DATA_NULL__ {S2D_HIT_NULL__,S3D_HIT_NULL__,0,NULL,NULL,NULL} static const struct hit_filter_data HIT_FILTER_DATA_NULL = HIT_FILTER_DATA_NULL__; diff --git a/src/test_sdis_scene.c b/src/test_sdis_scene.c @@ -98,6 +98,8 @@ test_scene_3d(struct sdis_device* dev, struct sdis_interface* interf) struct senc2d_scene* scn2d; struct senc3d_scene* scn3d; struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT; + struct sdis_scene_find_closest_point_args closest_pt_args = + SDIS_SCENE_FIND_CLOSEST_POINT_ARGS_NULL; struct sdis_scene* scn = NULL; struct sdis_device* dev2 = NULL; size_t ntris, npos; @@ -195,12 +197,15 @@ test_scene_3d(struct sdis_device* dev, struct sdis_interface* interf) BA(sdis_scene_boundary_project_position(scn, 6, pos, NULL)); OK(sdis_scene_boundary_project_position(scn, 6, pos, uv1)); - BA(sdis_scene_find_closest_point(NULL, pos, INF, &iprim, uv2)); - BA(sdis_scene_find_closest_point(scn, NULL, INF, &iprim, uv2)); - BA(sdis_scene_find_closest_point(scn, pos, 0, &iprim, uv2)); - BA(sdis_scene_find_closest_point(scn, pos, INF, NULL, uv2)); - BA(sdis_scene_find_closest_point(scn, pos, INF, &iprim, NULL)); - OK(sdis_scene_find_closest_point(scn, pos, INF, &iprim, uv2)); + closest_pt_args.position[0] = pos[0]; + closest_pt_args.position[1] = pos[1]; + closest_pt_args.position[2] = pos[2]; + closest_pt_args.radius = INF; + BA(sdis_scene_find_closest_point(NULL, &closest_pt_args, &iprim, uv2)); + BA(sdis_scene_find_closest_point(scn, NULL, &iprim, uv2)); + BA(sdis_scene_find_closest_point(scn, &closest_pt_args, NULL, uv2)); + BA(sdis_scene_find_closest_point(scn, &closest_pt_args, &iprim, NULL)); + OK(sdis_scene_find_closest_point(scn, &closest_pt_args, &iprim, uv2)); CHK(iprim == 6); CHK(d2_eq_eps(uv0, uv1, 1.e-6)); @@ -209,7 +214,10 @@ test_scene_3d(struct sdis_device* dev, struct sdis_interface* interf) pos[0] = 0.5; pos[1] = 0.1; pos[2] = 0.25; - OK(sdis_scene_find_closest_point(scn, pos, INF, &iprim, uv2)); + closest_pt_args.position[0] = pos[0]; + closest_pt_args.position[1] = pos[1]; + closest_pt_args.position[2] = pos[2]; + OK(sdis_scene_find_closest_point(scn, &closest_pt_args, &iprim, uv2)); CHK(iprim == 10); OK(sdis_scene_boundary_project_position(scn, 10, pos, uv0)); @@ -219,7 +227,11 @@ test_scene_3d(struct sdis_device* dev, struct sdis_interface* interf) dst = d3_len(d3_sub(pos1, pos, pos1)); CHK(eq_eps(dst, 0.1, 1.e-6)); - OK(sdis_scene_find_closest_point(scn, pos, 0.09, &iprim, uv2)); + closest_pt_args.position[0] = pos[0]; + closest_pt_args.position[1] = pos[1]; + closest_pt_args.position[2] = pos[2]; + closest_pt_args.radius = 0.09; + OK(sdis_scene_find_closest_point(scn, &closest_pt_args, &iprim, uv2)); CHK(iprim == SDIS_PRIMITIVE_NONE); FOR_EACH(i, 0, 64) { @@ -228,7 +240,12 @@ test_scene_3d(struct sdis_device* dev, struct sdis_interface* interf) OK(sdis_scene_get_boundary_position(scn, 4, uv0, pos)); OK(sdis_scene_boundary_project_position(scn, 4, pos, uv1)); - OK(sdis_scene_find_closest_point(scn, pos, INF, &iprim, uv2)); + + closest_pt_args.position[0] = pos[0]; + closest_pt_args.position[1] = pos[1]; + closest_pt_args.position[2] = pos[2]; + closest_pt_args.radius = INF; + OK(sdis_scene_find_closest_point(scn, &closest_pt_args, &iprim, uv2)); CHK(d2_eq_eps(uv0, uv1, 1.e-6)); CHK(d2_eq_eps(uv1, uv2, 1.e-6)); CHK(iprim == 4); @@ -264,6 +281,8 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) double duplicated_vertices[] = { 0, 0, 0, 0 }; struct sdis_scene* scn = NULL; struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT; + struct sdis_scene_find_closest_point_args closest_pt_args = + SDIS_SCENE_FIND_CLOSEST_POINT_ARGS_NULL; struct sdis_ambient_radiative_temperature trad = SDIS_AMBIENT_RADIATIVE_TEMPERATURE_NULL; double lower[2], upper[2]; @@ -407,12 +426,14 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) BA(sdis_scene_boundary_project_position(scn, 1, pos, NULL)); OK(sdis_scene_boundary_project_position(scn, 1, pos, &u1)); - BA(sdis_scene_find_closest_point(NULL, pos, INF, &iprim, &u2)); - BA(sdis_scene_find_closest_point(scn, NULL, INF, &iprim, &u2)); - BA(sdis_scene_find_closest_point(scn, pos, 0, &iprim, &u2)); - BA(sdis_scene_find_closest_point(scn, pos, INF, NULL, &u2)); - BA(sdis_scene_find_closest_point(scn, pos, INF, &iprim, NULL)); - OK(sdis_scene_find_closest_point(scn, pos, INF, &iprim, &u2)); + closest_pt_args.position[0] = pos[0]; + closest_pt_args.position[1] = pos[1]; + closest_pt_args.radius = INF; + BA(sdis_scene_find_closest_point(NULL, &closest_pt_args, &iprim, &u2)); + BA(sdis_scene_find_closest_point(scn, NULL, &iprim, &u2)); + BA(sdis_scene_find_closest_point(scn, &closest_pt_args, NULL, &u2)); + BA(sdis_scene_find_closest_point(scn, &closest_pt_args, &iprim, NULL)); + OK(sdis_scene_find_closest_point(scn, &closest_pt_args, &iprim, &u2)); CHK(eq_eps(u0, u1, 1.e-6)); CHK(eq_eps(u1, u2, 1.e-6)); @@ -420,7 +441,10 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) pos[0] = 0.5; pos[1] = 0.1; - OK(sdis_scene_find_closest_point(scn, pos, INF, &iprim, &u2)); + closest_pt_args.position[0] = pos[0]; + closest_pt_args.position[1] = pos[1]; + closest_pt_args.radius = INF; + OK(sdis_scene_find_closest_point(scn, &closest_pt_args, &iprim, &u2)); CHK(iprim == 0); OK(sdis_scene_boundary_project_position(scn, 0, pos, &u0)); @@ -430,7 +454,10 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) dst = d2_len(d2_sub(pos1, pos, pos1)); CHK(eq_eps(dst, 0.1, 1.e-6)); - OK(sdis_scene_find_closest_point(scn, pos, 0.09, &iprim, &u2)); + closest_pt_args.position[0] = pos[0]; + closest_pt_args.position[1] = pos[1]; + closest_pt_args.radius = 0.09; + OK(sdis_scene_find_closest_point(scn, &closest_pt_args, &iprim, &u2)); CHK(iprim == SDIS_PRIMITIVE_NONE); FOR_EACH(i, 0, 64) { @@ -438,7 +465,11 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) OK(sdis_scene_get_boundary_position(scn, 2, &u0, pos)); OK(sdis_scene_boundary_project_position(scn, 2, pos, &u1)); - OK(sdis_scene_find_closest_point(scn, pos, INF, &iprim, &u2)); + + closest_pt_args.position[0] = pos[0]; + closest_pt_args.position[1] = pos[1]; + closest_pt_args.radius = INF; + OK(sdis_scene_find_closest_point(scn, &closest_pt_args, &iprim, &u2)); CHK(eq_eps(u0, u1, 1.e-6)); CHK(eq_eps(u1, u2, 1.e-6)); CHK(iprim == 2); diff --git a/src/test_sdis_solve_probe_boundary_list.c b/src/test_sdis_solve_probe_boundary_list.c @@ -400,20 +400,25 @@ check_probe_boundary_list(struct sdis_scene* scn, const int is_master_process) SDIS_SOLVE_PROBE_BOUNDARY_LIST_ARGS_DEFAULT; size_t iprobe; + /* Miscellaneous */ + struct sdis_scene_find_closest_point_args closest_pt_args = + SDIS_SCENE_FIND_CLOSEST_POINT_ARGS_NULL; + (void)is_master_process; /* Setup the list of probes to calculate */ args.probes = probes; args.nprobes = NPROBES; FOR_EACH(iprobe, 0, NPROBES) { - double pos[3] = {0, 0, 0}; - sample_sphere(pos); + sample_sphere(closest_pt_args.position); + closest_pt_args.radius = INF; probes[iprobe] = SDIS_SOLVE_PROBE_BOUNDARY_ARGS_DEFAULT; probes[iprobe].nrealisations = 10000; probes[iprobe].side = SDIS_FRONT; + OK(sdis_scene_find_closest_point - (scn, pos, INF, &probes[iprobe].iprim, probes[iprobe].uv)); + (scn, &closest_pt_args, &probes[iprobe].iprim, probes[iprobe].uv)); } check_probe_boundary_list_api(scn, &args);