stardis-solver

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

commit 03a6935c69dd4b776d89f1e25dc800ec567bcbc9
parent 3434fe78d33de5b010b800d47550cd5b744ce1ce
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Wed, 13 Feb 2019 10:34:21 +0100

Add API calls to get access to enclosures descriptor

Diffstat:
Msrc/sdis.h | 13+++++++++++++
Msrc/sdis_scene.c | 26++++++++++++++++++++++++++
Msrc/sdis_scene_Xd.h | 6+++++-
Msrc/sdis_scene_c.h | 2++
Msrc/test_sdis_scene.c | 20++++++++++++++++++++
5 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/src/sdis.h b/src/sdis.h @@ -47,6 +47,8 @@ /* Forward declaration of external opaque data types */ struct logger; struct mem_allocator; +struct senc2d_descriptor; +struct senc_descriptor; /* Forward declaration of the Stardis opaque data types. These data types are * ref counted. Once created with the appropriated `sdis_<TYPE>_create' @@ -529,6 +531,17 @@ sdis_scene_boundary_project_position const double pos[3], double uv[]); +/* Get the descriptor of the scene's enclosures */ +SDIS_API res_T +sdis_get_geometry2d_analyze + (struct sdis_scene* scn, + struct senc2d_descriptor** descriptor); + +SDIS_API res_T +sdis_get_geometry_analyze + (struct sdis_scene* scn, + struct senc_descriptor** descriptor); + /******************************************************************************* * An estimator stores the state of a simulation ******************************************************************************/ diff --git a/src/sdis_scene.c b/src/sdis_scene.c @@ -106,6 +106,8 @@ scene_release(ref_T * ref) htable_d_release(&scn->tmp_hc_ub); if(scn->s2d_view) S2D(scene_view_ref_put(scn->s2d_view)); if(scn->s3d_view) S3D(scene_view_ref_put(scn->s3d_view)); + if(scn->senc_descriptor) SENC(descriptor_ref_put(scn->senc_descriptor)); + if(scn->senc2d_descriptor) SENC2D(descriptor_ref_put(scn->senc2d_descriptor)); MEM_RM(dev->allocator, scn); SDIS(device_ref_put(dev)); } @@ -275,6 +277,30 @@ sdis_scene_boundary_project_position return RES_OK; } +res_T +sdis_get_geometry2d_analyze + (struct sdis_scene* scn, + struct senc2d_descriptor** descriptor) +{ + if(!scn || !descriptor) return RES_BAD_ARG; + if(! scn->senc2d_descriptor) return RES_BAD_ARG; /* Scene is 3D */ + SENC2D(descriptor_ref_get(scn->senc2d_descriptor)); + *descriptor = scn->senc2d_descriptor; + return RES_OK; +} + +res_T +sdis_get_geometry_analyze +(struct sdis_scene* scn, + struct senc_descriptor** descriptor) +{ + if(!scn || !descriptor) return RES_BAD_ARG; + if(!scn->senc_descriptor) return RES_BAD_ARG; /* Scene is 2D */ + SENC(descriptor_ref_get(scn->senc_descriptor)); + *descriptor = scn->senc_descriptor; + return RES_OK; +} + /******************************************************************************* * Local miscellaneous function ******************************************************************************/ diff --git a/src/sdis_scene_Xd.h b/src/sdis_scene_Xd.h @@ -780,10 +780,14 @@ XD(scene_create) log_err(dev, "%s: could not setup the enclosures.\n", FUNC_NAME); goto error; } +#if DIM==2 + scn->senc2d_descriptor = desc; +#else + scn->senc_descriptor = desc; +#endif exit: if(out_scn) *out_scn = scn; - if(desc) SENCXD(descriptor_ref_put(desc)); return res; error: if(scn) { diff --git a/src/sdis_scene_c.h b/src/sdis_scene_c.h @@ -181,6 +181,8 @@ struct sdis_scene { struct darray_prim_prop prim_props; /* Per primitive properties */ struct s2d_scene_view* s2d_view; struct s3d_scene_view* s3d_view; + struct senc_descriptor* senc_descriptor; + struct senc2d_descriptor* senc2d_descriptor; struct htable_d tmp_hc_ub; /* Map an enclosure id to its hc upper bound */ struct htable_enclosure enclosures; /* Map an enclosure id to its data */ diff --git a/src/test_sdis_scene.c b/src/test_sdis_scene.c @@ -19,6 +19,8 @@ #include <rsys/double2.h> #include <rsys/double3.h> #include <rsys/math.h> +#include<star/senc.h> +#include<star/senc2d.h> struct context { const double* positions; @@ -91,6 +93,8 @@ test_scene_3d(struct sdis_device* dev, struct sdis_interface* interf) double lower[3], upper[3]; double uv0[2], uv1[2], pos[3], pos1[3]; struct context ctx; + struct senc_descriptor* descriptor; + struct senc2d_descriptor* descriptor2d; size_t ntris, npos; size_t i; @@ -162,6 +166,13 @@ test_scene_3d(struct sdis_device* dev, struct sdis_interface* interf) OK(sdis_scene_get_boundary_position(scn, 6, uv1, pos1)); CHK(!d3_eq_eps(pos1, pos, 1.e-6)); + BA(sdis_get_geometry_analyze(NULL, NULL)); + BA(sdis_get_geometry_analyze(scn, NULL)); + BA(sdis_get_geometry_analyze(NULL, &descriptor)); + OK(sdis_get_geometry_analyze(scn, &descriptor)); + OK(senc_descriptor_ref_put(descriptor)); + BA(sdis_get_geometry2d_analyze(scn, &descriptor2d)); + BA(sdis_scene_ref_get(NULL)); OK(sdis_scene_ref_get(scn)); BA(sdis_scene_ref_put(NULL)); @@ -176,6 +187,8 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) double lower[2], upper[2]; double u0, u1, pos[2]; struct context ctx; + struct senc2d_descriptor* descriptor; + struct senc_descriptor* descriptor3d; size_t nsegs, npos; size_t i; @@ -248,6 +261,13 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf) OK(sdis_scene_boundary_project_position(scn, 3, pos, &u0)); CHK(eq_eps(u0, 1, 1.e-6)); + BA(sdis_get_geometry2d_analyze(NULL, NULL)); + BA(sdis_get_geometry2d_analyze(scn, NULL)); + BA(sdis_get_geometry2d_analyze(NULL, &descriptor)); + OK(sdis_get_geometry2d_analyze(scn, &descriptor)); + OK(senc2d_descriptor_ref_put(descriptor)); + BA(sdis_get_geometry_analyze(scn, &descriptor3d)); + OK(sdis_scene_ref_put(scn)); }