commit 6f72b7547c3af133da8b6635c88025bf0ecce138
parent 19564c2076e440929fdcd517dea481db7de3fbad
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 24 Jun 2020 16:31:39 +0200
Update the API of sdis_solve_probe[_green_function]
The parameters of the simulation are now grouped into a unique data
structure rather than separately submitted as function arguments.
Thank to this structure and its default value, updating input parameters
should now affect marginally the calling code.
Diffstat:
23 files changed, 324 insertions(+), 226 deletions(-)
diff --git a/src/sdis.h b/src/sdis.h
@@ -274,6 +274,29 @@ struct sdis_point {
#define SDIS_POINT_NULL__ { {{NULL, SDIS_RWALK_VERTEX_NULL__}}, SDIS_POINT_NONE}
static const struct sdis_point SDIS_POINT_NULL = SDIS_POINT_NULL__;
+struct sdis_solve_probe_args {
+ size_t nrealisations; /* #realisations */
+ double position[3]; /* Probe position */
+ double time_range[2]; /* Observation time */
+ double fp_to_meter; /* Scale from floating point units to meters */
+ double ambient_radiative_temperature; /* In Kelvin */
+ double reference_temperature; /* In Kelvin */
+ int register_paths; /* Combination of enum sdis_heat_path_flag */
+ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */
+};
+#define SDIS_SOLVE_PROBE_ARGS_DEFAULT__ { \
+ 10000, /* #realisations */ \
+ {0,0,0}, /* Position */ \
+ {DBL_MAX,DBL_MAX}, /* Time range */ \
+ 1.0, /* FP to meter */ \
+ -1, /* Ambient radiative temperature */ \
+ -1, /* Reference temperature */ \
+ SDIS_HEAT_PATH_NONE, /* Register paths mask */ \
+ NULL /* RNG state */ \
+}
+static const struct sdis_solve_probe_args SDIS_SOLVE_PROBE_ARGS_DEFAULT =
+ SDIS_SOLVE_PROBE_ARGS_DEFAULT__;
+
/* Functor used to process the paths registered against the green function */
typedef res_T
(*sdis_process_green_path_T)
@@ -395,7 +418,7 @@ sdis_camera_look_at
const double up[3]);
/*******************************************************************************
- * An estimator buffer is 2D array of estimators
+ * An estimator buffer is 2D array of estimators
******************************************************************************/
SDIS_API res_T
sdis_estimator_buffer_ref_get
@@ -845,13 +868,7 @@ sdis_heat_path_for_each_vertex
SDIS_API res_T
sdis_solve_probe
(struct sdis_scene* scn,
- const size_t nrealisations, /* #realisations */
- const double position[3], /* Probe position */
- const double time_range[2], /* Observation time */
- const double fp_to_meter, /* Scale from floating point units to meters */
- const double ambient_radiative_temperature, /* In Kelvin */
- const double reference_temperature, /* In Kelvin */
- const int register_paths, /* Combination of enum sdis_heat_path_flag */
+ const struct sdis_solve_probe_args* args,
struct sdis_estimator** estimator);
SDIS_API res_T
@@ -956,11 +973,7 @@ sdis_solve_medium
SDIS_API res_T
sdis_solve_probe_green_function
(struct sdis_scene* scn,
- const size_t nrealisations, /* #realisations */
- const double position[3], /* Probe position */
- const double fp_to_meter, /* Scale from floating point units to meters */
- const double ambient_radiative_temperature, /* In Kelvin */
- const double reference_temperature, /* In Kelvin */
+ const struct sdis_solve_probe_args* args,
struct sdis_green_function** green);
SDIS_API res_T
diff --git a/src/sdis_solve.c b/src/sdis_solve.c
@@ -220,42 +220,28 @@ error:
res_T
sdis_solve_probe
(struct sdis_scene* scn,
- const size_t nrealisations,
- const double position[3],
- const double time_range[2],
- const double fp_to_meter,/* Scale factor from floating point unit to meter */
- const double Tarad, /* Ambient radiative temperature */
- const double Tref, /* Reference temperature */
- const int register_paths, /* Combination of enum sdis_heat_path_flag */
+ const struct sdis_solve_probe_args* args,
struct sdis_estimator** out_estimator)
{
if(!scn) return RES_BAD_ARG;
if(scene_is_2d(scn)) {
- return solve_probe_2d(scn, nrealisations, position, time_range,
- fp_to_meter, Tarad, Tref, register_paths, NULL, out_estimator);
+ return solve_probe_2d(scn, args, NULL, out_estimator);
} else {
- return solve_probe_3d(scn, nrealisations, position, time_range,
- fp_to_meter, Tarad, Tref, register_paths, NULL, out_estimator);
+ return solve_probe_3d(scn, args, NULL, out_estimator);
}
}
res_T
sdis_solve_probe_green_function
(struct sdis_scene* scn,
- const size_t nrealisations,
- const double position[3],
- const double fp_to_meter,/* Scale factor from floating point unit to meter */
- const double Tarad, /* Ambient radiative temperature */
- const double Tref, /* Reference temperature */
+ const struct sdis_solve_probe_args* args,
struct sdis_green_function** out_green)
{
if(!scn) return RES_BAD_ARG;
if(scene_is_2d(scn)) {
- return solve_probe_2d(scn, nrealisations, position, NULL,
- fp_to_meter, Tarad, Tref, SDIS_HEAT_PATH_NONE, out_green, NULL);
+ return solve_probe_2d(scn, args, out_green, NULL);
} else {
- return solve_probe_3d(scn, nrealisations, position, NULL,
- fp_to_meter, Tarad, Tref, SDIS_HEAT_PATH_NONE, out_green, NULL);
+ return solve_probe_3d(scn, args, out_green, NULL);
}
}
diff --git a/src/sdis_solve_medium_Xd.h b/src/sdis_solve_medium_Xd.h
@@ -226,7 +226,7 @@ XD(solve_medium)
ATOMIC res = RES_OK;
if(!scn || !mdm || !nrealisations || nrealisations > INT64_MAX
- || fp_to_meter <= 0 || Tref < 0) {
+ || fp_to_meter <= 0) {
res = RES_BAD_ARG;
goto error;
}
diff --git a/src/sdis_solve_probe_Xd.h b/src/sdis_solve_probe_Xd.h
@@ -33,13 +33,7 @@
static res_T
XD(solve_probe)
(struct sdis_scene* scn,
- const size_t nrealisations,
- const double position[3],
- const double time_range[2],
- const double fp_to_meter,/* Scale factor from floating point unit to meter */
- const double Tarad, /* Ambient radiative temperature */
- const double Tref, /* Reference temperature */
- const int register_paths, /* Combination of enum sdis_heat_path_flag */
+ const struct sdis_solve_probe_args* args,
struct sdis_green_function** out_green, /* May be NULL <=> No green func */
struct sdis_estimator** out_estimator) /* May be NULL <=> No estimator */
{
@@ -51,14 +45,16 @@ XD(solve_probe)
struct ssp_rng** rngs = NULL;
struct accum* acc_temps = NULL;
struct accum* acc_times = NULL;
+ size_t nrealisations = 0;
int64_t irealisation = 0;
size_t i;
int progress = 0;
+ int register_paths = SDIS_HEAT_PATH_NONE;
ATOMIC nsolved_realisations = 0;
ATOMIC res = RES_OK;
- if(!scn || !nrealisations || nrealisations > INT64_MAX || !position
- || fp_to_meter <= 0 || Tref < 0) {
+ if(!scn || !args || !args->nrealisations || args->nrealisations > INT64_MAX
+ || args->fp_to_meter <= 0) {
res = RES_BAD_ARG;
goto error;
}
@@ -67,13 +63,16 @@ XD(solve_probe)
goto error;
}
if(out_estimator) {
- if(!time_range || time_range[0] < 0 || time_range[1] < time_range[0]
- || (time_range[1] > DBL_MAX && time_range[0] != time_range[1])) {
+ if(args->time_range[0] < 0
+ || args->time_range[1] < args->time_range[0]
+ || ( args->time_range[1] > DBL_MAX
+ && args->time_range[0] != args->time_range[1])) {
res = RES_BAD_ARG;
goto error;
}
}
+
#if SDIS_XD_DIMENSION == 2
if(scene_is_2d(scn) == 0) { res = RES_BAD_ARG; goto error; }
#else
@@ -81,9 +80,15 @@ XD(solve_probe)
#endif
/* Create the proxy RNG */
- res = ssp_rng_proxy_create(scn->dev->allocator, &ssp_rng_mt19937_64,
- scn->dev->nthreads, &rng_proxy);
- if(res != RES_OK) goto error;
+ if(args->rng_state) {
+ res = ssp_rng_proxy_create_from_rng(scn->dev->allocator, args->rng_state,
+ scn->dev->nthreads, &rng_proxy);
+ if(res != RES_OK) goto error;
+ } else {
+ res = ssp_rng_proxy_create(scn->dev->allocator, &ssp_rng_mt19937_64,
+ scn->dev->nthreads, &rng_proxy);
+ if(res != RES_OK) goto error;
+ }
/* Create the per thread RNG */
rngs = MEM_CALLOC(scn->dev->allocator, scn->dev->nthreads, sizeof(*rngs));
@@ -102,7 +107,7 @@ XD(solve_probe)
if(!acc_times) { res = RES_MEM_ERR; goto error; }
/* Retrieve the medium in which the submitted position lies */
- res = scene_get_medium(scn, position, NULL, &medium);
+ res = scene_get_medium(scn, args->position, NULL, &medium);
if(res != RES_OK) goto error;
/* Create the per thread green function */
@@ -122,6 +127,8 @@ XD(solve_probe)
}
/* Here we go! Launch the Monte Carlo estimation */
+ nrealisations = args->nrealisations;
+ register_paths = out_estimator ? args->register_paths : SDIS_HEAT_PATH_NONE;
omp_set_num_threads((int)scn->dev->nthreads);
#pragma omp parallel for schedule(static)
for(irealisation = 0; irealisation < (int64_t)nrealisations; ++irealisation) {
@@ -147,7 +154,7 @@ XD(solve_probe)
time_current(&t0);
if(!out_green) {
- time = sample_time(rng, time_range);
+ time = sample_time(rng, args->time_range);
if(register_paths) {
heat_path_init(scn->dev->allocator, &heat_path);
pheat_path = &heat_path;
@@ -163,7 +170,9 @@ XD(solve_probe)
}
res_simul = XD(probe_realisation)((size_t)irealisation, scn, rng, medium,
- position, time, fp_to_meter, Tarad, Tref, pgreen_path, pheat_path, &w);
+ args->position, time, args->fp_to_meter,
+ args->ambient_radiative_temperature, args->reference_temperature,
+ pgreen_path, pheat_path, &w);
/* Handle fatal error */
if(res_simul != RES_OK && res_simul != RES_BAD_OP) {
diff --git a/src/test_sdis_conducto_radiative.c b/src/test_sdis_conducto_radiative.c
@@ -388,27 +388,30 @@ main(int argc, char** argv)
struct sdis_estimator* estimator;
struct sdis_estimator* estimator2;
struct sdis_green_function* green;
- double pos[3];
- double time_range[2] = { INF, INF };
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
double ref, u;
size_t nreals = 0;
size_t nfails = 0;
const size_t N = 10000;
- pos[0] = ssp_rng_uniform_double(rng, -0.9, 0.9);
- pos[1] = ssp_rng_uniform_double(rng, -0.9, 0.9);
- pos[2] = ssp_rng_uniform_double(rng, -0.9, 0.9);
+ solve_args.nrealisations = N;
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+ solve_args.position[0] = ssp_rng_uniform_double(rng, -0.9, 0.9);
+ solve_args.position[1] = ssp_rng_uniform_double(rng, -0.9, 0.9);
+ solve_args.position[2] = ssp_rng_uniform_double(rng, -0.9, 0.9);
+ solve_args.reference_temperature = Tref;
- OK(sdis_solve_probe(scn, N, pos, time_range, 1, -1, Tref, 0, &estimator));
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
OK(sdis_estimator_get_failure_count(estimator, &nfails));
OK(sdis_estimator_get_temperature(estimator, &T));
OK(sdis_estimator_get_realisation_time(estimator, &time));
- u = (pos[0] + 1) / thickness;
+ u = (solve_args.position[0] + 1) / thickness;
ref = u * Ts1 + (1-u) * Ts0;
printf("Temperature at (%g, %g, %g) = %g ~ %g +/- %g\n",
- SPLIT3(pos), ref, T.E, T.SE);
+ SPLIT3(solve_args.position), ref, T.E, T.SE);
printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE);
printf("#failures = %lu/%lu\n", (unsigned long)nfails, (unsigned long)N);
@@ -417,8 +420,8 @@ main(int argc, char** argv)
CHK(eq_eps(T.E, ref, 3*T.SE) == 1);
/* Check green function */
- OK(sdis_solve_probe_green_function(scn, N, pos, 1, -1, Tref, &green));
- OK(sdis_green_function_solve(green, time_range, &estimator2));
+ OK(sdis_solve_probe_green_function(scn, &solve_args, &green));
+ OK(sdis_green_function_solve(green, solve_args.time_range, &estimator2));
check_green_function(green);
check_estimator_eq(estimator, estimator2);
@@ -426,8 +429,10 @@ main(int argc, char** argv)
OK(sdis_estimator_ref_put(estimator2));
OK(sdis_green_function_ref_put(green));
- OK(sdis_solve_probe(scn, 10, pos, time_range, 1, -1, Tref,
- SDIS_HEAT_PATH_ALL, &estimator));
+ solve_args.nrealisations = 10;
+ solve_args.register_paths = SDIS_HEAT_PATH_ALL;
+
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
OK(sdis_estimator_ref_put(estimator));
printf("\n");
diff --git a/src/test_sdis_conducto_radiative_2d.c b/src/test_sdis_conducto_radiative_2d.c
@@ -394,26 +394,29 @@ main(int argc, char** argv)
struct sdis_estimator* estimator;
struct sdis_estimator* estimator2;
struct sdis_green_function* green;
- double pos[2];
- double time_range[2] = { INF, INF };
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
double ref, u;
size_t nreals = 0;
size_t nfails = 0;
const size_t N = 10000;
- pos[0] = ssp_rng_uniform_double(rng, -0.9, 0.9);
- pos[1] = ssp_rng_uniform_double(rng, -0.9, 0.9);
+ solve_args.nrealisations = N;
+ solve_args.position[0] = ssp_rng_uniform_double(rng, -0.9, 0.9);
+ solve_args.position[1] = ssp_rng_uniform_double(rng, -0.9, 0.9);
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+ solve_args.reference_temperature = Tref;
- OK(sdis_solve_probe(scn, 10000, pos, time_range, 1, -1, Tref, 0, &estimator));
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
OK(sdis_estimator_get_failure_count(estimator, &nfails));
OK(sdis_estimator_get_temperature(estimator, &T));
OK(sdis_estimator_get_realisation_time(estimator, &time));
- u = (pos[0] + 1) / thickness;
+ u = (solve_args.position[0] + 1) / thickness;
ref = u * Ts1 + (1-u) * Ts0;
printf("Temperature at (%g, %g) = %g ~ %g +/- %g\n",
- SPLIT2(pos), ref, T.E, T.SE);
+ SPLIT2(solve_args.position), ref, T.E, T.SE);
printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE);
printf("#failures = %lu/%lu\n", (unsigned long)nfails, (unsigned long)N);
@@ -422,8 +425,8 @@ main(int argc, char** argv)
CHK(eq_eps(T.E, ref, 3*T.SE) == 1);
/* Check green function */
- OK(sdis_solve_probe_green_function(scn, 10000, pos, 1, -1, Tref, &green));
- OK(sdis_green_function_solve(green, time_range, &estimator2));
+ OK(sdis_solve_probe_green_function(scn, &solve_args, &green));
+ OK(sdis_green_function_solve(green, solve_args.time_range, &estimator2));
check_green_function(green);
check_estimator_eq(estimator, estimator2);
@@ -431,8 +434,10 @@ main(int argc, char** argv)
OK(sdis_estimator_ref_put(estimator2));
OK(sdis_green_function_ref_put(green));
- OK(sdis_solve_probe
- (scn, 10, pos, time_range, 1, -1, Tref, SDIS_HEAT_PATH_ALL, &estimator));
+ solve_args.nrealisations = 10;
+ solve_args.register_paths = SDIS_HEAT_PATH_ALL;
+
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
OK(sdis_estimator_ref_put(estimator));
printf("\n");
diff --git a/src/test_sdis_convection.c b/src/test_sdis_convection.c
@@ -188,7 +188,7 @@ main(int argc, char** argv)
struct sdis_interface_shader interf_shader = DUMMY_INTERFACE_SHADER;
struct sdis_interface* box_interfaces[12/*#triangles*/];
struct sdis_interface* square_interfaces[4/*#segments*/];
- double pos[3];
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
double ref;
double Tinf;
double nu;
@@ -262,23 +262,28 @@ main(int argc, char** argv)
OK(sdis_interface_ref_put(interf_T4));
OK(sdis_interface_ref_put(interf_T5));
- d3_splat(pos, 0.25);
+ solve_args.nrealisations = N;
+ solve_args.position[0] = 0.25;
+ solve_args.position[1] = 0.25;
+ solve_args.position[2] = 0.25;
/* Test in 3D for various time values. */
nu = (6 * H) / (RHO*CP);
Tinf = (H*(T0 + T1 + T2 + T3 + T4 + T5)) / (6 * H);
- printf(">>> Temperature of the box at (%g %g %g)\n\n", SPLIT3(pos));
+ printf(">>> Temperature of the box at (%g %g %g)\n\n",
+ SPLIT3(solve_args.position));
FOR_EACH(i, 0, 5) {
double time = i ? (double)i / nu : INF;
- double time_range[2];
- time_range[0] = time_range[1] = time;
ref = Tf_0 * exp(-nu * time) + Tinf * (1 - exp(-nu * time));
+ solve_args.time_range[0] = time;
+ solve_args.time_range[1] = time;
+
/* Setup stationary state */
*((int*)sdis_data_get(is_stationary)) = IS_INF(time);
/* Solve in 3D */
- OK(sdis_solve_probe(box_scn, N, pos, time_range, 1.0, 0, 0, 0, &estimator));
+ OK(sdis_solve_probe(box_scn, &solve_args, &estimator));
OK(sdis_estimator_get_temperature(estimator, &T));
OK(sdis_estimator_get_realisation_time(estimator, &mc_time));
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
@@ -291,8 +296,8 @@ main(int argc, char** argv)
CHK(eq_eps(T.E, ref, T.SE * 3));
if(IS_INF(time)) { /* Check green function */
- OK(sdis_solve_probe_green_function(box_scn, N, pos, 1.0, 0, 0, &green));
- OK(sdis_green_function_solve(green, time_range, &estimator2));
+ OK(sdis_solve_probe_green_function(box_scn, &solve_args, &green));
+ OK(sdis_green_function_solve(green, solve_args.time_range, &estimator2));
check_green_function(green);
check_estimator_eq(estimator, estimator2);
OK(sdis_estimator_ref_put(estimator2));
@@ -306,18 +311,20 @@ main(int argc, char** argv)
/* Test in 2D for various time values. */
nu = (4 * H) / (RHO*CP);
Tinf = (H * (T0 + T1 + T2 + T3)) / (4 * H);
- printf(">>> Temperature of the square at (%g %g)\n\n", SPLIT2(pos));
+ printf(">>> Temperature of the square at (%g %g)\n\n",
+ SPLIT2(solve_args.position));
FOR_EACH(i, 0, 5) {
double time = i ? (double)i / nu : INF;
- double time_range[2];
- time_range[0] = time_range[1] = time;
ref = Tf_0 * exp(-nu * time) + Tinf * (1 - exp(-nu * time));
+ solve_args.time_range[0] = time;
+ solve_args.time_range[1] = time;
+
/* Setup stationnary state */
*((int*)sdis_data_get(is_stationary)) = IS_INF(time);
/* Solve in 2D */
- OK(sdis_solve_probe(square_scn, N, pos, time_range, 1.0, 0, 0, 0, &estimator));
+ OK(sdis_solve_probe(square_scn, &solve_args, &estimator));
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
OK(sdis_estimator_get_failure_count(estimator, &nfails));
CHK(nfails + nreals == N);
@@ -330,8 +337,8 @@ main(int argc, char** argv)
CHK(eq_eps(T.E, ref, T.SE * 3));
if(IS_INF(time)) { /* Check green function */
- OK(sdis_solve_probe_green_function(square_scn, N, pos, 1.0, 0, 0, &green));
- OK(sdis_green_function_solve(green, time_range, &estimator2));
+ OK(sdis_solve_probe_green_function(square_scn, &solve_args, &green));
+ OK(sdis_green_function_solve(green, solve_args.time_range, &estimator2));
check_green_function(green);
check_estimator_eq(estimator, estimator2);
OK(sdis_estimator_ref_put(estimator2));
diff --git a/src/test_sdis_convection_non_uniform.c b/src/test_sdis_convection_non_uniform.c
@@ -196,9 +196,9 @@ main(int argc, char** argv)
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;
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
struct sdis_interface* box_interfaces[12/*#triangles*/];
struct sdis_interface* square_interfaces[4/*#segments*/];
- double pos[3];
double ref;
double Tinf;
double nu;
@@ -278,23 +278,28 @@ main(int argc, char** argv)
OK(sdis_interface_ref_put(interf_T4));
OK(sdis_interface_ref_put(interf_T5));
- d3_splat(pos, 0.25);
+ solve_args.nrealisations = N;
+ solve_args.position[0] = 0.25;
+ solve_args.position[1] = 0.25;
+ solve_args.position[2] = 0.25;
/* Test in 3D for various time values. */
nu = (HC0 + HC1 + HC2 + HC3 + HC4 + HC5) / (RHO * CP);
Tinf = (HC0 * T0 + HC1 * T1 + HC2 * T2 + HC3 * T3 + HC4 * T4 + HC5 * T5)
/ (HC0 + HC1 + HC2 + HC3 + HC4 + HC5);
- printf(">>> Temperature of the box at (%g %g %g)\n\n", SPLIT3(pos));
+ printf(">>> Temperature of the box at (%g %g %g)\n\n",
+ SPLIT3(solve_args.position));
FOR_EACH(i, 0, 5) {
double time = i ? (double)i / nu : INF;
- double time_range[2];
- time_range[0] = time_range[1] = time;
+ solve_args.time_range[0] = time;
+ solve_args.time_range[1] = time;
+
ref = Tf_0 * exp(-nu * time) + Tinf * (1 - exp(-nu * time));
*((int*)sdis_data_get(is_stationary)) = IS_INF(time);
/* Solve in 3D */
- OK(sdis_solve_probe(box_scn, N, pos, time_range, 1.0, 0, 0, 0, &estimator));
+ OK(sdis_solve_probe(box_scn, &solve_args, &estimator));
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
OK(sdis_estimator_get_failure_count(estimator, &nfails));
CHK(nfails + nreals == N);
@@ -307,8 +312,8 @@ main(int argc, char** argv)
CHK(eq_eps(T.E, ref, T.SE * 3));
if(IS_INF(time)) { /* Check green function */
- OK(sdis_solve_probe_green_function(box_scn, N, pos, 1.0, 0, 0, &green));
- OK(sdis_green_function_solve(green, time_range, &estimator2));
+ OK(sdis_solve_probe_green_function(box_scn, &solve_args, &green));
+ OK(sdis_green_function_solve(green, solve_args.time_range, &estimator2));
check_green_function(green);
check_estimator_eq(estimator, estimator2);
OK(sdis_estimator_ref_put(estimator2));
@@ -322,16 +327,19 @@ main(int argc, char** argv)
/* Test in 2D for various time values. */
nu = (HC0 + HC1 + HC2 + HC3) / (RHO * CP);
Tinf = (HC0 * T0 + HC1 * T1 + HC2 * T2 + HC3 * T3) / (HC0 + HC1 + HC2 + HC3);
- printf(">>> Temperature of the square at (%g %g)\n\n", SPLIT2(pos));
+ printf(">>> Temperature of the square at (%g %g)\n\n",
+ SPLIT2(solve_args.position));
FOR_EACH(i, 0, 5) {
double time = i ? (double)i / nu : INF;
- double time_range[2];
- time_range[0] = time_range[1] = time;
+
+ solve_args.time_range[0] = time;
+ solve_args.time_range[1] = time;
+
ref = Tf_0 * exp(-nu * time) + Tinf * (1 - exp(-nu * time));
*((int*)sdis_data_get(is_stationary)) = IS_INF(time);
- OK(sdis_solve_probe(square_scn, N, pos, time_range, 1.0, 0, 0, 0, &estimator));
+ OK(sdis_solve_probe(square_scn, &solve_args, &estimator));
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
OK(sdis_estimator_get_failure_count(estimator, &nfails));
CHK(nfails + nreals == N);
@@ -344,8 +352,8 @@ main(int argc, char** argv)
CHK(eq_eps(T.E, ref, T.SE * 3));
if(IS_INF(time)) { /* Check green function */
- OK(sdis_solve_probe_green_function(square_scn, N, pos, 1.0, 0, 0, &green));
- OK(sdis_green_function_solve(green, time_range, &estimator2));
+ OK(sdis_solve_probe_green_function(square_scn, &solve_args, &green));
+ OK(sdis_green_function_solve(green, solve_args.time_range, &estimator2));
check_green_function(green);
check_estimator_eq(estimator, estimator2);
OK(sdis_estimator_ref_put(estimator2));
diff --git a/src/test_sdis_flux.c b/src/test_sdis_flux.c
@@ -136,6 +136,7 @@ solve(struct sdis_scene* scn, const double pos[])
struct sdis_green_function* green;
struct sdis_mc T;
struct sdis_mc time;
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
size_t nreals;
size_t nfails;
double ref;
@@ -145,8 +146,17 @@ solve(struct sdis_scene* scn, const double pos[])
ref = T0 + (1 - pos[0]) * PHI/LAMBDA;
+ OK(sdis_scene_get_dimension(scn, &dim));
+
+ solve_args.nrealisations = N;
+ solve_args.position[0] = pos[0];
+ solve_args.position[1] = pos[1];
+ solve_args.position[2] = dim == SDIS_SCENE_2D ? 0 : pos[2];
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+
time_current(&t0);
- OK(sdis_solve_probe(scn, N, pos, time_range, 1.0, 0, 0, 0, &estimator));
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
time_sub(&t0, time_current(&t1), &t0);
time_dump(&t0, TIME_ALL, NULL, dump, sizeof(dump));
@@ -155,8 +165,6 @@ solve(struct sdis_scene* scn, const double pos[])
OK(sdis_estimator_get_temperature(estimator, &T));
OK(sdis_estimator_get_realisation_time(estimator, &time));
- OK(sdis_scene_get_dimension(scn, &dim));
-
switch(dim) {
case SDIS_SCENE_2D:
printf("Temperature at (%g %g) = %g ~ %g +/- %g\n",
@@ -177,7 +185,7 @@ solve(struct sdis_scene* scn, const double pos[])
CHK(eq_eps(T.E, ref, T.SE*3));
time_current(&t0);
- OK(sdis_solve_probe_green_function(scn, N, pos, 1.0, 0, 0, &green));
+ OK(sdis_solve_probe_green_function(scn, &solve_args, &green));
time_current(&t1);
OK(sdis_green_function_solve(green, time_range, &estimator2));
time_current(&t2);
diff --git a/src/test_sdis_solid_random_walk_robustness.c b/src/test_sdis_solid_random_walk_robustness.c
@@ -273,14 +273,13 @@ main(int argc, char** argv)
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;
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
struct interf* interf_param = NULL;
struct solid* solid_param = NULL;
struct context ctx;
- double probe[3];
double lower[3];
double upper[3];
double size[3];
- const double time[2] = {DBL_MAX, DBL_MAX};
(void)argc, (void)argv;
OK(mem_init_proxy_allocator(&allocator, &mem_default_allocator));
@@ -347,30 +346,43 @@ main(int argc, char** argv)
interf_param->upper[2] = upper[2];
interf_param->h = 1;
- probe[0] = 0;
- probe[1] = 0;
- probe[2] = 0;
+ solve_args.nrealisations = Nreals;
+ solve_args.position[0] = 0;
+ solve_args.position[1] = 0;
+ solve_args.position[2] = 0;
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+ solve_args.register_paths = SDIS_HEAT_PATH_FAILURE;
/* Launch probe estimation with trilinear profile set at interfaces */
interf_param->profile = PROFILE_TRILINEAR;
- OK(sdis_solve_probe(scn, Nreals, probe, time, 1.0, -1, 0,
- SDIS_HEAT_PATH_FAILURE, &estimator));
- print_estimation_result(estimator, trilinear_temperature(probe));
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
+ print_estimation_result
+ (estimator, trilinear_temperature(solve_args.position));
OK(sdis_estimator_ref_put(estimator));
/* Launch probe estimation with volumetric power profile set at interfaces */
interf_param->profile = PROFILE_VOLUMETRIC_POWER;
solid_param->power = Pw;
- OK(sdis_solve_probe(scn, Nreals, probe, time, 1.0, -1, 0,
- SDIS_HEAT_PATH_FAILURE, &estimator));
- print_estimation_result(estimator, volumetric_temperature(probe, upper));
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
+ print_estimation_result
+ (estimator, volumetric_temperature(solve_args.position, upper));
solid_param->power = SDIS_VOLUMIC_POWER_NONE;
OK(sdis_estimator_ref_put(estimator));
/* Launch medium integration */
interf_param->profile = PROFILE_UNKNOWN;
- OK(sdis_solve_medium(scn, Nreals, solid, time, 1.0, -1, 0,
- SDIS_HEAT_PATH_FAILURE, &estimator));
+ OK(sdis_solve_medium
+ (scn,
+ solve_args.nrealisations,
+ solid,
+ solve_args.time_range,
+ solve_args.fp_to_meter,
+ solve_args.ambient_radiative_temperature,
+ solve_args.reference_temperature,
+ solve_args.register_paths,
+ &estimator));
+
print_estimation_result(estimator, Tfluid);
/*dump_heat_paths(stdout, estimator);*/
OK(sdis_estimator_ref_put(estimator));
diff --git a/src/test_sdis_solve_medium.c b/src/test_sdis_solve_medium.c
@@ -417,7 +417,6 @@ main(int argc, char** argv)
BA(sdis_solve_medium_green_function(scn, 0, solid0, 1.0, 0, 0, &green));
BA(sdis_solve_medium_green_function(scn, Np, NULL, 1.0, 0, 0, &green));
BA(sdis_solve_medium_green_function(scn, Np, solid0, 0.0, 0, 0, &green));
- BA(sdis_solve_medium_green_function(scn, Np, solid0, 1.0, 0, -1, &green));
BA(sdis_solve_medium_green_function(scn, Np, solid0, 1.0, 0, 0, NULL));
BA(sdis_solve_medium_green_function(scn, Np, solid1, 1.0, 0, 0, &green));
OK(sdis_solve_medium_green_function(scn, Np, solid0, 1.0, 0, 0, &green));
diff --git a/src/test_sdis_solve_medium_2d.c b/src/test_sdis_solve_medium_2d.c
@@ -389,7 +389,6 @@ main(int argc, char** argv)
BA(sdis_solve_medium_green_function(scn, 0, solid0, 1.0, 0, 0, &green));
BA(sdis_solve_medium_green_function(scn, Np, NULL, 1.0, 0, 0, &green));
BA(sdis_solve_medium_green_function(scn, Np, solid0, 0.0, 0, 0, &green));
- BA(sdis_solve_medium_green_function(scn, Np, solid0, 1.0, 0, -1, &green));
BA(sdis_solve_medium_green_function(scn, Np, solid0, 1.0, 0, 0, NULL));
BA(sdis_solve_medium_green_function(scn, Np, solid1, 1.0, 0, 0, &green));
OK(sdis_solve_medium_green_function(scn, Np, solid0, 1.0, 0, 0, &green));
diff --git a/src/test_sdis_solve_probe.c b/src/test_sdis_solve_probe.c
@@ -264,6 +264,7 @@ main(int argc, char** argv)
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;
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
struct dump_path_context dump_ctx = DUMP_PATH_CONTEXT_NULL;
struct context ctx;
struct fluid* fluid_param;
@@ -271,8 +272,6 @@ main(int argc, char** argv)
struct interf* interface_param;
struct ssp_rng* rng_state = NULL;
enum sdis_estimator_type type;
- double pos[3];
- double time_range[2];
double ref;
const size_t N = 1000;
const size_t N_dump = 10;
@@ -340,17 +339,23 @@ main(int argc, char** argv)
OK(sdis_interface_ref_put(interf));
/* Test the solver */
- pos[0] = 0.5;
- pos[1] = 0.5;
- pos[2] = 0.5;
- time_range[0] = time_range[1] = INF;
- BA(sdis_solve_probe(NULL, N, pos, time_range, 1.0, 0, 0, 0, &estimator));
- BA(sdis_solve_probe(scn, 0, pos, time_range, 1.0, 0, 0, 0, &estimator));
- BA(sdis_solve_probe(scn, N, NULL, time_range, 1.0, 0, 0, 0, &estimator));
- BA(sdis_solve_probe(scn, N, pos, time_range, 0, 0, 0, 0, &estimator));
- BA(sdis_solve_probe(scn, N, pos, time_range, 0, 0, -1, 0, &estimator));
- BA(sdis_solve_probe(scn, N, pos, time_range, 1.0, 0, 0, 0, NULL));
- OK(sdis_solve_probe(scn, N, pos, time_range, 1.0, 0, 0, 0, &estimator));
+ solve_args.nrealisations = N;
+ solve_args.position[0] = 0.5;
+ solve_args.position[1] = 0.5;
+ solve_args.position[2] = 0.5;
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+
+ BA(sdis_solve_probe(NULL, &solve_args, &estimator));
+ BA(sdis_solve_probe(scn, NULL, &estimator));
+ BA(sdis_solve_probe(scn, &solve_args, NULL));
+ solve_args.nrealisations = 0;
+ BA(sdis_solve_probe(scn, &solve_args, &estimator));
+ solve_args.nrealisations = N;
+ solve_args.fp_to_meter = 0;
+ BA(sdis_solve_probe(scn, &solve_args, &estimator));
+ solve_args.fp_to_meter = 1;
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
BA(sdis_estimator_get_type(estimator, NULL));
BA(sdis_estimator_get_type(NULL, &type));
@@ -388,7 +393,7 @@ main(int argc, char** argv)
ref = 300;
printf("Temperature at (%g, %g, %g) = %g ~ %g +/- %g\n",
- SPLIT3(pos), ref, T.E, T.SE);
+ SPLIT3(solve_args.position), ref, T.E, T.SE);
printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE);
printf("#failures = %lu/%lu\n", (unsigned long)nfails, (unsigned long)N);
@@ -404,23 +409,26 @@ main(int argc, char** argv)
/* The external fluid cannot have an unknown temperature */
fluid_param->temperature = -1;
- BA(sdis_solve_probe(scn, N, pos, time_range, 1.0, 0, 0, 0, &estimator));
+ BA(sdis_solve_probe(scn, &solve_args, &estimator));
fluid_param->temperature = 300;
- OK(sdis_solve_probe(scn, N, pos, time_range, 1.0, 0, 0, 0, &estimator));
-
- BA(sdis_solve_probe_green_function(NULL, N, pos, 1.0, 0, 0, &green));
- BA(sdis_solve_probe_green_function(scn, 0, pos, 1.0, 0, 0, &green));
- BA(sdis_solve_probe_green_function(scn, N, NULL, 1.0, 0, 0, &green));
- BA(sdis_solve_probe_green_function(scn, N, pos, 0.0, 0, 0, &green));
- BA(sdis_solve_probe_green_function(scn, N, pos, 1.0, 0, -1, &green));
- BA(sdis_solve_probe_green_function(scn, N, pos, 1.0, 0, 0, NULL));
- OK(sdis_solve_probe_green_function(scn, N, pos, 1.0, 0, 0, &green));
-
- BA(sdis_green_function_solve(NULL, time_range, &estimator2));
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
+
+ BA(sdis_solve_probe_green_function(NULL, &solve_args, &green));
+ BA(sdis_solve_probe_green_function(scn, NULL, &green));
+ BA(sdis_solve_probe_green_function(scn, &solve_args, NULL));
+ solve_args.nrealisations = 0;
+ BA(sdis_solve_probe_green_function(scn, &solve_args, &green));
+ solve_args.nrealisations = N;
+ solve_args.fp_to_meter = 0;
+ BA(sdis_solve_probe_green_function(scn, &solve_args, &green));
+ solve_args.fp_to_meter = 1;
+ OK(sdis_solve_probe_green_function(scn, &solve_args, &green));
+
+ BA(sdis_green_function_solve(NULL, solve_args.time_range, &estimator2));
BA(sdis_green_function_solve(green, NULL, &estimator2));
- BA(sdis_green_function_solve(green, time_range, NULL));
- OK(sdis_green_function_solve(green, time_range, &estimator2));
+ BA(sdis_green_function_solve(green, solve_args.time_range, NULL));
+ OK(sdis_green_function_solve(green, solve_args.time_range, &estimator2));
check_green_function(green);
check_estimator_eq(estimator, estimator2);
@@ -434,15 +442,16 @@ main(int argc, char** argv)
OK(sdis_estimator_ref_put(estimator));
OK(sdis_estimator_ref_put(estimator2));
- OK(sdis_solve_probe(scn, N, pos, time_range, 1.0, 0, 0, 0, &estimator));
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
BA(sdis_estimator_get_paths_count(NULL, &n));
BA(sdis_estimator_get_paths_count(estimator, NULL));
OK(sdis_estimator_get_paths_count(estimator, &n));
CHK(n == 0);
OK(sdis_estimator_ref_put(estimator));
- OK(sdis_solve_probe(scn, N_dump, pos, time_range, 1.0, 0, 0,
- SDIS_HEAT_PATH_ALL, &estimator));
+ solve_args.nrealisations = N_dump;
+ solve_args.register_paths = SDIS_HEAT_PATH_ALL;
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
OK(sdis_estimator_get_paths_count(estimator, &n));
CHK(n == N_dump);
diff --git a/src/test_sdis_solve_probe2.c b/src/test_sdis_solve_probe2.c
@@ -162,10 +162,9 @@ main(int argc, char** argv)
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interface_shader = DUMMY_INTERFACE_SHADER;
struct sdis_interface* interfaces[12];
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
struct context ctx;
struct interf* interface_param = NULL;
- double pos[3];
- double time_range[2] = { INF, INF };
double ref;
const size_t N = 10000;
size_t nreals;
@@ -239,20 +238,23 @@ main(int argc, char** argv)
OK(sdis_interface_ref_put(T350));
/* Launch the solver */
- pos[0] = 0.5;
- pos[1] = 0.5;
- pos[2] = 0.5;
- time_range[0] = time_range[1] = INF;
- OK(sdis_solve_probe(scn, N, pos, time_range, 1.0, -1, 0, 0, &estimator));
+ solve_args.nrealisations = N;
+ solve_args.position[0] = 0.5;
+ solve_args.position[1] = 0.5;
+ solve_args.position[2] = 0.5;
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
OK(sdis_estimator_get_failure_count(estimator, &nfails));
OK(sdis_estimator_get_temperature(estimator, &T));
OK(sdis_estimator_get_realisation_time(estimator, &time));
/* Print the estimation results */
- ref = 350 * pos[2] + (1-pos[2]) * 300;
+ ref = 350 * solve_args.position[2] + (1-solve_args.position[2]) * 300;
printf("Temperature at (%g, %g, %g) = %g ~ %g +/- %g\n",
- SPLIT3(pos), ref, T.E, T.SE);
+ SPLIT3(solve_args.position), ref, T.E, T.SE);
printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE);
printf("#failures = %lu/%lu\n", (unsigned long)nfails, (unsigned long)N);
@@ -262,8 +264,8 @@ main(int argc, char** argv)
CHK(eq_eps(T.E, ref, 3*T.SE));
/* Check green */
- OK(sdis_solve_probe_green_function(scn, N, pos, 1, -1, 0, &green));
- OK(sdis_green_function_solve(green, time_range, &estimator2));
+ OK(sdis_solve_probe_green_function(scn, &solve_args, &green));
+ OK(sdis_green_function_solve(green, solve_args.time_range, &estimator2));
check_green_function(green);
check_estimator_eq(estimator, estimator2);
diff --git a/src/test_sdis_solve_probe2_2d.c b/src/test_sdis_solve_probe2_2d.c
@@ -159,10 +159,9 @@ main(int argc, char** argv)
struct sdis_solid_shader solid_shader = DUMMY_SOLID_SHADER;
struct sdis_interface_shader interface_shader = DUMMY_INTERFACE_SHADER;
struct sdis_interface* interfaces[4];
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
struct context ctx;
struct interf* interface_param = NULL;
- double pos[2];
- double time_range[2];
double ref;
const size_t N = 10000;
size_t nreals;
@@ -186,14 +185,14 @@ main(int argc, char** argv)
/* Create the fluid/solid interface with no limit conidition */
interface_shader.convection_coef = null_interface_value;
- interface_shader.front = SDIS_INTERFACE_SIDE_SHADER_NULL;
- interface_shader.back = SDIS_INTERFACE_SIDE_SHADER_NULL;
+ interface_shader.front = SDIS_INTERFACE_SIDE_SHADER_NULL;
+ interface_shader.back = SDIS_INTERFACE_SIDE_SHADER_NULL;
OK(sdis_interface_create
(dev, solid, fluid, &interface_shader, NULL, &Tnone));
interface_shader.convection_coef = null_interface_value;
- interface_shader.front = SDIS_INTERFACE_SIDE_SHADER_NULL;
- interface_shader.back = SDIS_INTERFACE_SIDE_SHADER_NULL;
+ interface_shader.front = SDIS_INTERFACE_SIDE_SHADER_NULL;
+ interface_shader.back = SDIS_INTERFACE_SIDE_SHADER_NULL;
interface_shader.front.temperature = interface_get_temperature;
/* Create the fluid/solid interface with a fixed temperature of 300K */
@@ -238,20 +237,23 @@ main(int argc, char** argv)
OK(sdis_interface_ref_put(T350));
/* Launch the solver */
- pos[0] = 0.5;
- pos[1] = 0.5;
- time_range[0] = time_range[1] = INF;
- OK(sdis_solve_probe(scn, N, pos, time_range, 1.0, -1, 0, 0, &estimator));
+ solve_args.nrealisations = N;
+ solve_args.position[0] = 0.5;
+ solve_args.position[1] = 0.5;
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
+
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
OK(sdis_estimator_get_failure_count(estimator, &nfails));
OK(sdis_estimator_get_temperature(estimator, &T));
OK(sdis_estimator_get_realisation_time(estimator, &time));
-
/* Print the estimation results */
- ref = 350 * pos[0] + (1-pos[0]) * 300;
+ ref = 350 * solve_args.position[0] + (1-solve_args.position[0]) * 300;
printf("Temperature at (%g, %g) = %g ~ %g +/- %g\n",
- SPLIT2(pos), ref, T.E, T.SE);
+ SPLIT2(solve_args.position), ref, T.E, T.SE);
printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE);
printf("#failures = %lu/%lu\n", (unsigned long)nfails, (unsigned long)N);
@@ -261,8 +263,8 @@ main(int argc, char** argv)
CHK(eq_eps(T.E, ref, T.SE*2));
/* Check green function */
- OK(sdis_solve_probe_green_function(scn, N, pos, 1.0, -1, 0, &green));
- OK(sdis_green_function_solve(green, time_range, &estimator2));
+ OK(sdis_solve_probe_green_function(scn, &solve_args, &green));
+ OK(sdis_green_function_solve(green, solve_args.time_range, &estimator2));
check_green_function(green);
check_estimator_eq(estimator, estimator2);
diff --git a/src/test_sdis_solve_probe3.c b/src/test_sdis_solve_probe3.c
@@ -184,12 +184,11 @@ main(int argc, char** argv)
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;
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
struct s3dut_mesh* msh = NULL;
struct s3dut_mesh_data msh_data;
struct context ctx = CONTEXT_NULL;
struct interf* interface_param = NULL;
- double pos[3];
- double time_range[2];
double ref;
const size_t N = 10000;
size_t ntris;
@@ -295,20 +294,23 @@ main(int argc, char** argv)
sa_release(ctx.indices);
/* Launch the solver */
- pos[0] = 0.5;
- pos[1] = 0.5;
- pos[2] = 0.5;
- time_range[0] = time_range[1] = INF;
- OK(sdis_solve_probe( scn, N, pos, time_range, 1.0, -1, 0, 0, &estimator));
+ solve_args.nrealisations = N;
+ solve_args.position[0] = 0.5;
+ solve_args.position[1] = 0.5;
+ solve_args.position[2] = 0.5;
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
OK(sdis_estimator_get_failure_count(estimator, &nfails));
OK(sdis_estimator_get_temperature(estimator, &T));
OK(sdis_estimator_get_realisation_time(estimator, &time));
/* Print the estimation results */
- ref = 350 * pos[2] + (1-pos[2]) * 300;
+ ref = 350 * solve_args.position[2] + (1-solve_args.position[2]) * 300;
printf("Temperature at (%g, %g, %g) = %g ~ %g +/- %g\n",
- SPLIT3(pos), ref, T.E, T.SE);
+ SPLIT3(solve_args.position), ref, T.E, T.SE);
printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE);
printf("#failures = %lu/%lu\n", (unsigned long)nfails, (unsigned long)N);
@@ -318,8 +320,8 @@ main(int argc, char** argv)
CHK(eq_eps(T.E, ref, 3*T.SE));
/* Check green function */
- OK(sdis_solve_probe_green_function(scn, N, pos, 1.0, -1, 0, &green));
- OK(sdis_green_function_solve(green, time_range, &estimator2));
+ OK(sdis_solve_probe_green_function(scn, &solve_args, &green));
+ OK(sdis_green_function_solve(green, solve_args.time_range, &estimator2));
check_green_function(green);
check_estimator_eq(estimator, estimator2);
diff --git a/src/test_sdis_solve_probe3_2d.c b/src/test_sdis_solve_probe3_2d.c
@@ -181,10 +181,9 @@ main(int argc, char** argv)
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;
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
struct context ctx = CONTEXT_NULL;
struct interf* interface_param = NULL;
- double pos[2];
- double time_range[2];
double ref;
const size_t N = 10000;
size_t nsegs;
@@ -289,19 +288,21 @@ main(int argc, char** argv)
sa_release(ctx.indices);
/* Launch the solver */
- pos[0] = 0.5;
- pos[1] = 0.5;
- time_range[0] = time_range[1] = INF;
- OK(sdis_solve_probe(scn, N, pos, time_range, 1.0, -1, 0, 0, &estimator));
+ solve_args.nrealisations = N;
+ solve_args.position[0] = 0.5;
+ solve_args.position[1] = 0.5;
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
OK(sdis_estimator_get_failure_count(estimator, &nfails));
OK(sdis_estimator_get_temperature(estimator, &T));
OK(sdis_estimator_get_realisation_time(estimator, &time));
/* Print the estimation results */
- ref = 350 * pos[0] + (1-pos[0]) * 300;
+ ref = 350 * solve_args.position[0] + (1-solve_args.position[0]) * 300;
printf("Temperature at (%g, %g) = %g ~ %g +/- %g\n",
- SPLIT2(pos), ref, T.E, T.SE);
+ SPLIT2(solve_args.position), ref, T.E, T.SE);
printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE);
printf("#failures = %lu/%lu\n", (unsigned long)nfails, (unsigned long)N);
@@ -311,8 +312,8 @@ main(int argc, char** argv)
CHK(eq_eps(T.E, ref, 3*T.SE));
/* Check green function */
- OK(sdis_solve_probe_green_function(scn, N, pos, 1.0, -1, 0, &green));
- OK(sdis_green_function_solve(green, time_range, &estimator2));
+ OK(sdis_solve_probe_green_function(scn, &solve_args, &green));
+ OK(sdis_green_function_solve(green, solve_args.time_range, &estimator2));
check_green_function(green);
check_estimator_eq(estimator, estimator2);
diff --git a/src/test_sdis_solve_probe_2d.c b/src/test_sdis_solve_probe_2d.c
@@ -148,10 +148,9 @@ main(int argc, char** argv)
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;
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
struct context ctx;
struct fluid* fluid_param;
- double pos[2];
- double time_range[2] = { INF, INF };
double ref;
const size_t N = 1000;
size_t nreals;
@@ -199,10 +198,13 @@ main(int argc, char** argv)
OK(sdis_interface_ref_put(interf));
/* Test the solver */
- pos[0] = 0.5;
- pos[1] = 0.5;
- time_range[0] = time_range[1] = INF;
- OK(sdis_solve_probe(scn, N, pos, time_range, 1.0, 0, 0, 0, &estimator));
+ solve_args.nrealisations = N;
+ solve_args.position[0] = 0.5;
+ solve_args.position[1] = 0.5;
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
OK(sdis_estimator_get_failure_count(estimator, &nfails));
OK(sdis_estimator_get_temperature(estimator, &T));
@@ -210,7 +212,7 @@ main(int argc, char** argv)
ref = 300;
printf("Temperature at (%g, %g) = %g ~ %g +/- %g\n",
- SPLIT2(pos), ref, T.E, T.SE);
+ SPLIT2(solve_args.position), ref, T.E, T.SE);
printf("Time per realisation (in usec) = %g +/- %g\n", time.E, time.SE);
printf("#failures = %lu/%lu\n", (unsigned long)nfails, (unsigned long)N);
@@ -218,8 +220,8 @@ main(int argc, char** argv)
CHK(nfails < N/1000);
CHK(eq_eps(T.E, ref, T.SE));
- OK(sdis_solve_probe_green_function(scn, N, pos, 1.0, 0, 0, &green));
- OK(sdis_green_function_solve(green, time_range, &estimator2));
+ OK(sdis_solve_probe_green_function(scn, &solve_args, &green));
+ OK(sdis_green_function_solve(green, solve_args.time_range, &estimator2));
check_green_function(green);
check_estimator_eq(estimator, estimator2);
@@ -230,7 +232,7 @@ main(int argc, char** argv)
/* The external fluid cannot have an unknown temperature */
fluid_param->temperature = -1;
- BA(sdis_solve_probe(scn, N, pos, time_range, 1.0, 0, 0, 0, &estimator));
+ BA(sdis_solve_probe(scn, &solve_args, &estimator));
OK(sdis_scene_ref_put(scn));
OK(sdis_device_ref_put(dev));
diff --git a/src/test_sdis_volumic_power.c b/src/test_sdis_volumic_power.c
@@ -156,6 +156,7 @@ solve(struct sdis_scene* scn, const double pos[])
struct sdis_estimator* estimator;
struct sdis_estimator* estimator2;
struct sdis_green_function* green;
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
struct sdis_mc T;
size_t nreals;
size_t nfails;
@@ -168,8 +169,17 @@ solve(struct sdis_scene* scn, const double pos[])
x = pos[0] - 0.5;
ref = P0 / (2*LAMBDA) * (1.0/4.0 - x*x) + T0;
+ OK(sdis_scene_get_dimension(scn, &dim));
+
+ solve_args.nrealisations = N;
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+ solve_args.position[0] = pos[0];
+ solve_args.position[1] = pos[1];
+ solve_args.position[2] = dim == SDIS_SCENE_2D ? 0 : pos[2];
+
time_current(&t0);
- OK(sdis_solve_probe(scn, N, pos, time_range, 1.0, 0, 0, 0, &estimator));
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
time_sub(&t0, time_current(&t1), &t0);
time_dump(&t0, TIME_ALL, NULL, dump, sizeof(dump));
@@ -177,8 +187,6 @@ solve(struct sdis_scene* scn, const double pos[])
OK(sdis_estimator_get_failure_count(estimator, &nfails));
OK(sdis_estimator_get_temperature(estimator, &T));
- OK(sdis_scene_get_dimension(scn, &dim));
-
switch(dim) {
case SDIS_SCENE_2D:
printf("Temperature at (%g %g) = %g ~ %g +/- %g [%g, %g]\n",
@@ -198,7 +206,7 @@ solve(struct sdis_scene* scn, const double pos[])
CHK(eq_eps(T.E, ref, T.SE*3));
time_current(&t0);
- OK(sdis_solve_probe_green_function(scn, N, pos, 1.0, 0, 0, &green));
+ OK(sdis_solve_probe_green_function(scn, &solve_args, &green));
time_current(&t1);
OK(sdis_green_function_solve(green, time_range, &estimator2));
time_current(&t2);
diff --git a/src/test_sdis_volumic_power2.c b/src/test_sdis_volumic_power2.c
@@ -229,20 +229,24 @@ static void
check(struct sdis_scene* scn, const struct reference refs[], const size_t nrefs)
{
struct sdis_estimator* estimator = NULL;
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
struct sdis_mc T = SDIS_MC_NULL;
size_t nreals;
size_t nfails;
double pos[3] = {0,0};
- double time_range[2] = { INF, INF };
size_t i;
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+ solve_args.nrealisations = N;
+
FOR_EACH(i, 0, nrefs) {
double Tc;
- pos[0] = refs[i].pos[0];
- pos[1] = refs[i].pos[1];
- pos[2] = refs[i].pos[2];
+ solve_args.position[0] = refs[i].pos[0];
+ solve_args.position[1] = refs[i].pos[1];
+ solve_args.position[2] = refs[i].pos[2];
- OK(sdis_solve_probe(scn, N, pos, time_range, 1.f, -1, 0, 0, &estimator));
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
OK(sdis_estimator_get_temperature(estimator, &T));
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
OK(sdis_estimator_get_failure_count(estimator, &nfails));
diff --git a/src/test_sdis_volumic_power2_2d.c b/src/test_sdis_volumic_power2_2d.c
@@ -250,18 +250,22 @@ check(struct sdis_scene* scn, const struct reference refs[], const size_t nrefs)
{
struct sdis_estimator* estimator = NULL;
struct sdis_mc T = SDIS_MC_NULL;
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
size_t nreals;
size_t nfails;
double pos[2] = {0,0};
- double time_range[2] = { INF, INF };
size_t i;
+ solve_args.nrealisations = N;
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+
FOR_EACH(i, 0, nrefs) {
double Tc;
- pos[0] = refs[i].pos[0];
- pos[1] = refs[i].pos[1];
+ solve_args.position[0] = refs[i].pos[0];
+ solve_args.position[1] = refs[i].pos[1];
- OK(sdis_solve_probe(scn, N, pos, time_range, 1.f, -1, 0, 0, &estimator));
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
OK(sdis_estimator_get_temperature(estimator, &T));
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
OK(sdis_estimator_get_failure_count(estimator, &nfails));
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_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
struct sdis_mc T = SDIS_MC_NULL;
double Tref;
double time_range[2] = { INF, INF };
@@ -441,7 +442,12 @@ main(int argc, char** argv)
FATAL("Unreachable code.\n");
}
- OK(sdis_solve_probe(scn, N, pos, time_range, 1.f, -1, 0, 0, &estimator));
+ solve_args.nrealisations = N;
+ solve_args.position[0] = pos[0];
+ solve_args.position[1] = pos[1];
+ solve_args.time_range[0] = time_range[0];
+ solve_args.time_range[1] = time_range[1];
+ OK(sdis_solve_probe(scn, &solve_args, &estimator));
OK(sdis_estimator_get_temperature(estimator, &T));
OK(sdis_estimator_get_failure_count(estimator, &nfails));
OK(sdis_estimator_get_realisation_count(estimator, &nreals));
diff --git a/src/test_sdis_volumic_power4.c b/src/test_sdis_volumic_power4.c
@@ -225,9 +225,9 @@ main(int argc, char** argv)
struct sdis_interface* interf_solid_fluid2 = NULL;
struct sdis_interface* interfaces[12/*#max primitives*/];
struct sdis_mc T = SDIS_MC_NULL;
+ struct sdis_solve_probe_args solve_args = SDIS_SOLVE_PROBE_ARGS_DEFAULT;
size_t nreals, nfails;
double pos[3];
- double time_range[2] = { INF, INF };
double Tref;
double x;
(void)argc, (void)argv;
@@ -353,10 +353,17 @@ main(int argc, char** argv)
x = pos[1];
Tref = -Power / (2*LAMBDA) * x*x + Tf + Power/(2*H) + Power/(8*LAMBDA);
+ solve_args.nrealisations = N;
+ solve_args.position[0] = pos[0];
+ solve_args.position[1] = pos[1];
+ solve_args.position[2] = pos[2];
+ solve_args.time_range[0] = INF;
+ solve_args.time_range[1] = INF;
+
printf(">>> 2D\n");
time_current(&t0);
- OK(sdis_solve_probe(scn_2d, N, pos, time_range, 1.f, -1, 0, 0, &estimator));
+ OK(sdis_solve_probe(scn_2d, &solve_args, &estimator));
time_sub(&t0, time_current(&t1), &t0);
time_dump(&t0, TIME_ALL, NULL, dump, sizeof(dump));
printf("Elapsed time = %s\n", dump);
@@ -375,7 +382,7 @@ main(int argc, char** argv)
printf("\n>>> 3D\n");
time_current(&t0);
- OK(sdis_solve_probe(scn_3d, N, pos, time_range, 1.f, -1, 0, 0, &estimator));
+ OK(sdis_solve_probe(scn_3d, &solve_args, &estimator));
time_sub(&t0, time_current(&t1), &t0);
time_dump(&t0, TIME_ALL, NULL, dump, sizeof(dump));
printf("Elapsed time = %s\n", dump);