commit a98df7818238286ecb492b2cb2ad4acf6be00611
parent d331c22d3285a5d09a3cfb0e1048dd2452f9ef8e
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 16 Nov 2020 10:25:48 +0100
Update the sdis_scene_[2d_]create API
The input parameters are now provided through a struct
sdis_scene_create_args variable.
Diffstat:
30 files changed, 776 insertions(+), 549 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -175,7 +175,7 @@ if(NOT NO_TEST)
endfunction()
new_test(test_sdis_camera)
- new_test(test_sdis_compute_mean_power)
+ new_test(test_sdis_compute_power)
new_test(test_sdis_conducto_radiative)
new_test(test_sdis_conducto_radiative_2d)
new_test(test_sdis_convection)
@@ -213,7 +213,7 @@ if(NOT NO_TEST)
add_test(test_sdis_volumic_power3_2d test_sdis_volumic_power3_2d)
endif()
- target_link_libraries(test_sdis_compute_mean_power Star3DUT)
+ target_link_libraries(test_sdis_compute_power Star3DUT)
target_link_libraries(test_sdis_solid_random_walk_robustness Star3DUT)
target_link_libraries(test_sdis_solve_medium Star3DUT)
target_link_libraries(test_sdis_solve_probe3 Star3DUT)
diff --git a/src/sdis.h b/src/sdis.h
@@ -327,6 +327,62 @@ typedef res_T
void* context);
/*******************************************************************************
+ * Data types of scene creation
+ ******************************************************************************/
+/* Functor used to retrieve the indices toward the vertices of a geometric
+ * primitive. Geometric primitive means for segment in 2D and triangle in 3D */
+typedef void
+(*sdis_get_primitive_indices_T)
+ (const size_t iprim, /* Index of the primitive */
+ size_t ids[], /* Output list of primitive indices */
+ void* ctx); /* User defined data */
+
+/* Retrieve the interface, i.e. the physical properties, associated to a given
+ * geometric primitive */
+typedef void
+(*sdis_get_primitive_interface_T)
+ (const size_t iprim, /* Index of the primitive */
+ struct sdis_interface** interf,
+ void* ctx);
+
+/* Retrieve the coordinates of a vertex */
+typedef void
+(*sdis_get_vertex_position_T)
+ (const size_t ivert, /* Index of the vertex */
+ double pos[], /* Output list of vertex coordinates */
+ void* ctx);
+
+struct sdis_scene_create_args {
+ /* Functors to retrieve the geometric description */
+ sdis_get_primitive_indices_T get_indices;
+ sdis_get_primitive_interface_T get_interface;
+ sdis_get_vertex_position_T get_position;
+
+ /* Pointer toward client side sent as the last argument of the callbacks */
+ void* context;
+
+ size_t nprimitives; /* #primitives, i.e. #segments or #triangles */
+ size_t nvertices; /* #vertices */
+ double fp_to_meter; /* Scale factor used to convert 1.0 in 1 meter */
+ double trad; /* Ambiant radiative temperature */
+ double tref; /* Temperature used to linearize the radiative temperature */
+};
+
+#define SDIS_SCENE_CREATE_ARGS_DEFAULT__ { \
+ NULL, /* Get indices */ \
+ NULL, /* Get interfaces */ \
+ NULL, /* Get position */ \
+ NULL, /* Context */ \
+ 0, /* #primitives */ \
+ 0, /* #vertices */ \
+ 1.0, /* #Floating point to meter scale factor */ \
+ -1.0, /* Ambient radiative temperature */ \
+ -1.0 /* Reference temperature */ \
+}
+static const struct sdis_scene_create_args SDIS_SCENE_CREATE_ARGS_DEFAULT =
+ SDIS_SCENE_CREATE_ARGS_DEFAULT__;
+
+/*******************************************************************************
* Data types of the input simulation parameters
******************************************************************************/
struct sdis_solve_probe_args {
@@ -702,7 +758,7 @@ sdis_interface_get_id
*
* Note that each triangle has 2 sides: a front and a back side. By convention,
* the front side of a triangle is the side where its vertices are clock wise
- * ordered. The back side of a triangle is the exact opposite: it is the side
+ * ordered. The back side of a triangle is the exact opposite: it is the side
* where the triangle vertices are counter-clock wise ordered. The front and
* back media of a triangle interface directly refer to this convention and
* thus one has to take care of how the triangle vertices are defined to ensure
@@ -710,18 +766,7 @@ sdis_interface_get_id
SDIS_API res_T
sdis_scene_create
(struct sdis_device* dev,
- const size_t ntris, /* #triangles */
- void (*indices) /* Retrieve the indices toward the vertices of `itri' */
- (const size_t itri, size_t ids[3], void* ctx),
- void (*interf) /* Get the interface of the triangle `itri' */
- (const size_t itri, struct sdis_interface** bound, void* ctx),
- const size_t nverts, /* #vertices */
- void (*position) /* Retrieve the position of the vertex `ivert' */
- (const size_t ivert, double pos[3], void* ctx),
- const double fp_to_meter,
- const double trad,
- const double tref,
- void* ctx, /* Client side data sent as input of the previous callbacks */
+ const struct sdis_scene_create_args* args,
struct sdis_scene** scn);
/* Create a 2D scene. The geometry of the 2D scene is defined by an indexed
@@ -742,18 +787,7 @@ sdis_scene_create
SDIS_API res_T
sdis_scene_2d_create
(struct sdis_device* dev,
- const size_t nsegs, /* #segments */
- void (*indices) /* Retrieve the indices toward the vertices of `iseg' */
- (const size_t iseg, size_t ids[2], void* ctx),
- void (*interf) /* Get the interface of the segment `iseg' */
- (const size_t iseg, struct sdis_interface** bound, void* ctx),
- const size_t nverts, /* #vertices */
- void (*position) /* Retrieve the position of the vertex `ivert' */
- (const size_t ivert, double pos[2], void* ctx),
- const double fp_to_meter,
- const double trad,
- const double tref,
- void* ctx, /* Client side data sent as input of the previous callbacks */
+ const struct sdis_scene_create_args* args,
struct sdis_scene** scn);
SDIS_API res_T
diff --git a/src/sdis_scene.c b/src/sdis_scene.c
@@ -125,37 +125,19 @@ scene_release(ref_T * ref)
res_T
sdis_scene_create
(struct sdis_device* dev,
- const size_t ntris, /* #triangles */
- void (*indices)(const size_t itri, size_t ids[3], void*),
- void (*interf)(const size_t itri, struct sdis_interface** bound, void*),
- const size_t nverts, /* #vertices */
- void (*position)(const size_t ivert, double pos[3], void* ctx),
- const double fp_to_meter,
- const double trad,
- const double tref,
- void* ctx,
+ const struct sdis_scene_create_args* args,
struct sdis_scene** out_scn)
{
- return scene_create_3d
- (dev, ntris, indices, interf, nverts, position, fp_to_meter, trad, tref, ctx, out_scn);
+ return scene_create_3d(dev, args, out_scn);
}
res_T
sdis_scene_2d_create
(struct sdis_device* dev,
- const size_t nsegs, /* #segments */
- void (*indices)(const size_t iseg, size_t ids[2], void*),
- void (*interf)(const size_t iseg, struct sdis_interface** bound, void*),
- const size_t nverts, /* #vertices */
- void (*position)(const size_t ivert, double pos[2], void* ctx),
- const double fp_to_meter,
- const double trad,
- const double tref,
- void* ctx,
+ const struct sdis_scene_create_args* args,
struct sdis_scene** out_scn)
{
- return scene_create_2d
- (dev, nsegs, indices, interf, nverts, position, fp_to_meter, trad, tref, ctx, out_scn);
+ return scene_create_2d(dev, args, out_scn);
}
res_T
diff --git a/src/sdis_scene_Xd.h b/src/sdis_scene_Xd.h
@@ -106,6 +106,20 @@ clear_properties(struct sdis_scene* scn)
darray_prim_prop_clear(&scn->prim_props);
}
+static INLINE int
+check_sdis_scene_create_args(const struct sdis_scene_create_args* args)
+{
+ return args
+ && args->get_indices
+ && args->get_interface
+ && args->get_position
+ && args->nprimitives
+ && args->nprimitives < UINT_MAX
+ && args->nvertices
+ && args->nvertices < UINT_MAX
+ && args->fp_to_meter > 0;
+}
+
#endif /* SDIS_SCENE_XD_H */
#else /* !SDIS_SCENE_DIMENSION */
@@ -524,10 +538,10 @@ static res_T
XD(run_analyze)
(struct sdis_scene* scn,
const size_t nprims, /* #primitives */
- void (*indices)(const size_t iprim, size_t ids[], void*),
- void (interf)(const size_t iprim, struct sdis_interface**, void*),
+ sdis_get_primitive_indices_T indices,
+ sdis_get_primitive_interface_T interf,
const size_t nverts, /* #vertices */
- void (*position)(const size_t ivert, double pos[], void*),
+ sdis_get_vertex_position_T position,
void* ctx,
struct sencXd(scene)** out_scn)
{
@@ -851,24 +865,14 @@ error:
static res_T
XD(scene_create)
(struct sdis_device* dev,
- const size_t nprims, /* #primitives */
- void (*indices)(const size_t iprim, size_t ids[], void*),
- void (*interf)(const size_t iprim, struct sdis_interface** bound, void*),
- const size_t nverts, /* #vertices */
- void (*position)(const size_t ivert, double pos[], void* ctx),
- const double fp_to_meter,
- const double trad,
- const double tref,
- void* ctx,
+ const struct sdis_scene_create_args* args,
struct sdis_scene** out_scn)
{
struct sencXd(scene)* senc3d_scn = NULL;
struct sdis_scene* scn = NULL;
res_T res = RES_OK;
- if(!dev || !out_scn || !nprims || !indices || !interf || !nverts
- || !position || nprims > UINT_MAX || nverts > UINT_MAX
- || fp_to_meter <= 0 || tref < 0) {
+ if(!dev || !check_sdis_scene_create_args(args) || !out_scn) {
res = RES_BAD_ARG;
goto error;
}
@@ -879,12 +883,13 @@ XD(scene_create)
res = RES_MEM_ERR;
goto error;
}
+
ref_init(&scn->ref);
SDIS(device_ref_get(dev));
scn->dev = dev;
- scn->fp_to_meter = fp_to_meter;
- scn->ambient_radiative_temperature = trad;
- scn->reference_temperature = tref;
+ scn->fp_to_meter = args->fp_to_meter;
+ scn->ambient_radiative_temperature = args->trad;
+ scn->reference_temperature = args->tref;
scn->outer_enclosure_id = UINT_MAX;
darray_interf_init(dev->allocator, &scn->interfaces);
darray_medium_init(dev->allocator, &scn->media);
@@ -892,12 +897,20 @@ XD(scene_create)
htable_enclosure_init(dev->allocator, &scn->enclosures);
htable_d_init(dev->allocator, &scn->tmp_hc_ub);
- res = XD(run_analyze)(scn, nprims, indices, interf, nverts, position, ctx, &senc3d_scn);
+ res = XD(run_analyze)
+ (scn,
+ args->nprimitives,
+ args->get_indices,
+ args->get_interface,
+ args->nvertices,
+ args->get_position,
+ args->context,
+ &senc3d_scn);
if(res != RES_OK) {
log_err(dev, "%s: error during the scene analysis.\n", FUNC_NAME);
goto error;
}
- res = XD(setup_properties)(scn, senc3d_scn, interf, ctx);
+ res = XD(setup_properties)(scn, senc3d_scn, args->get_interface, args->context);
if(res != RES_OK) {
log_err(dev, "%s: could not setup the scene interfaces and their media.\n",
FUNC_NAME);
diff --git a/src/test_sdis_compute_mean_power.c b/src/test_sdis_compute_mean_power.c
@@ -1,340 +0,0 @@
-/* Copyright (C) 2016-2020 |Meso|Star> (contact@meso-star.com)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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.h"
-#include "test_sdis_utils.h"
-
-#include <rsys/stretchy_array.h>
-#include <star/s3dut.h>
-
-#define UNKOWN_TEMPERATURE -1
-#define N 100000ul /* #realisations */
-#define POWER0 10
-#define POWER1 5
-
-static INLINE void
-check_intersection
- (const double val0,
- const double eps0,
- const double val1,
- const double eps1)
-{
- double interval0[2], interval1[2];
- double intersection[2];
- interval0[0] = val0 - eps0;
- interval0[1] = val0 + eps0;
- interval1[0] = val1 - eps1;
- interval1[1] = val1 + eps1;
- intersection[0] = MMAX(interval0[0], interval1[0]);
- intersection[1] = MMIN(interval0[1], interval1[1]);
- CHK(intersection[0] <= intersection[1]);
-}
-
-/*******************************************************************************
- * Geometry
- ******************************************************************************/
-struct context {
- struct s3dut_mesh_data msh0;
- struct s3dut_mesh_data msh1;
- struct sdis_interface* interf0;
- struct sdis_interface* interf1;
-};
-
-static void
-get_indices(const size_t itri, size_t ids[3], void* context)
-{
- const struct context* ctx = context;
- /* Note that we swap the indices to ensure that the triangle normals point
- * inward the super shape */
- if(itri < ctx->msh0.nprimitives) {
- ids[0] = ctx->msh0.indices[itri*3+0];
- ids[2] = ctx->msh0.indices[itri*3+1];
- ids[1] = ctx->msh0.indices[itri*3+2];
- } else {
- const size_t itri2 = itri - ctx->msh0.nprimitives;
- ids[0] = ctx->msh1.indices[itri2*3+0] + ctx->msh0.nvertices;
- ids[2] = ctx->msh1.indices[itri2*3+1] + ctx->msh0.nvertices;
- ids[1] = ctx->msh1.indices[itri2*3+2] + ctx->msh0.nvertices;
- }
-}
-
-static void
-get_position(const size_t ivert, double pos[3], void* context)
-{
- const struct context* ctx = context;
- if(ivert < ctx->msh0.nvertices) {
- pos[0] = ctx->msh0.positions[ivert*3+0] - 2.0;
- pos[1] = ctx->msh0.positions[ivert*3+1];
- pos[2] = ctx->msh0.positions[ivert*3+2];
- } else {
- const size_t ivert2 = ivert - ctx->msh0.nvertices;
- pos[0] = ctx->msh1.positions[ivert2*3+0] + 2.0;
- pos[1] = ctx->msh1.positions[ivert2*3+1];
- pos[2] = ctx->msh1.positions[ivert2*3+2];
- }
-}
-
-static void
-get_interface(const size_t itri, struct sdis_interface** bound, void* context)
-{
- const struct context* ctx = context;
- *bound = itri < ctx->msh0.nprimitives ? ctx->interf0 : ctx->interf1;
-}
-
-/*******************************************************************************
- * Interface
- ******************************************************************************/
-static double
-interface_get_convection_coef
- (const struct sdis_interface_fragment* frag, struct sdis_data* data)
-{
- CHK(frag != NULL); (void)data;
- return 1.0;
-}
-
-/*******************************************************************************
- * Fluid medium
- ******************************************************************************/
-static double
-fluid_get_temperature
- (const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
-{
- CHK(vtx == NULL); (void)data;
- return 300;
-}
-
-/*******************************************************************************
- * Solid medium
- ******************************************************************************/
-static double
-solid_get_calorific_capacity
- (const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
-{
- CHK(vtx != NULL); (void)data;
- return 1.0;
-}
-
-static double
-solid_get_thermal_conductivity
- (const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
-{
- CHK(vtx != NULL); (void)data;
- return 1.0;
-}
-
-static double
-solid_get_volumic_mass
- (const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
-{
- CHK(vtx != NULL); (void)data;
- return 1.0;
-}
-
-static double
-solid_get_delta
- (const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
-{
- CHK(vtx != NULL); (void)data;
- return 1.0 / 20.0;
-}
-
-static double
-solid_get_volumic_power
- (const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
-{
- CHK(vtx != NULL); (void)data;
- return vtx->P[0] < 0 ? POWER0 : POWER1;
-}
-
-/*******************************************************************************
- * Test
- ******************************************************************************/
-int
-main(int argc, char** argv)
-{
- struct mem_allocator allocator;
- struct context ctx;
- struct s3dut_mesh* sphere = NULL;
- struct s3dut_mesh* cylinder = NULL;
- struct sdis_data* data = NULL;
- struct sdis_device* dev = NULL;
- struct sdis_estimator* estimator = NULL;
- struct sdis_medium* fluid = NULL;
- struct sdis_medium* solid0 = NULL;
- struct sdis_medium* solid1 = NULL;
- struct sdis_interface* interf0 = NULL;
- struct sdis_interface* interf1 = NULL;
- struct sdis_scene* scn = NULL;
- struct sdis_mc mpow = SDIS_MC_NULL;
- struct sdis_mc time = SDIS_MC_NULL;
- struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
- struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
- struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL;
- struct sdis_compute_power_args args = SDIS_COMPUTE_POWER_ARGS_DEFAULT;
- size_t nverts = 0;
- size_t ntris = 0;
- double ref = 0;
- (void)argc, (void) argv;
-
- OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
- OK(sdis_device_create(NULL, &allocator, SDIS_NTHREADS_DEFAULT, 1, &dev));
-
- /* Setup the interface shader */
- interf_shader.convection_coef = interface_get_convection_coef;
-
- /* Setup the fluid shader */
- fluid_shader.temperature = fluid_get_temperature;
-
- /* Setup the solid shader */
- solid_shader.calorific_capacity = solid_get_calorific_capacity;
- solid_shader.thermal_conductivity = solid_get_thermal_conductivity;
- solid_shader.volumic_mass = solid_get_volumic_mass;
- solid_shader.delta_solid = solid_get_delta;
- solid_shader.volumic_power = solid_get_volumic_power;
-
- /* Create the fluid */
- OK(sdis_fluid_create(dev, &fluid_shader, NULL, &fluid));
-
- /* Create the solids */
- OK(sdis_solid_create(dev, &solid_shader, data, &solid0));
- OK(sdis_solid_create(dev, &solid_shader, data, &solid1));
-
- /* Create the interface0 */
- OK(sdis_interface_create(dev, solid0, fluid, &interf_shader, NULL, &interf0));
- OK(sdis_interface_create(dev, solid1, fluid, &interf_shader, NULL, &interf1));
- ctx.interf0 = interf0;
- ctx.interf1 = interf1;
-
- /* Create the geometry */
- OK(s3dut_create_sphere(&allocator, 1, 512, 256, &sphere));
- OK(s3dut_create_cylinder(&allocator, 1, 10, 512, 8, &cylinder));
- OK(s3dut_mesh_get_data(sphere, &ctx.msh0));
- OK(s3dut_mesh_get_data(cylinder, &ctx.msh1));
-
- /* Create the scene */
- ntris = ctx.msh0.nprimitives + ctx.msh1.nprimitives;
- nverts = ctx.msh0.nvertices + ctx.msh1.nvertices;
- OK(sdis_scene_create(dev, ntris, get_indices, get_interface, nverts,
- get_position, 1, -1, 0, &ctx, &scn));
-
- /* Test sdis_compute_power function */
- args.nrealisations = N;
- args.medium = solid0;
- args.time_range[0] = INF;
- args.time_range[1] = INF;
- BA(sdis_compute_power(NULL, &args, &estimator));
- BA(sdis_compute_power(scn, NULL, &estimator));
- BA(sdis_compute_power(scn, &args, NULL));
- args.nrealisations = 0;
- BA(sdis_compute_power(scn, &args, &estimator));
- args.nrealisations = N;
- args.medium = NULL;
- BA(sdis_compute_power(scn, &args, &estimator));
- args.medium = solid0;
- args.time_range[0] = args.time_range[1] = -1;
- BA(sdis_compute_power(scn, &args, &estimator));
- args.time_range[0] = 1;
- BA(sdis_compute_power(scn, &args, &estimator));
- args.time_range[1] = 0;
- BA(sdis_compute_power(scn, &args, &estimator));
- args.time_range[0] = args.time_range[1] = INF;
- OK(sdis_compute_power(scn, &args, &estimator));
-
- BA(sdis_estimator_get_power(NULL, &mpow));
- BA(sdis_estimator_get_power(estimator, NULL));
- OK(sdis_estimator_get_power(estimator, &mpow));
- OK(sdis_estimator_get_realisation_time(estimator, &time));
-
- /* Check results for solid 0 */
- ref = 4.0/3.0 * PI * POWER0;
- printf("Mean power of the solid0 = %g ~ %g +/- %g\n",
- ref, mpow.E, mpow.SE);
- check_intersection(ref, 1.e-2, mpow.E, 3*mpow.SE);
- OK(sdis_estimator_ref_put(estimator));
-
- /* Check results for solid 1 */
- args.medium = solid1;
- OK(sdis_compute_power(scn, &args, &estimator));
- OK(sdis_estimator_get_power(estimator, &mpow));
- ref = PI * 10 * POWER1;
- printf("Mean power of the solid1 = %g ~ %g +/- %g\n",
- ref, mpow.E, mpow.SE);
- check_intersection(ref, 1.e-2, mpow.E, 3*mpow.SE);
- OK(sdis_estimator_ref_put(estimator));
-
- /* Check for a not null time range */
- args.time_range[0] = 0;
- args.time_range[1] = 10;
- OK(sdis_compute_power(scn, &args, &estimator));
- OK(sdis_estimator_get_power(estimator, &mpow));
- ref = PI * 10 * POWER1 / 10;
- printf("Mean power of the solid1 in [0, 10] s = %g ~ %g +/- %g\n",
- ref, mpow.E, mpow.SE);
- check_intersection(ref, 1.e-2, mpow.E, 3*mpow.SE);
- OK(sdis_estimator_ref_put(estimator));
-
- /* Reset the scene with only one solid medium */
- OK(sdis_scene_ref_put(scn));
- ctx.interf0 = interf0;
- ctx.interf1 = interf0;
- OK(sdis_scene_create(dev, ntris, get_indices, get_interface, nverts,
- get_position, 1, -1, 0, &ctx, &scn));
-
- /* Check invalid medium */
- args.time_range[0] = args.time_range[1] = 1;
- args.medium = solid1;
- BA(sdis_compute_power(scn, &args, &estimator));
-
- /* Check non constant volumic power */
- args.medium = solid0;
- OK(sdis_compute_power(scn, &args, &estimator));
- OK(sdis_estimator_get_power(estimator, &mpow));
- ref = 4.0/3.0*PI*POWER0 + PI*10*POWER1;
- printf("Mean power of the sphere+cylinder = %g ~ %g +/- %g\n",
- ref, mpow.E, mpow.SE);
- check_intersection(ref, 1.5e-1, mpow.E, 3*mpow.SE);
- OK(sdis_estimator_ref_put(estimator));
-
-#if 0
- {
- double* vertices = NULL;
- size_t* indices = NULL;
- size_t i;
- CHK(vertices = MEM_CALLOC(&allocator, nverts*3, sizeof(*vertices)));
- CHK(indices = MEM_CALLOC(&allocator, ntris*3, sizeof(*indices)));
- FOR_EACH(i, 0, ntris) get_indices(i, indices + i*3, &ctx);
- FOR_EACH(i, 0, nverts) get_position(i, vertices + i*3, &ctx);
- dump_mesh(stdout, vertices, nverts, indices, ntris);
- MEM_RM(&allocator, vertices);
- MEM_RM(&allocator, indices);
- }
-#endif
-
- /* Clean up memory */
- OK(sdis_device_ref_put(dev));
- OK(sdis_medium_ref_put(fluid));
- OK(sdis_medium_ref_put(solid0));
- OK(sdis_medium_ref_put(solid1));
- OK(sdis_interface_ref_put(interf0));
- OK(sdis_interface_ref_put(interf1));
- OK(sdis_scene_ref_put(scn));
- OK(s3dut_mesh_ref_put(sphere));
- OK(s3dut_mesh_ref_put(cylinder));
-
- check_memory_allocator(&allocator);
- mem_shutdown_proxy_allocator(&allocator);
- CHK(mem_allocated_size() == 0);
- return 0;
-}
diff --git a/src/test_sdis_compute_power.c b/src/test_sdis_compute_power.c
@@ -0,0 +1,345 @@
+/* Copyright (C) 2016-2020 |Meso|Star> (contact@meso-star.com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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.h"
+#include "test_sdis_utils.h"
+
+#include <rsys/stretchy_array.h>
+#include <star/s3dut.h>
+
+#define UNKOWN_TEMPERATURE -1
+#define N 100000ul /* #realisations */
+#define POWER0 10
+#define POWER1 5
+
+static INLINE void
+check_intersection
+ (const double val0,
+ const double eps0,
+ const double val1,
+ const double eps1)
+{
+ double interval0[2], interval1[2];
+ double intersection[2];
+ interval0[0] = val0 - eps0;
+ interval0[1] = val0 + eps0;
+ interval1[0] = val1 - eps1;
+ interval1[1] = val1 + eps1;
+ intersection[0] = MMAX(interval0[0], interval1[0]);
+ intersection[1] = MMIN(interval0[1], interval1[1]);
+ CHK(intersection[0] <= intersection[1]);
+}
+
+/*******************************************************************************
+ * Geometry
+ ******************************************************************************/
+struct context {
+ struct s3dut_mesh_data msh0;
+ struct s3dut_mesh_data msh1;
+ struct sdis_interface* interf0;
+ struct sdis_interface* interf1;
+};
+
+static void
+get_indices(const size_t itri, size_t ids[3], void* context)
+{
+ const struct context* ctx = context;
+ /* Note that we swap the indices to ensure that the triangle normals point
+ * inward the super shape */
+ if(itri < ctx->msh0.nprimitives) {
+ ids[0] = ctx->msh0.indices[itri*3+0];
+ ids[2] = ctx->msh0.indices[itri*3+1];
+ ids[1] = ctx->msh0.indices[itri*3+2];
+ } else {
+ const size_t itri2 = itri - ctx->msh0.nprimitives;
+ ids[0] = ctx->msh1.indices[itri2*3+0] + ctx->msh0.nvertices;
+ ids[2] = ctx->msh1.indices[itri2*3+1] + ctx->msh0.nvertices;
+ ids[1] = ctx->msh1.indices[itri2*3+2] + ctx->msh0.nvertices;
+ }
+}
+
+static void
+get_position(const size_t ivert, double pos[3], void* context)
+{
+ const struct context* ctx = context;
+ if(ivert < ctx->msh0.nvertices) {
+ pos[0] = ctx->msh0.positions[ivert*3+0] - 2.0;
+ pos[1] = ctx->msh0.positions[ivert*3+1];
+ pos[2] = ctx->msh0.positions[ivert*3+2];
+ } else {
+ const size_t ivert2 = ivert - ctx->msh0.nvertices;
+ pos[0] = ctx->msh1.positions[ivert2*3+0] + 2.0;
+ pos[1] = ctx->msh1.positions[ivert2*3+1];
+ pos[2] = ctx->msh1.positions[ivert2*3+2];
+ }
+}
+
+static void
+get_interface(const size_t itri, struct sdis_interface** bound, void* context)
+{
+ const struct context* ctx = context;
+ *bound = itri < ctx->msh0.nprimitives ? ctx->interf0 : ctx->interf1;
+}
+
+/*******************************************************************************
+ * Interface
+ ******************************************************************************/
+static double
+interface_get_convection_coef
+ (const struct sdis_interface_fragment* frag, struct sdis_data* data)
+{
+ CHK(frag != NULL); (void)data;
+ return 1.0;
+}
+
+/*******************************************************************************
+ * Fluid medium
+ ******************************************************************************/
+static double
+fluid_get_temperature
+ (const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
+{
+ CHK(vtx == NULL); (void)data;
+ return 300;
+}
+
+/*******************************************************************************
+ * Solid medium
+ ******************************************************************************/
+static double
+solid_get_calorific_capacity
+ (const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
+{
+ CHK(vtx != NULL); (void)data;
+ return 1.0;
+}
+
+static double
+solid_get_thermal_conductivity
+ (const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
+{
+ CHK(vtx != NULL); (void)data;
+ return 1.0;
+}
+
+static double
+solid_get_volumic_mass
+ (const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
+{
+ CHK(vtx != NULL); (void)data;
+ return 1.0;
+}
+
+static double
+solid_get_delta
+ (const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
+{
+ CHK(vtx != NULL); (void)data;
+ return 1.0 / 20.0;
+}
+
+static double
+solid_get_volumic_power
+ (const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
+{
+ CHK(vtx != NULL); (void)data;
+ return vtx->P[0] < 0 ? POWER0 : POWER1;
+}
+
+/*******************************************************************************
+ * Test
+ ******************************************************************************/
+int
+main(int argc, char** argv)
+{
+ struct mem_allocator allocator;
+ struct context ctx;
+ struct s3dut_mesh* sphere = NULL;
+ struct s3dut_mesh* cylinder = NULL;
+ struct sdis_data* data = NULL;
+ struct sdis_device* dev = NULL;
+ struct sdis_estimator* estimator = NULL;
+ struct sdis_medium* fluid = NULL;
+ struct sdis_medium* solid0 = NULL;
+ struct sdis_medium* solid1 = NULL;
+ struct sdis_interface* interf0 = NULL;
+ struct sdis_interface* interf1 = NULL;
+ struct sdis_scene* scn = NULL;
+ struct sdis_mc mpow = SDIS_MC_NULL;
+ struct sdis_mc time = SDIS_MC_NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
+ struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
+ struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
+ struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL;
+ struct sdis_compute_power_args args = SDIS_COMPUTE_POWER_ARGS_DEFAULT;
+ size_t nverts = 0;
+ size_t ntris = 0;
+ double ref = 0;
+ (void)argc, (void) argv;
+
+ OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
+ OK(sdis_device_create(NULL, &allocator, SDIS_NTHREADS_DEFAULT, 1, &dev));
+
+ /* Setup the interface shader */
+ interf_shader.convection_coef = interface_get_convection_coef;
+
+ /* Setup the fluid shader */
+ fluid_shader.temperature = fluid_get_temperature;
+
+ /* Setup the solid shader */
+ solid_shader.calorific_capacity = solid_get_calorific_capacity;
+ solid_shader.thermal_conductivity = solid_get_thermal_conductivity;
+ solid_shader.volumic_mass = solid_get_volumic_mass;
+ solid_shader.delta_solid = solid_get_delta;
+ solid_shader.volumic_power = solid_get_volumic_power;
+
+ /* Create the fluid */
+ OK(sdis_fluid_create(dev, &fluid_shader, NULL, &fluid));
+
+ /* Create the solids */
+ OK(sdis_solid_create(dev, &solid_shader, data, &solid0));
+ OK(sdis_solid_create(dev, &solid_shader, data, &solid1));
+
+ /* Create the interface0 */
+ OK(sdis_interface_create(dev, solid0, fluid, &interf_shader, NULL, &interf0));
+ OK(sdis_interface_create(dev, solid1, fluid, &interf_shader, NULL, &interf1));
+ ctx.interf0 = interf0;
+ ctx.interf1 = interf1;
+
+ /* Create the geometry */
+ OK(s3dut_create_sphere(&allocator, 1, 512, 256, &sphere));
+ OK(s3dut_create_cylinder(&allocator, 1, 10, 512, 8, &cylinder));
+ OK(s3dut_mesh_get_data(sphere, &ctx.msh0));
+ OK(s3dut_mesh_get_data(cylinder, &ctx.msh1));
+
+ /* Create the scene */
+ ntris = ctx.msh0.nprimitives + ctx.msh1.nprimitives;
+ nverts = ctx.msh0.nvertices + ctx.msh1.nvertices;
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = ntris;
+ scn_args.nvertices = nverts;
+ scn_args.context = &ctx;
+ OK(sdis_scene_create(dev, &scn_args, &scn));
+
+ /* Test sdis_compute_power function */
+ args.nrealisations = N;
+ args.medium = solid0;
+ args.time_range[0] = INF;
+ args.time_range[1] = INF;
+ BA(sdis_compute_power(NULL, &args, &estimator));
+ BA(sdis_compute_power(scn, NULL, &estimator));
+ BA(sdis_compute_power(scn, &args, NULL));
+ args.nrealisations = 0;
+ BA(sdis_compute_power(scn, &args, &estimator));
+ args.nrealisations = N;
+ args.medium = NULL;
+ BA(sdis_compute_power(scn, &args, &estimator));
+ args.medium = solid0;
+ args.time_range[0] = args.time_range[1] = -1;
+ BA(sdis_compute_power(scn, &args, &estimator));
+ args.time_range[0] = 1;
+ BA(sdis_compute_power(scn, &args, &estimator));
+ args.time_range[1] = 0;
+ BA(sdis_compute_power(scn, &args, &estimator));
+ args.time_range[0] = args.time_range[1] = INF;
+ OK(sdis_compute_power(scn, &args, &estimator));
+
+ BA(sdis_estimator_get_power(NULL, &mpow));
+ BA(sdis_estimator_get_power(estimator, NULL));
+ OK(sdis_estimator_get_power(estimator, &mpow));
+ OK(sdis_estimator_get_realisation_time(estimator, &time));
+
+ /* Check results for solid 0 */
+ ref = 4.0/3.0 * PI * POWER0;
+ printf("Mean power of the solid0 = %g ~ %g +/- %g\n",
+ ref, mpow.E, mpow.SE);
+ check_intersection(ref, 1.e-2, mpow.E, 3*mpow.SE);
+ OK(sdis_estimator_ref_put(estimator));
+
+ /* Check results for solid 1 */
+ args.medium = solid1;
+ OK(sdis_compute_power(scn, &args, &estimator));
+ OK(sdis_estimator_get_power(estimator, &mpow));
+ ref = PI * 10 * POWER1;
+ printf("Mean power of the solid1 = %g ~ %g +/- %g\n",
+ ref, mpow.E, mpow.SE);
+ check_intersection(ref, 1.e-2, mpow.E, 3*mpow.SE);
+ OK(sdis_estimator_ref_put(estimator));
+
+ /* Check for a not null time range */
+ args.time_range[0] = 0;
+ args.time_range[1] = 10;
+ OK(sdis_compute_power(scn, &args, &estimator));
+ OK(sdis_estimator_get_power(estimator, &mpow));
+ ref = PI * 10 * POWER1 / 10;
+ printf("Mean power of the solid1 in [0, 10] s = %g ~ %g +/- %g\n",
+ ref, mpow.E, mpow.SE);
+ check_intersection(ref, 1.e-2, mpow.E, 3*mpow.SE);
+ OK(sdis_estimator_ref_put(estimator));
+
+ /* Reset the scene with only one solid medium */
+ OK(sdis_scene_ref_put(scn));
+ ctx.interf0 = interf0;
+ ctx.interf1 = interf0;
+ OK(sdis_scene_create(dev, &scn_args, &scn));
+
+ /* Check invalid medium */
+ args.time_range[0] = args.time_range[1] = 1;
+ args.medium = solid1;
+ BA(sdis_compute_power(scn, &args, &estimator));
+
+ /* Check non constant volumic power */
+ args.medium = solid0;
+ OK(sdis_compute_power(scn, &args, &estimator));
+ OK(sdis_estimator_get_power(estimator, &mpow));
+ ref = 4.0/3.0*PI*POWER0 + PI*10*POWER1;
+ printf("Mean power of the sphere+cylinder = %g ~ %g +/- %g\n",
+ ref, mpow.E, mpow.SE);
+ check_intersection(ref, 1.5e-1, mpow.E, 3*mpow.SE);
+ OK(sdis_estimator_ref_put(estimator));
+
+#if 0
+ {
+ double* vertices = NULL;
+ size_t* indices = NULL;
+ size_t i;
+ CHK(vertices = MEM_CALLOC(&allocator, nverts*3, sizeof(*vertices)));
+ CHK(indices = MEM_CALLOC(&allocator, ntris*3, sizeof(*indices)));
+ FOR_EACH(i, 0, ntris) get_indices(i, indices + i*3, &ctx);
+ FOR_EACH(i, 0, nverts) get_position(i, vertices + i*3, &ctx);
+ dump_mesh(stdout, vertices, nverts, indices, ntris);
+ MEM_RM(&allocator, vertices);
+ MEM_RM(&allocator, indices);
+ }
+#endif
+
+ /* Clean up memory */
+ OK(sdis_device_ref_put(dev));
+ OK(sdis_medium_ref_put(fluid));
+ OK(sdis_medium_ref_put(solid0));
+ OK(sdis_medium_ref_put(solid1));
+ OK(sdis_interface_ref_put(interf0));
+ OK(sdis_interface_ref_put(interf1));
+ OK(sdis_scene_ref_put(scn));
+ OK(s3dut_mesh_ref_put(sphere));
+ OK(s3dut_mesh_ref_put(cylinder));
+
+ check_memory_allocator(&allocator);
+ mem_shutdown_proxy_allocator(&allocator);
+ CHK(mem_allocated_size() == 0);
+ return 0;
+}
diff --git a/src/test_sdis_conducto_radiative.c b/src/test_sdis_conducto_radiative.c
@@ -282,6 +282,7 @@ main(int argc, char** argv)
struct sdis_medium* solid2 = NULL;
struct sdis_interface* interfaces[5] = {NULL};
struct sdis_interface* prim_interfaces[32/*#triangles*/];
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_scene* scn = NULL;
@@ -392,8 +393,14 @@ main(int argc, char** argv)
geom.positions = vertices;
geom.indices = indices;
geom.interfaces = prim_interfaces;
- OK(sdis_scene_create(dev, ntriangles, get_indices, get_interface, nvertices,
- get_position, 1, 0, Tref, &geom, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = ntriangles;
+ scn_args.nvertices = nvertices;
+ scn_args.tref = Tref;
+ scn_args.context = &geom;
+ OK(sdis_scene_create(dev, &scn_args, &scn));
hr = 4.0 * BOLTZMANN_CONSTANT * Tref*Tref*Tref * emissivity;
diff --git a/src/test_sdis_conducto_radiative_2d.c b/src/test_sdis_conducto_radiative_2d.c
@@ -283,6 +283,7 @@ main(int argc, char** argv)
struct sdis_medium* solid2 = NULL;
struct sdis_interface* interfaces[5] = {NULL};
struct sdis_interface* prim_interfaces[10/*#segment*/];
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
const size_t nsimuls = 4;
@@ -378,8 +379,14 @@ main(int argc, char** argv)
geom.positions = vertices;
geom.indices = indices;
geom.interfaces = prim_interfaces;
- OK(sdis_scene_2d_create(dev, nsegments, get_indices, get_interface, nvertices,
- get_position, 1, 0, Tref, &geom, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = nsegments;
+ scn_args.nvertices = nvertices;
+ scn_args.tref = Tref;
+ scn_args.context = &geom;
+ OK(sdis_scene_2d_create(dev, &scn_args, &scn));
hr = 4*BOLTZMANN_CONSTANT * Tref*Tref*Tref * emissivity;
tmp = lambda/(2*lambda + thickness*hr) * (T1 - T0);
diff --git a/src/test_sdis_convection.c b/src/test_sdis_convection.c
@@ -183,6 +183,7 @@ main(int argc, char** argv)
struct sdis_estimator* estimator = NULL;
struct sdis_estimator* estimator2 = NULL;
struct sdis_green_function* green = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interf_shader = DUMMY_INTERFACE_SHADER;
@@ -245,14 +246,22 @@ main(int argc, char** argv)
square_interfaces[3] = interf_T1; /* Right */
/* Create the box scene */
- OK(sdis_scene_create(dev, box_ntriangles, box_get_indices,
- box_get_interface, box_nvertices, box_get_position, 1, -1, 0,
- box_interfaces, &box_scn));
+ scn_args.get_indices = box_get_indices;
+ scn_args.get_interface = box_get_interface;
+ scn_args.get_position = box_get_position;
+ scn_args.nprimitives = box_ntriangles;
+ scn_args.nvertices = box_nvertices;
+ scn_args.context = box_interfaces;
+ OK(sdis_scene_create(dev, &scn_args, &box_scn));
/* Create the square scene */
- OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices,
- square_get_interface, square_nvertices, square_get_position, 1, -1, 0,
- square_interfaces, &square_scn));
+ scn_args.get_indices = square_get_indices;
+ scn_args.get_interface = square_get_interface;
+ scn_args.get_position = square_get_position;
+ scn_args.nprimitives = square_nsegments;
+ scn_args.nvertices = square_nvertices;
+ scn_args.context = square_interfaces;
+ OK(sdis_scene_2d_create(dev, &scn_args, &square_scn));
/* Release the interfaces */
OK(sdis_interface_ref_put(interf_T0));
diff --git a/src/test_sdis_convection_non_uniform.c b/src/test_sdis_convection_non_uniform.c
@@ -193,6 +193,7 @@ main(int argc, char** argv)
struct sdis_estimator* estimator = NULL;
struct sdis_estimator* estimator2 = NULL;
struct sdis_green_function* green = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interf_shader = DUMMY_INTERFACE_SHADER;
@@ -261,14 +262,22 @@ main(int argc, char** argv)
square_interfaces[3] = interf_T1; /* Right */
/* Create the box scene */
- OK(sdis_scene_create(dev, box_ntriangles, box_get_indices,
- box_get_interface, box_nvertices, box_get_position, 1, -1, 0,
- box_interfaces, &box_scn));
+ scn_args.get_indices = box_get_indices;
+ scn_args.get_interface = box_get_interface;
+ scn_args.get_position = box_get_position;
+ scn_args.nprimitives = box_ntriangles;
+ scn_args.nvertices = box_nvertices;
+ scn_args.context = box_interfaces;
+ OK(sdis_scene_create(dev, &scn_args, &box_scn));
/* Create the square scene */
- OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices,
- square_get_interface, square_nvertices, square_get_position, 1, -1, 0,
- square_interfaces, &square_scn));
+ scn_args.get_indices = square_get_indices;
+ scn_args.get_interface = square_get_interface;
+ scn_args.get_position = square_get_position;
+ scn_args.nprimitives = square_nsegments;
+ scn_args.nvertices = square_nvertices;
+ scn_args.context = square_interfaces;
+ OK(sdis_scene_2d_create(dev, &scn_args, &square_scn));
/* Release the interfaces */
OK(sdis_interface_ref_put(interf_T0));
diff --git a/src/test_sdis_flux.c b/src/test_sdis_flux.c
@@ -353,6 +353,7 @@ main(int argc, char** argv)
struct sdis_interface* interf_phi = NULL;
struct sdis_scene* box_scn = NULL;
struct sdis_scene* square_scn = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL;
@@ -425,14 +426,22 @@ main(int argc, char** argv)
square_interfaces[3] = interf_T0; /* Right */
/* Create the box scene */
- OK(sdis_scene_create(dev, box_ntriangles, box_get_indices,
- box_get_interface, box_nvertices, box_get_position, 1, -1, 0,
- box_interfaces, &box_scn));
+ scn_args.get_indices = box_get_indices;
+ scn_args.get_interface = box_get_interface;
+ scn_args.get_position = box_get_position;
+ scn_args.nprimitives = box_ntriangles;
+ scn_args.nvertices = box_nvertices;
+ scn_args.context = box_interfaces;
+ OK(sdis_scene_create(dev, &scn_args, &box_scn));
/* Create the square scene */
- OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices,
- square_get_interface, square_nvertices, square_get_position, 1, -1, 0,
- square_interfaces, &square_scn));
+ scn_args.get_indices = square_get_indices;
+ scn_args.get_interface = square_get_interface;
+ scn_args.get_position = square_get_position;
+ scn_args.nprimitives = square_nsegments;
+ scn_args.nvertices = square_nvertices;
+ scn_args.context = square_interfaces;
+ OK(sdis_scene_2d_create(dev, &scn_args, &square_scn));
/* Release the interfaces */
OK(sdis_interface_ref_put(interf_adiabatic));
diff --git a/src/test_sdis_scene.c b/src/test_sdis_scene.c
@@ -97,6 +97,7 @@ test_scene_3d(struct sdis_device* dev, struct sdis_interface* interf)
struct context ctx;
struct senc2d_scene* scn2d;
struct senc3d_scene* scn3d;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_scene* scn = NULL;
size_t ntris, npos;
size_t iprim;
@@ -111,39 +112,51 @@ test_scene_3d(struct sdis_device* dev, struct sdis_interface* interf)
ntris = box_ntriangles;
npos = box_nvertices;
- #define CREATE sdis_scene_create
- #define IDS get_indices_3d
- #define POS get_position_3d
- #define IFA get_interface
-
- BA(CREATE(NULL, 0, NULL, NULL, 0, NULL, 0, -1, -1, &ctx, NULL));
- BA(CREATE(dev, 0, IDS, IFA, npos, POS, 0, -1, -1, &ctx, &scn));
- BA(CREATE(dev, ntris, NULL, IFA, npos, POS, 0, -1, -1, &ctx, &scn));
- BA(CREATE(dev, ntris, IDS, NULL, npos, POS, 0, -1, -1, &ctx, &scn));
- BA(CREATE(dev, ntris, IDS, IFA, 0, POS, 0, -1, -1, &ctx, &scn));
- BA(CREATE(dev, ntris, IDS, IFA, npos, NULL, 0, -1, -1, &ctx, &scn));
- BA(CREATE(dev, ntris, IDS, IFA, npos, POS, 0, -1, -1, &ctx, &scn));
- BA(CREATE(dev, ntris, IDS, IFA, npos, POS, 1, -1, -1, &ctx, &scn));
+ scn_args.get_indices = get_indices_3d;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position_3d;
+ scn_args.nprimitives = ntris;
+ scn_args.nvertices = npos;
+ scn_args.context = &ctx;
+ BA(sdis_scene_create(NULL, &SDIS_SCENE_CREATE_ARGS_DEFAULT, NULL));
+ BA(sdis_scene_create(NULL, &SDIS_SCENE_CREATE_ARGS_DEFAULT, NULL));
+
+ scn_args.nprimitives = 0;
+ BA(sdis_scene_create(dev, &scn_args, &scn));
+ scn_args.nprimitives = ntris;
+ scn_args.get_indices = NULL;
+ BA(sdis_scene_create(dev, &scn_args, &scn));
+ scn_args.get_indices = get_indices_3d;
+ scn_args.get_interface = NULL;
+ BA(sdis_scene_create(dev, &scn_args, &scn));
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = NULL;
+ BA(sdis_scene_create(dev, &scn_args, &scn));
+ scn_args.get_position = get_position_3d;
+ scn_args.nvertices = 0;
+ BA(sdis_scene_create(dev, &scn_args, &scn));
+ scn_args.nvertices = npos;
+ scn_args.fp_to_meter = 0;
+ BA(sdis_scene_create(dev, &scn_args, &scn));
+ scn_args.fp_to_meter = 1;
/* Duplicated vertex */
ctx.positions = duplicated_vertices;
ctx.indices = dup_vrtx_indices;
- BA(CREATE(dev, 1, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn));
+ BA(sdis_scene_create(dev, &scn_args, &scn));
/* Duplicated triangle */
ctx.positions = box_vertices;
ctx.indices = duplicated_indices;
- BA(CREATE(dev, 2, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn));
+ BA(sdis_scene_create(dev, &scn_args, &scn));
/* Degenerated triangle */
ctx.indices = degenerated_indices;
- BA(CREATE(dev, 1, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn));
-
+ BA(sdis_scene_create(dev, &scn_args, &scn));
ctx.positions = box_vertices;
ctx.indices = box_indices;
- OK(CREATE(dev, ntris, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn));
-
- #undef CREATE
- #undef IDS
- #undef POS
- #undef IFA
+ BA(sdis_scene_create(dev, &SDIS_SCENE_CREATE_ARGS_DEFAULT, &scn));
+ BA(sdis_scene_create(NULL, &scn_args, &scn));
+ BA(sdis_scene_create(dev, NULL, &scn));
+ BA(sdis_scene_create(dev, &scn_args, NULL));
+ OK(sdis_scene_create(dev, &scn_args, &scn));
BA(sdis_scene_get_dimension(NULL, &dim));
BA(sdis_scene_get_dimension(scn, NULL));
@@ -244,6 +257,7 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf)
size_t degenerated_indices[] = { 0, 0 };
double duplicated_vertices[] = { 0, 0, 0, 0 };
struct sdis_scene* scn = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
double lower[2], upper[2];
double u0, u1, u2, pos[2], pos1[2];
double dst, fp, t;
@@ -262,39 +276,50 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf)
nsegs = square_nsegments;
npos = square_nvertices;
- #define CREATE sdis_scene_2d_create
- #define IDS get_indices_2d
- #define POS get_position_2d
- #define IFA get_interface
-
- BA(CREATE(NULL, 0, NULL, NULL, 0, NULL, 0, -1, -1, &ctx, NULL));
- BA(CREATE(dev, 0, IDS, IFA, npos, POS, 0, -1, -1, &ctx, &scn));
- BA(CREATE(dev, nsegs, NULL, IFA, npos, POS, 0, -1, -1, &ctx, &scn));
- BA(CREATE(dev, nsegs, IDS, NULL, npos, POS, 0, -1, -1, &ctx, &scn));
- BA(CREATE(dev, nsegs, IDS, IFA, 0, POS, 0, -1, -1, &ctx, &scn));
- BA(CREATE(dev, nsegs, IDS, IFA, npos, NULL, 0, -1, -1, &ctx, &scn));
- BA(CREATE(dev, nsegs, IDS, IFA, npos, POS, 0, -1, -1, &ctx, &scn));
- BA(CREATE(dev, nsegs, IDS, IFA, npos, POS, 1, -1, -1, &ctx, &scn));
+ scn_args.get_indices = get_indices_2d;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position_2d;
+ scn_args.nprimitives = nsegs;
+ scn_args.nvertices = npos;
+ scn_args.context = &ctx;
+
+ BA(sdis_scene_2d_create(NULL, &SDIS_SCENE_CREATE_ARGS_DEFAULT, NULL));
+ scn_args.nprimitives = 0;
+ BA(sdis_scene_2d_create(dev, &scn_args, &scn));
+ scn_args.nprimitives = nsegs;
+ scn_args.get_indices = NULL;
+ BA(sdis_scene_2d_create(dev, &scn_args, &scn));
+ scn_args.get_indices = get_indices_2d;
+ scn_args.get_interface = NULL;
+ BA(sdis_scene_2d_create(dev, &scn_args, &scn));
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = NULL;
+ BA(sdis_scene_2d_create(dev, &scn_args, &scn));
+ scn_args.get_position = get_position_2d;
+ scn_args.nvertices = 0;
+ BA(sdis_scene_2d_create(dev, &scn_args, &scn));
+ scn_args.nvertices = npos;
+ scn_args.fp_to_meter = 0;
+ BA(sdis_scene_2d_create(dev, &scn_args, &scn));
+ scn_args.fp_to_meter = 1;
/* Duplicated vertex */
ctx.positions = duplicated_vertices;
ctx.indices = dup_vrtx_indices;
- BA(CREATE(dev, 1, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn));
+ BA(sdis_scene_2d_create(dev, &scn_args, &scn));
/* Duplicated segment */
ctx.positions = square_vertices;
ctx.indices = duplicated_indices;
- BA(CREATE(dev, 2, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn));
+ BA(sdis_scene_2d_create(dev, &scn_args, &scn));
/* Degenerated segment */
ctx.indices = degenerated_indices;
- BA(CREATE(dev, 1, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn));
-
+ BA(sdis_scene_2d_create(dev, &scn_args, &scn));
ctx.positions = square_vertices;
ctx.indices = square_indices;
- OK(CREATE(dev, nsegs, IDS, IFA, npos, POS, 1, -1, 0, &ctx, &scn));
-
- #undef CREATE
- #undef IDS
- #undef POS
- #undef IFA
+ BA(sdis_scene_2d_create(dev, &SDIS_SCENE_CREATE_ARGS_DEFAULT, &scn));
+ BA(sdis_scene_2d_create(NULL, &scn_args, &scn));
+ BA(sdis_scene_2d_create(dev, NULL, &scn));
+ BA(sdis_scene_2d_create(dev, &scn_args, NULL));
+ OK(sdis_scene_2d_create(dev, &scn_args, &scn));
BA(sdis_scene_get_dimension(NULL, &dim));
BA(sdis_scene_get_dimension(scn, NULL));
@@ -330,7 +355,7 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf)
BA(sdis_scene_get_ambient_radiative_temperature(scn, NULL));
BA(sdis_scene_get_ambient_radiative_temperature(NULL, &t));
OK(sdis_scene_get_ambient_radiative_temperature(scn, &t));
- CHK(t == -1);
+ CHK(t == SDIS_SCENE_CREATE_ARGS_DEFAULT.trad);
t = 100;
BA(sdis_scene_set_ambient_radiative_temperature(NULL, t));
@@ -342,7 +367,7 @@ test_scene_2d(struct sdis_device* dev, struct sdis_interface* interf)
BA(sdis_scene_get_reference_temperature(scn, NULL));
BA(sdis_scene_get_reference_temperature(NULL, &t));
OK(sdis_scene_get_reference_temperature(scn, &t));
- CHK(t == 0);
+ CHK(t == SDIS_SCENE_CREATE_ARGS_DEFAULT.tref);
t = -1;
BA(sdis_scene_set_reference_temperature(NULL, t));
diff --git a/src/test_sdis_solid_random_walk_robustness.c b/src/test_sdis_solid_random_walk_robustness.c
@@ -270,6 +270,7 @@ main(int argc, char** argv)
struct sdis_medium* solid = NULL;
struct sdis_interface* interf = NULL;
struct sdis_scene* scn = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = SDIS_SOLID_SHADER_NULL;
struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL;
@@ -331,8 +332,13 @@ main(int argc, char** argv)
/* Create the scene */
ctx.interf = interf;
- OK(sdis_scene_create(dev, ctx.msh.nprimitives, get_indices, get_interface,
- ctx.msh.nvertices, get_position, 1, -1, 0, &ctx, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = ctx.msh.nprimitives;
+ scn_args.nvertices = ctx.msh.nvertices;
+ scn_args.context = &ctx;
+ OK(sdis_scene_create(dev, &scn_args, &scn));
/*dump_mesh(stdout, ctx.msh.positions,
ctx.msh.nvertices, ctx.msh.indices, ctx.msh.nprimitives);*/
diff --git a/src/test_sdis_solve_boundary.c b/src/test_sdis_solve_boundary.c
@@ -186,6 +186,7 @@ main(int argc, char** argv)
struct sdis_estimator* estimator = NULL;
struct sdis_estimator* estimator2 = NULL;
struct sdis_green_function* green = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL;
@@ -278,14 +279,22 @@ main(int argc, char** argv)
square_interfaces[3] = interf_H; /* Right */
/* Create the box scene */
- OK(sdis_scene_create(dev, box_ntriangles, box_get_indices,
- box_get_interface, box_nvertices, box_get_position, 1, -1, 0,
- box_interfaces, &box_scn));
+ scn_args.get_indices = box_get_indices;
+ scn_args.get_interface = box_get_interface;
+ scn_args.get_position = box_get_position;
+ scn_args.nprimitives = box_ntriangles;
+ scn_args.nvertices = box_nvertices;
+ scn_args.context = box_interfaces;
+ OK(sdis_scene_create(dev, &scn_args, &box_scn));
/* Create the square scene */
- OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices,
- square_get_interface, square_nvertices, square_get_position, 1, -1, 0,
- square_interfaces, &square_scn));
+ scn_args.get_indices = square_get_indices;
+ scn_args.get_interface = square_get_interface;
+ scn_args.get_position = square_get_position;
+ scn_args.nprimitives = square_nsegments;
+ scn_args.nvertices = square_nvertices;
+ scn_args.context = square_interfaces;
+ OK(sdis_scene_2d_create(dev, &scn_args, &square_scn));
/* Release the interfaces */
OK(sdis_interface_ref_put(interf_adiabatic));
diff --git a/src/test_sdis_solve_boundary_flux.c b/src/test_sdis_solve_boundary_flux.c
@@ -229,6 +229,7 @@ main(int argc, char** argv)
struct sdis_scene* box_scn = NULL;
struct sdis_scene* square_scn = NULL;
struct sdis_estimator* estimator = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL;
@@ -325,14 +326,26 @@ main(int argc, char** argv)
square_interfaces[3] = interf_H; /* Right */
/* Create the box scene */
- OK(sdis_scene_create(dev, box_ntriangles, box_get_indices,
- box_get_interface, box_nvertices, box_get_position, 1, Trad, Tref,
- box_interfaces, &box_scn));
+ scn_args.get_indices = box_get_indices;
+ scn_args.get_interface = box_get_interface;
+ scn_args.get_position = box_get_position;
+ scn_args.nprimitives = box_ntriangles;
+ scn_args.nvertices = box_nvertices;
+ scn_args.trad = Trad;
+ scn_args.tref = Tref;
+ scn_args.context = box_interfaces;
+ OK(sdis_scene_create(dev, &scn_args, &box_scn));
/* Create the square scene */
- OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices,
- square_get_interface, square_nvertices, square_get_position, 1, Trad, Tref,
- square_interfaces, &square_scn));
+ scn_args.get_indices = square_get_indices;
+ scn_args.get_interface = square_get_interface;
+ scn_args.get_position = square_get_position;
+ scn_args.nprimitives = square_nsegments;
+ scn_args.nvertices = square_nvertices;
+ scn_args.trad = Trad;
+ scn_args.tref = Tref;
+ scn_args.context = square_interfaces;
+ OK(sdis_scene_2d_create(dev, &scn_args, &square_scn));
/* Release the interfaces */
OK(sdis_interface_ref_put(interf_adiabatic));
diff --git a/src/test_sdis_solve_camera.c b/src/test_sdis_solve_camera.c
@@ -540,6 +540,7 @@ main(int argc, char** argv)
struct sdis_interface* interf0 = NULL;
struct sdis_interface* interf1 = NULL;
struct sdis_scene* scn = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_solve_camera_args solve_args = SDIS_SOLVE_CAMERA_ARGS_DEFAULT;
struct ssp_rng* rng_state = NULL;
struct fluid fluid_param = FLUID_NULL;
@@ -608,9 +609,15 @@ main(int argc, char** argv)
/* Setup the scene */
ntris = sa_size(geom.indices) / 3; /* #primitives */
npos = sa_size(geom.positions) / 3; /* #positions */
- OK(sdis_scene_create(dev, ntris, geometry_get_indices,
- geometry_get_interface, npos, geometry_get_position,
- 1, 300, 300, &geom, &scn));
+ scn_args.get_indices = geometry_get_indices;
+ scn_args.get_interface = geometry_get_interface;
+ scn_args.get_position = geometry_get_position;
+ scn_args.nprimitives = ntris;
+ scn_args.nvertices = npos;
+ scn_args.trad = 300;
+ scn_args.tref = 300;
+ scn_args.context = &geom;
+ OK(sdis_scene_create(dev, &scn_args, &scn));
#if 0
dump_mesh(stdout, geom.positions, sa_size(geom.positions)/3, geom.indices,
diff --git a/src/test_sdis_solve_medium.c b/src/test_sdis_solve_medium.c
@@ -220,6 +220,7 @@ main(int argc, char** argv)
struct fluid* fluid_param = NULL;
struct solid* solid_param = NULL;
struct interf* interface_param = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interface_shader = SDIS_INTERFACE_SHADER_NULL;
@@ -337,8 +338,13 @@ main(int argc, char** argv)
}
#endif
- OK(sdis_scene_create(dev, ntris, get_indices, get_interface, nverts,
- get_position, 1, -1, 0, &ctx, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = ntris;
+ scn_args.nvertices = nverts;
+ scn_args.context = &ctx;
+ OK(sdis_scene_create(dev, &scn_args, &scn));
BA(sdis_scene_get_medium_spread(NULL, solid0, &v0));
BA(sdis_scene_get_medium_spread(scn, NULL, &v0));
@@ -415,8 +421,7 @@ main(int argc, char** argv)
OK(sdis_scene_ref_put(scn));
ctx.interf0 = solid0_fluid0;
ctx.interf1 = solid0_fluid1;
- OK(sdis_scene_create(dev, ntris, get_indices, get_interface, nverts,
- get_position, 1, -1, 0, &ctx, &scn));
+ OK(sdis_scene_create(dev, &scn_args, &scn));
OK(sdis_scene_get_medium_spread(scn, solid0, &v));
CHK(eq_eps(v, v0+v1, 1.e-6));
diff --git a/src/test_sdis_solve_medium_2d.c b/src/test_sdis_solve_medium_2d.c
@@ -205,6 +205,7 @@ main(int argc, char** argv)
struct fluid* fluid_param = NULL;
struct solid* solid_param = NULL;
struct interf* interface_param = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interface_shader = SDIS_INTERFACE_SHADER_NULL;
@@ -325,8 +326,13 @@ main(int argc, char** argv)
ctx.nsegments_interf0 = square_nsegments;
ctx.interf0 = solid0_fluid0;
ctx.interf1 = solid1_fluid1;
- OK(sdis_scene_2d_create(dev, sa_size(indices)/2, get_indices, get_interface,
- sa_size(positions)/2, get_position, 1, -1, 0, &ctx, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = sa_size(indices)/2;
+ scn_args.nvertices = sa_size(positions)/2;
+ scn_args.context = &ctx;
+ OK(sdis_scene_2d_create(dev, &scn_args, &scn));
OK(sdis_scene_get_medium_spread(scn, solid0, &a0));
CHK(eq_eps(a0, 1.0, 1.e-6));
@@ -370,8 +376,7 @@ main(int argc, char** argv)
OK(sdis_scene_ref_put(scn));
ctx.interf0 = solid0_fluid0;
ctx.interf1 = solid0_fluid1;
- OK(sdis_scene_2d_create(dev, sa_size(indices)/2, get_indices, get_interface,
- sa_size(positions)/2, get_position, 1, -1, 0, &ctx, &scn));
+ OK(sdis_scene_2d_create(dev, &scn_args, &scn));
OK(sdis_scene_get_medium_spread(scn, solid0, &a));
CHK(eq_eps(a, a0+a1, 1.e-6));
diff --git a/src/test_sdis_solve_probe.c b/src/test_sdis_solve_probe.c
@@ -262,6 +262,7 @@ main(int argc, char** argv)
struct sdis_estimator* estimator3 = NULL;
struct sdis_green_function* green = NULL;
const struct sdis_heat_path* path = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interface_shader = SDIS_INTERFACE_SHADER_NULL;
@@ -335,8 +336,13 @@ main(int argc, char** argv)
ctx.positions = box_vertices;
ctx.indices = box_indices;
ctx.interf = interf;
- OK(sdis_scene_create(dev, box_ntriangles, get_indices, get_interface,
- box_nvertices, get_position, 1, -1, 0, &ctx, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = box_ntriangles;
+ scn_args.nvertices = box_nvertices;
+ scn_args.context = &ctx;
+ OK(sdis_scene_create(dev, &scn_args, &scn));
OK(sdis_interface_ref_put(interf));
diff --git a/src/test_sdis_solve_probe2.c b/src/test_sdis_solve_probe2.c
@@ -159,6 +159,7 @@ main(int argc, char** argv)
struct sdis_interface* T350 = NULL;
struct sdis_scene* scn = NULL;
struct sdis_green_function* green = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interface_shader = DUMMY_INTERFACE_SHADER;
@@ -230,8 +231,13 @@ main(int argc, char** argv)
ctx.positions = box_vertices;
ctx.indices = box_indices;
ctx.interfaces = interfaces;
- OK(sdis_scene_create(dev, box_ntriangles, get_indices, get_interface,
- box_nvertices, get_position, 1, -1, 0, &ctx, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = box_ntriangles;
+ scn_args.nvertices = box_nvertices;
+ scn_args.context = &ctx;
+ OK(sdis_scene_create(dev, &scn_args, &scn));
/* Release the interfaces */
OK(sdis_interface_ref_put(Tnone));
diff --git a/src/test_sdis_solve_probe2_2d.c b/src/test_sdis_solve_probe2_2d.c
@@ -155,6 +155,7 @@ main(int argc, char** argv)
struct sdis_interface* T350 = NULL;
struct sdis_scene* scn = NULL;
struct sdis_green_function* green = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interface_shader = DUMMY_INTERFACE_SHADER;
@@ -228,8 +229,13 @@ main(int argc, char** argv)
ctx.positions = square_vertices;
ctx.indices = square_indices;
ctx.interfaces = interfaces;
- OK(sdis_scene_2d_create(dev, square_nsegments, get_indices, get_interface,
- square_nvertices, get_position, 1, -1, 0, &ctx, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = square_nsegments;
+ scn_args.nvertices = square_nvertices;
+ scn_args.context = &ctx;
+ OK(sdis_scene_2d_create(dev, &scn_args, &scn));
/* Release the interfaces */
OK(sdis_interface_ref_put(Tnone));
diff --git a/src/test_sdis_solve_probe3.c b/src/test_sdis_solve_probe3.c
@@ -181,6 +181,7 @@ main(int argc, char** argv)
struct sdis_interface* solid_solid = NULL;
struct sdis_scene* scn = NULL;
struct sdis_green_function* green = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interface_shader = DUMMY_INTERFACE_SHADER;
@@ -282,8 +283,13 @@ main(int argc, char** argv)
ctx.solid_solid = solid_solid;
nverts = sa_size(ctx.positions) / 3;
ntris = sa_size(ctx.indices) / 3;
- OK(sdis_scene_create(dev, ntris, get_indices, get_interface, nverts,
- get_position, 1, -1, 0, &ctx, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = ntris;
+ scn_args.nvertices = nverts;
+ scn_args.context = &ctx;
+ OK(sdis_scene_create(dev, &scn_args, &scn));
/* Release the scene data */
OK(sdis_interface_ref_put(Tnone));
diff --git a/src/test_sdis_solve_probe3_2d.c b/src/test_sdis_solve_probe3_2d.c
@@ -178,6 +178,7 @@ main(int argc, char** argv)
struct sdis_interface* solid_solid = NULL;
struct sdis_scene* scn = NULL;
struct sdis_green_function* green = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interface_shader = DUMMY_INTERFACE_SHADER;
@@ -276,8 +277,13 @@ main(int argc, char** argv)
ctx.solid_solid = solid_solid;
nverts = sa_size(ctx.positions) / 2;
nsegs = sa_size(ctx.indices) / 2;
- OK(sdis_scene_2d_create(dev, nsegs, get_indices, get_interface, nverts,
- get_position, 1, -1, 0, &ctx, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = nsegs;
+ scn_args.nvertices = nverts;
+ scn_args.context = &ctx;
+ OK(sdis_scene_2d_create(dev, &scn_args, &scn));
/* Release the scene data */
OK(sdis_interface_ref_put(Tnone));
diff --git a/src/test_sdis_solve_probe_2d.c b/src/test_sdis_solve_probe_2d.c
@@ -145,6 +145,7 @@ main(int argc, char** argv)
struct sdis_estimator* estimator = NULL;
struct sdis_estimator* estimator2 = NULL;
struct sdis_green_function* green = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interface_shader = DUMMY_INTERFACE_SHADER;
@@ -192,8 +193,13 @@ main(int argc, char** argv)
ctx.positions = square_vertices;
ctx.indices = square_indices;
ctx.interf = interf;
- OK(sdis_scene_2d_create(dev, square_nsegments, get_indices, get_interface,
- square_nvertices, get_position, 1, -1, 0, &ctx, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = square_nsegments;
+ scn_args.nvertices = square_nvertices;
+ scn_args.context = &ctx;
+ OK(sdis_scene_2d_create(dev, &scn_args, &scn));
OK(sdis_interface_ref_put(interf));
diff --git a/src/test_sdis_transcient.c b/src/test_sdis_transcient.c
@@ -144,7 +144,7 @@ matriochka_indices(const size_t itri, size_t ids[3], void* context)
}
static void
-matriocka_interface
+matriochka_interface
(const size_t itri, struct sdis_interface** bound, void* context)
{
struct matriochka_context* ctx = context;
@@ -471,6 +471,7 @@ main(int argc, char** argv)
struct sdis_medium* fluid = NULL;
struct sdis_medium* solid = NULL;
struct sdis_data* data = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = SDIS_FLUID_SHADER_NULL;
struct sdis_solid_shader solid_shader = SDIS_SOLID_SHADER_NULL;
struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL;
@@ -557,8 +558,13 @@ main(int argc, char** argv)
ctx.scale = boxsz;
/* Create the box scene */
- OK(sdis_scene_create(dev, box_ntriangles, get_indices, get_interface,
- box_nvertices, get_position, 1, -1, 0, &ctx, &box_scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = box_ntriangles;
+ scn_args.nvertices = box_nvertices;
+ scn_args.context = &ctx;
+ OK(sdis_scene_create(dev, &scn_args, &box_scn));
/* Setup the box2 scene context */
ctx.indices = indices;
@@ -576,9 +582,10 @@ main(int argc, char** argv)
ctx.interfs[20] = ctx.interfs[21] = interfs[5]; /* Zmax */
ctx.scale = boxsz;
- /* Create the box scene */
- OK(sdis_scene_create(dev, ntriangles, get_indices, get_interface,
- nvertices, get_position, 1, -1, 0, &ctx, &box2_scn));
+ /* Create the box2 scene */
+ scn_args.nprimitives = ntriangles;
+ scn_args.nvertices = nvertices;
+ OK(sdis_scene_create(dev, &scn_args, &box2_scn));
/* Setup the matriochka context */
matriochka_ctx.interfs[0] = matriochka_ctx.interfs[1] = interfs[4]; /* Zmin */
@@ -589,12 +596,16 @@ main(int argc, char** argv)
matriochka_ctx.interfs[10] = matriochka_ctx.interfs[11] = interfs[2]; /* Ymin */
matriochka_ctx.interfs[12] = interfs[6]; /* The remaining internal triangles */
matriochka_ctx.scale = boxsz;
- matriochka_ctx.nboxes = nmatriochkas;
+ matriochka_ctx.nboxes = nmatriochkas;
/* Create the matriochka scene */
- OK(sdis_scene_create(dev, box_ntriangles*nmatriochkas, matriochka_indices,
- matriocka_interface, box_nvertices*nmatriochkas, matriochka_position,
- 1, -1, 0, &matriochka_ctx, &box_matriochka_scn));
+ scn_args.get_indices = matriochka_indices;
+ scn_args.get_interface = matriochka_interface;
+ scn_args.get_position = matriochka_position;
+ scn_args.nprimitives = box_ntriangles*nmatriochkas;
+ scn_args.nvertices = box_nvertices*nmatriochkas;
+ scn_args.context = &matriochka_ctx;
+ OK(sdis_scene_create(dev, &scn_args, &box_matriochka_scn));
/* Setup and run the simulation */
probe[0] = 0.1;
diff --git a/src/test_sdis_volumic_power.c b/src/test_sdis_volumic_power.c
@@ -189,7 +189,7 @@ solve
solve_args.position[0] = ssp_rng_uniform_double(rng, 0.1, 0.9);
solve_args.position[1] = ssp_rng_uniform_double(rng, 0.1, 0.9);
- solve_args.position[2] =
+ solve_args.position[2] =
dim == SDIS_SCENE_2D ? 0 : ssp_rng_uniform_double(rng, 0.1, 0.9);
solve_args.nrealisations = N;
@@ -388,6 +388,7 @@ main(int argc, char** argv)
struct sdis_interface* interf_T0 = NULL;
struct sdis_scene* box_scn = NULL;
struct sdis_scene* square_scn = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = DUMMY_FLUID_SHADER;
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL;
@@ -464,14 +465,22 @@ main(int argc, char** argv)
square_interfaces[3] = interf_T0; /* Right */
/* Create the box scene */
- OK(sdis_scene_create(dev, box_ntriangles, box_get_indices,
- box_get_interface, box_nvertices, box_get_position, 1, -1, 0,
- box_interfaces, &box_scn));
+ scn_args.get_indices = box_get_indices;
+ scn_args.get_interface = box_get_interface;
+ scn_args.get_position = box_get_position;
+ scn_args.nprimitives = box_ntriangles;
+ scn_args.nvertices = box_nvertices;
+ scn_args.context = box_interfaces;
+ OK(sdis_scene_create(dev, &scn_args, &box_scn));
/* Create the square scene */
- OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices,
- square_get_interface, square_nvertices, square_get_position, 1, -1, 0,
- square_interfaces, &square_scn));
+ scn_args.get_indices = square_get_indices;
+ scn_args.get_interface = square_get_interface;
+ scn_args.get_position = square_get_position;
+ scn_args.nprimitives = square_nsegments;
+ scn_args.nvertices = square_nvertices;
+ scn_args.context = square_interfaces;
+ OK(sdis_scene_2d_create(dev, &scn_args, &square_scn));
/* Release the interfaces */
OK(sdis_interface_ref_put(interf_adiabatic));
diff --git a/src/test_sdis_volumic_power2.c b/src/test_sdis_volumic_power2.c
@@ -274,6 +274,7 @@ main(int argc, char** argv)
struct sdis_medium* solid1 = NULL;
struct sdis_medium* solid2 = NULL;
struct sdis_scene* scn = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = SDIS_FLUID_SHADER_NULL;
struct sdis_solid_shader solid_shader = SDIS_SOLID_SHADER_NULL;
struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL;
@@ -425,8 +426,13 @@ main(int argc, char** argv)
interfaces[17] = interf_solid2_adiabatic;
/* Create the scene */
- OK(sdis_scene_create(dev, ntriangles, get_indices, get_interface,
- nvertices, get_position, 1, -1, 0, interfaces, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = ntriangles;
+ scn_args.nvertices = nvertices;
+ scn_args.context = interfaces;
+ OK(sdis_scene_create(dev, &scn_args, &scn));
#if 0
dump_mesh(stdout, vertices, nvertices, indices, ntriangles);
@@ -441,8 +447,7 @@ main(int argc, char** argv)
data = sdis_medium_get_data(solid1);
solid_param = sdis_data_get(data);
solid_param->lambda = 0.1;
- OK(sdis_scene_create(dev, ntriangles, get_indices, get_interface,
- nvertices, get_position, 1, -1, 0, interfaces, &scn));
+ OK(sdis_scene_create(dev, &scn_args, &scn));
printf("\n>>> Check 2\n");
check(scn, refs2, sizeof(refs2)/sizeof(struct reference));
diff --git a/src/test_sdis_volumic_power2_2d.c b/src/test_sdis_volumic_power2_2d.c
@@ -296,6 +296,7 @@ main(int argc, char** argv)
struct sdis_medium* solid1 = NULL;
struct sdis_medium* solid2 = NULL;
struct sdis_scene* scn = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = SDIS_FLUID_SHADER_NULL;
struct sdis_solid_shader solid_shader = SDIS_SOLID_SHADER_NULL;
struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL;
@@ -446,8 +447,13 @@ main(int argc, char** argv)
interfaces[7] = interf_solid1_solid2;
/* Create the scene */
- OK(sdis_scene_2d_create(dev, nsegments, get_indices, get_interface,
- nvertices, get_position, 1, -1, 0, interfaces, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = nsegments;
+ scn_args.nvertices = nvertices;
+ scn_args.context = interfaces;
+ OK(sdis_scene_2d_create(dev, &scn_args, &scn));
printf(">>> Check 1\n");
check(scn, refs1, sizeof(refs1)/sizeof(struct reference));
@@ -457,8 +463,7 @@ main(int argc, char** argv)
data = sdis_medium_get_data(solid1);
solid_param = sdis_data_get(data);
solid_param->lambda = 0.1;
- OK(sdis_scene_2d_create(dev, nsegments, get_indices, get_interface,
- nvertices, get_position, 1, -1, 0, interfaces, &scn));
+ OK(sdis_scene_2d_create(dev, &scn_args, &scn));
printf("\n>>> Check 2\n");
check(scn, refs2, sizeof(refs2)/sizeof(struct reference));
@@ -472,8 +477,7 @@ main(int argc, char** argv)
solid_param = sdis_data_get(data);
solid_param->lambda = 10;
solid_param->P = SDIS_VOLUMIC_POWER_NONE;
- OK(sdis_scene_2d_create(dev, nsegments, get_indices, get_interface,
- nvertices, get_position, 1, -1, 0, interfaces, &scn));
+ OK(sdis_scene_2d_create(dev, &scn_args, &scn));
printf("\n>>> Check 3\n");
check(scn, refs3, sizeof(refs3)/sizeof(struct reference));
diff --git a/src/test_sdis_volumic_power3_2d.c b/src/test_sdis_volumic_power3_2d.c
@@ -261,6 +261,7 @@ main(int argc, char** argv)
struct sdis_interface* interf_solid1_fluid = NULL;
struct sdis_interface* interf_solid2_fluid = NULL;
struct sdis_interface* interfaces[10/*#segment*/];
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
struct sdis_mc T = SDIS_MC_NULL;
double Tref;
@@ -414,8 +415,13 @@ main(int argc, char** argv)
#endif
/* Create the scene */
- OK(sdis_scene_2d_create(dev, nsegments, get_indices, get_interface,
- nvertices, get_position, 1, -1, 0, interfaces, &scn));
+ scn_args.get_indices = get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position;
+ scn_args.nprimitives = nsegments;
+ scn_args.nvertices = nvertices;
+ scn_args.context = interfaces;
+ OK(sdis_scene_2d_create(dev, &scn_args, &scn));
/* Release the interfaces */
OK(sdis_interface_ref_put(interf_solid_adiabatic));
diff --git a/src/test_sdis_volumic_power4.c b/src/test_sdis_volumic_power4.c
@@ -217,6 +217,7 @@ main(int argc, char** argv)
struct sdis_scene* scn_2d = NULL;
struct sdis_scene* scn_3d = NULL;
struct sdis_estimator* estimator = NULL;
+ struct sdis_scene_create_args scn_args = SDIS_SCENE_CREATE_ARGS_DEFAULT;
struct sdis_fluid_shader fluid_shader = SDIS_FLUID_SHADER_NULL;
struct sdis_solid_shader solid_shader = SDIS_SOLID_SHADER_NULL;
struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL;
@@ -326,8 +327,13 @@ main(int argc, char** argv)
interfaces[3] = interf_adiabatic; /* Right */
/* Create the 2D scene */
- OK(sdis_scene_2d_create(dev, square_nsegments, square_get_indices, get_interface,
- square_nvertices, get_position_2d, 1, -1, 0, interfaces, &scn_2d));
+ scn_args.get_indices = square_get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position_2d;
+ scn_args.nprimitives = square_nsegments;
+ scn_args.nvertices = square_nvertices;
+ scn_args.context = interfaces;
+ OK(sdis_scene_2d_create(dev, &scn_args, &scn_2d));
/* Map the interfaces to their box triangles */
interfaces[0] = interfaces[1] = interf_adiabatic; /* Front */
@@ -338,8 +344,13 @@ main(int argc, char** argv)
interfaces[10]= interfaces[11]= interf_solid_fluid2; /* Bottom */
/* Create the 3D scene */
- OK(sdis_scene_create(dev, box_ntriangles, box_get_indices, get_interface,
- box_nvertices, get_position_3d, 1, -1, 0, interfaces, &scn_3d));
+ scn_args.get_indices = box_get_indices;
+ scn_args.get_interface = get_interface;
+ scn_args.get_position = get_position_3d;
+ scn_args.nprimitives = box_ntriangles;
+ scn_args.nvertices = box_nvertices;
+ scn_args.context = interfaces;
+ OK(sdis_scene_create(dev, &scn_args, &scn_3d));
/* Release the interfaces */
OK(sdis_interface_ref_put(interf_adiabatic));