stardis-solver

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

commit 31dc31181fb81409484328cdc21fd3d2a03cf3b2
parent 828ab9a8363d2c46d6e156cb2225d39b9b344e43
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 25 Jun 2020 11:35:27 +0200

Update the API of sdis_solve_boundary[_green_function]

Diffstat:
Msrc/sdis.h | 49+++++++++++++++++++++++++++++++------------------
Msrc/sdis_solve.c | 32++++++--------------------------
Msrc/sdis_solve_boundary_Xd.h | 75+++++++++++++++++++++++++++++++++++++++++++++------------------------------
Msrc/test_sdis_solve_boundary.c | 244+++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
4 files changed, 226 insertions(+), 174 deletions(-)

diff --git a/src/sdis.h b/src/sdis.h @@ -313,7 +313,7 @@ struct sdis_solve_probe_boundary_args { 10000, /* #realisations */ \ 0, /* Primitive identifier */ \ {0,0}, /* UV */ \ - {DBL_MAX,DBL_MAX}, \ + {DBL_MAX,DBL_MAX}, /* Time range */ \ SDIS_SIDE_NULL__, \ 1, /* FP to meter */ \ -1, /* Ambient radiative temperature */ \ @@ -323,7 +323,34 @@ struct sdis_solve_probe_boundary_args { } static const struct sdis_solve_probe_boundary_args SDIS_SOLVE_PROBE_BOUNDARY_ARGS_DEFAULT = -SDIS_SOLVE_PROBE_BOUNDARY_ARGS_DEFAULT__; + SDIS_SOLVE_PROBE_BOUNDARY_ARGS_DEFAULT__; + +struct sdis_solve_boundary_args { + size_t nrealisations; /* #realisations */ + size_t* primitives; /* List of boundary primitives to handle */ + enum sdis_side* sides; /* Per primitive side to consider */ + size_t nprimitives; /* #primitives */ + 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_BOUNDARY_ARGS_DEFAULT__ { \ + 10000, /* #realisations */ \ + NULL, /* List or primitive ids */ \ + NULL, /* Per primitive side */ \ + 0, /* #primitives */ \ + {DBL_MAX,DBL_MAX}, /* Time range */ \ + 1, /* FP to meter */ \ + -1, /* Ambient radiative temperature */ \ + -1, /* Refernce temperature */ \ + SDIS_HEAT_PATH_NONE, \ + NULL /* RNG state */ \ +} +static const struct sdis_solve_boundary_args SDIS_SOLVE_BOUNDARY_ARGS_DEFAULT = + SDIS_SOLVE_BOUNDARY_ARGS_DEFAULT__; /* Functor used to process the paths registered against the green function */ typedef res_T @@ -908,15 +935,7 @@ sdis_solve_probe_boundary SDIS_API res_T sdis_solve_boundary (struct sdis_scene* scn, - const size_t nrealisations, /* #realisations */ - const size_t primitives[], /* List of boundary primitives to handle */ - const enum sdis_side sides[], /* Per primitive side to consider */ - const size_t nprimitives, /* #primitives */ - 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_boundary_args* args, struct sdis_estimator** estimator); SDIS_API res_T @@ -1005,13 +1024,7 @@ sdis_solve_probe_boundary_green_function SDIS_API res_T sdis_solve_boundary_green_function (struct sdis_scene* scn, - const size_t nrealisations, /* #realisations */ - const size_t primitives[], /* List of boundary primitives to handle */ - const enum sdis_side sides[], /* Per primitive side to consider */ - const size_t nprimitives, /* #primitives */ - 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_boundary_args* args, struct sdis_green_function** green); SDIS_API res_T diff --git a/src/sdis_solve.c b/src/sdis_solve.c @@ -276,48 +276,28 @@ sdis_solve_probe_boundary_green_function res_T sdis_solve_boundary (struct sdis_scene* scn, - const size_t nrealisations, /* #realisations */ - const size_t primitives[], /* List of boundary primitives to handle */ - const enum sdis_side sides[], /* Per primitive side to consider */ - const size_t nprimitives, /* #primitives */ - const double time_range[2], /* Observation time */ - const double fp_to_meter, /* Scale from floating point units to meters */ - const double Tarad, /* In Kelvin */ - const double Tref, /* In Kelvin */ - const int register_paths, /* Combination of enum sdis_heat_path_flag */ + const struct sdis_solve_boundary_args* args, struct sdis_estimator** out_estimator) { if(!scn) return RES_BAD_ARG; if(scene_is_2d(scn)) { - return solve_boundary_2d(scn, nrealisations, primitives, sides, nprimitives, - time_range, fp_to_meter, Tarad, Tref, register_paths, NULL, out_estimator); + return solve_boundary_2d(scn, args, NULL, out_estimator); } else { - return solve_boundary_3d(scn, nrealisations, primitives, sides, nprimitives, - time_range, fp_to_meter, Tarad, Tref, register_paths, NULL, out_estimator); + return solve_boundary_3d(scn, args, NULL, out_estimator); } } res_T sdis_solve_boundary_green_function (struct sdis_scene* scn, - const size_t nrealisations, /* #realisations */ - const size_t primitives[], /* List of boundary primitives to handle */ - const enum sdis_side sides[], /* Per primitive side to consider */ - const size_t nprimitives, /* #primitives */ - const double fp_to_meter, /* Scale from floating point units to meters */ - const double Tarad, /* In Kelvin */ - const double Tref, /* In Kelvin */ + const struct sdis_solve_boundary_args* args, struct sdis_green_function** green) { if(!scn) return RES_BAD_ARG; if(scene_is_2d(scn)) { - return solve_boundary_2d(scn, nrealisations, primitives, sides, - nprimitives, NULL, fp_to_meter, Tarad, Tref, SDIS_HEAT_PATH_NONE, green, - NULL); + return solve_boundary_2d(scn, args, green, NULL); } else { - return solve_boundary_3d(scn, nrealisations, primitives, sides, - nprimitives, NULL, fp_to_meter, Tarad, Tref, SDIS_HEAT_PATH_NONE, green, - NULL); + return solve_boundary_3d(scn, args, green, NULL); } } diff --git a/src/sdis_solve_boundary_Xd.h b/src/sdis_solve_boundary_Xd.h @@ -76,15 +76,7 @@ XD(boundary_get_position)(const unsigned ivert, float pos[DIM], void* context) static res_T XD(solve_boundary) (struct sdis_scene* scn, - const size_t nrealisations, /* #realisations */ - const size_t primitives[], /* List of boundary primitives to handle */ - const enum sdis_side sides[], /* Per primitive side to consider */ - const size_t nprimitives, /* #primitives */ - const double time_range[2], /* Observation time */ - const double fp_to_meter, /* Scale from floating point units to meters */ - const double Tarad, /* In Kelvin */ - const double Tref, /* In Kelvin */ - const int register_paths, /* Combination of enum sdis_heat_path_flag */ + const struct sdis_solve_boundary_args* args, struct sdis_green_function** out_green, struct sdis_estimator** out_estimator) { @@ -100,15 +92,18 @@ XD(solve_boundary) 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; size_t view_nprims; - int64_t irealisation; int progress = 0; + int register_paths = SDIS_HEAT_PATH_NONE; ATOMIC nsolved_realisations = 0; ATOMIC res = RES_OK; - if(!scn || !nrealisations || nrealisations > INT64_MAX || !primitives - || !sides || !nprimitives || fp_to_meter <= 0 || Tref < 0) { + if(!scn || !args || !args->nrealisations || args->nrealisations > INT64_MAX + || !args->primitives || !args->sides || !args->nprimitives + || args->fp_to_meter <= 0) { res = RES_BAD_ARG; goto error; } @@ -117,8 +112,10 @@ XD(solve_boundary) 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; } @@ -131,16 +128,23 @@ XD(solve_boundary) #endif SXD(scene_view_primitives_count(scn->sXd(view), &view_nprims)); - FOR_EACH(i, 0, nprimitives) { - if(primitives[i] >= view_nprims) { + FOR_EACH(i, 0, args->nprimitives) { + if(args->primitives[i] >= view_nprims) { log_err(scn->dev, "%s: invalid primitive identifier `%lu'. It must be in the [0 %lu] range.\n", FUNC_NAME, - (unsigned long)primitives[i], + (unsigned long)args->primitives[i], (unsigned long)scene_get_primitives_count(scn)-1); res = RES_BAD_ARG; goto error; } + if((unsigned)args->sides[i] >= SDIS_SIDE_NULL__) { + log_err(scn->dev, + "%s: invalid side for the primitive `%lu'.\n", + FUNC_NAME, (unsigned long)args->primitives[i]); + res = RES_BAD_ARG; + goto error; + } } /* Create the Star-XD shape of the boundary */ @@ -153,18 +157,20 @@ XD(solve_boundary) /* Initialise the boundary shape with the triangles/segments of the * submitted primitives */ - ctx.primitives = primitives; + ctx.primitives = args->primitives; ctx.view = scn->sXd(view); vdata.usage = SXD_POSITION; vdata.get = XD(boundary_get_position); #if SDIS_XD_DIMENSION == 2 vdata.type = S2D_FLOAT2; - res = s2d_line_segments_setup_indexed_vertices(shape, (unsigned)nprimitives, - boundary_get_indices_2d, (unsigned)(nprimitives*2), &vdata, 1, &ctx); + res = s2d_line_segments_setup_indexed_vertices(shape, + (unsigned)args->nprimitives, boundary_get_indices_2d, + (unsigned)(args->nprimitives*2), &vdata, 1, &ctx); #else vdata.type = S3D_FLOAT3; - res = s3d_mesh_setup_indexed_vertices(shape, (unsigned)nprimitives, - boundary_get_indices_3d, (unsigned)(nprimitives*3), &vdata, 1, &ctx); + res = s3d_mesh_setup_indexed_vertices(shape, + (unsigned)args->nprimitives, boundary_get_indices_3d, + (unsigned)(args->nprimitives*3), &vdata, 1, &ctx); #endif if(res != RES_OK) goto error; @@ -177,9 +183,15 @@ XD(solve_boundary) if(res != RES_OK) goto error; /* 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)); @@ -213,6 +225,8 @@ XD(solve_boundary) if(res != RES_OK) goto error; } + 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) { @@ -243,7 +257,7 @@ XD(solve_boundary) 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; @@ -277,13 +291,14 @@ XD(solve_boundary) if(res_local != RES_OK) { ATOMIC_SET(&res, res_local); continue; } /* Map from boundary scene to sdis scene */ - ASSERT(prim.prim_id < nprimitives); - iprim = primitives[prim.prim_id]; - side = sides[prim.prim_id]; + ASSERT(prim.prim_id < args->nprimitives); + iprim = args->primitives[prim.prim_id]; + side = args->sides[prim.prim_id]; /* Invoke the boundary realisation */ res_simul = XD(boundary_realisation)(scn, rng, iprim, uv, time, side, - fp_to_meter, Tarad, Tref, pgreen_path, pheat_path, &w); + args->fp_to_meter, args->ambient_radiative_temperature, + args->reference_temperature, pgreen_path, pheat_path, &w); /* Fatal error */ if(res_simul != RES_OK && res_simul != RES_BAD_OP) { diff --git a/src/test_sdis_solve_boundary.c b/src/test_sdis_solve_boundary.c @@ -191,13 +191,12 @@ main(int argc, char** argv) struct sdis_interface_shader interf_shader = SDIS_INTERFACE_SHADER_NULL; struct sdis_interface* box_interfaces[12 /*#triangles*/]; struct sdis_interface* square_interfaces[4/*#segments*/]; - struct sdis_solve_probe_boundary_args solve_args = + struct sdis_solve_probe_boundary_args probe_args = SDIS_SOLVE_PROBE_BOUNDARY_ARGS_DEFAULT; + struct sdis_solve_boundary_args bound_args = SDIS_SOLVE_BOUNDARY_ARGS_DEFAULT; struct interf* interf_props = NULL; struct fluid* fluid_param; double pos[3]; - double time_range[2] = { INF, INF }; - double tr[2]; double ref; size_t prims[4]; enum sdis_side sides[4]; @@ -298,56 +297,56 @@ main(int argc, char** argv) #define SOLVE sdis_solve_probe_boundary #define GREEN sdis_solve_probe_boundary_green_function - solve_args.nrealisations = N; - solve_args.uv[0] = 0.3; - solve_args.uv[1] = 0.3; - solve_args.iprim = 6; - solve_args.time_range[0] = INF; - solve_args.time_range[1] = INF; - solve_args.side = SDIS_FRONT; + probe_args.nrealisations = N; + probe_args.uv[0] = 0.3; + probe_args.uv[1] = 0.3; + probe_args.iprim = 6; + probe_args.time_range[0] = INF; + probe_args.time_range[1] = INF; + probe_args.side = SDIS_FRONT; - BA(SOLVE(NULL, &solve_args, &estimator)); + BA(SOLVE(NULL, &probe_args, &estimator)); BA(SOLVE(box_scn, NULL, &estimator)); - BA(SOLVE(box_scn, &solve_args, NULL)); - solve_args.nrealisations = 0; - BA(SOLVE(box_scn, &solve_args, &estimator)); - solve_args.nrealisations = N; - solve_args.iprim = 12; - BA(SOLVE(box_scn, &solve_args, &estimator)); - solve_args.iprim = 6; - solve_args.side = SDIS_SIDE_NULL__; - BA(SOLVE(box_scn, &solve_args, &estimator)); - solve_args.side = SDIS_FRONT; - solve_args.time_range[0] = solve_args.time_range[1] = -1; - BA(SOLVE(box_scn, &solve_args, &estimator)); - solve_args.time_range[0] = 1; - BA(SOLVE(box_scn, &solve_args, &estimator)); - solve_args.time_range[1] = 0; - BA(SOLVE(box_scn, &solve_args, &estimator)); - solve_args.time_range[0] = solve_args.time_range[1] = INF; - - OK(SOLVE(box_scn, &solve_args, &estimator)); + BA(SOLVE(box_scn, &probe_args, NULL)); + probe_args.nrealisations = 0; + BA(SOLVE(box_scn, &probe_args, &estimator)); + probe_args.nrealisations = N; + probe_args.iprim = 12; + BA(SOLVE(box_scn, &probe_args, &estimator)); + probe_args.iprim = 6; + probe_args.side = SDIS_SIDE_NULL__; + BA(SOLVE(box_scn, &probe_args, &estimator)); + probe_args.side = SDIS_FRONT; + probe_args.time_range[0] = probe_args.time_range[1] = -1; + BA(SOLVE(box_scn, &probe_args, &estimator)); + probe_args.time_range[0] = 1; + BA(SOLVE(box_scn, &probe_args, &estimator)); + probe_args.time_range[1] = 0; + BA(SOLVE(box_scn, &probe_args, &estimator)); + probe_args.time_range[0] = probe_args.time_range[1] = INF; + + OK(SOLVE(box_scn, &probe_args, &estimator)); OK(sdis_scene_get_boundary_position - (box_scn, solve_args.iprim, solve_args.uv, pos)); + (box_scn, probe_args.iprim, probe_args.uv, pos)); printf("Boundary temperature of the box at (%g %g %g) = ", SPLIT3(pos)); check_estimator(estimator, N, ref); - BA(GREEN(NULL, &solve_args, &green)); + BA(GREEN(NULL, &probe_args, &green)); BA(GREEN(box_scn, NULL, &green)); - BA(GREEN(box_scn, &solve_args, NULL)); - solve_args.nrealisations = 0; - BA(GREEN(box_scn, &solve_args, &green)); - solve_args.nrealisations = N; - solve_args.iprim = 12; - BA(GREEN(box_scn, &solve_args, &green)); - solve_args.iprim = 6; - solve_args.side = SDIS_SIDE_NULL__; - BA(GREEN(box_scn, &solve_args, &green)); - solve_args.side = SDIS_FRONT; - OK(GREEN(box_scn, &solve_args, &green)); + BA(GREEN(box_scn, &probe_args, NULL)); + probe_args.nrealisations = 0; + BA(GREEN(box_scn, &probe_args, &green)); + probe_args.nrealisations = N; + probe_args.iprim = 12; + BA(GREEN(box_scn, &probe_args, &green)); + probe_args.iprim = 6; + probe_args.side = SDIS_SIDE_NULL__; + BA(GREEN(box_scn, &probe_args, &green)); + probe_args.side = SDIS_FRONT; + OK(GREEN(box_scn, &probe_args, &green)); check_green_function(green); - OK(sdis_green_function_solve(green, time_range, &estimator2)); + OK(sdis_green_function_solve(green, probe_args.time_range, &estimator2)); check_estimator(estimator2, N, ref); OK(sdis_green_function_ref_put(green)); @@ -355,29 +354,29 @@ main(int argc, char** argv) OK(sdis_estimator_ref_put(estimator2)); /* Dump paths */ - solve_args.nrealisations = N_dump; - solve_args.register_paths = SDIS_HEAT_PATH_ALL; - OK(SOLVE(box_scn, &solve_args, &estimator)); + probe_args.nrealisations = N_dump; + probe_args.register_paths = SDIS_HEAT_PATH_ALL; + OK(SOLVE(box_scn, &probe_args, &estimator)); dump_heat_paths(fp, estimator); OK(sdis_estimator_ref_put(estimator)); /* The external fluid cannot have an unknown temperature */ fluid_param->temperature = UNKNOWN_TEMPERATURE; - BA(SOLVE(box_scn, &solve_args, &estimator)); + BA(SOLVE(box_scn, &probe_args, &estimator)); fluid_param->temperature = Tf; - solve_args.nrealisations = N; - solve_args.register_paths = SDIS_HEAT_PATH_NONE; - solve_args.uv[0] = 0.5; - solve_args.iprim = 4; + probe_args.nrealisations = N; + probe_args.register_paths = SDIS_HEAT_PATH_NONE; + probe_args.uv[0] = 0.5; + probe_args.iprim = 4; - BA(SOLVE(square_scn, &solve_args, &estimator)); - solve_args.iprim = 3; - OK(SOLVE(square_scn, &solve_args, &estimator)); + BA(SOLVE(square_scn, &probe_args, &estimator)); + probe_args.iprim = 3; + OK(SOLVE(square_scn, &probe_args, &estimator)); - OK(GREEN(square_scn, &solve_args, &green)); + OK(GREEN(square_scn, &probe_args, &green)); check_green_function(green); - OK(sdis_green_function_solve(green, solve_args.time_range, &estimator2)); + OK(sdis_green_function_solve(green, probe_args.time_range, &estimator2)); check_estimator(estimator2, N, ref); OK(sdis_estimator_ref_put(estimator)); @@ -386,7 +385,7 @@ main(int argc, char** argv) /* The external fluid cannot have an unknown temperature */ fluid_param->temperature = UNKNOWN_TEMPERATURE; - BA(SOLVE(square_scn, &solve_args, &estimator)); + BA(SOLVE(square_scn, &probe_args, &estimator)); fluid_param->temperature = Tf; #undef F @@ -398,40 +397,78 @@ main(int argc, char** argv) sides[2] = SDIS_FRONT; sides[3] = SDIS_FRONT; + bound_args.nrealisations = N; + bound_args.sides = sides; + bound_args.primitives = prims; + bound_args.nprimitives = 2; + bound_args.time_range[0] = INF; + bound_args.time_range[1] = INF; + #define SOLVE sdis_solve_boundary #define GREEN sdis_solve_boundary_green_function prims[0] = 6; prims[1] = 7; - BA(SOLVE(NULL, N, prims, sides, 2, time_range, 1.0, 0, 0, 0, &estimator)); - BA(SOLVE(box_scn, 0, prims, sides, 2, time_range, 1.0, 0, 0, 0, &estimator)); - BA(SOLVE(box_scn, N, NULL, sides, 2, time_range, 1.0, 0, 0, 0, &estimator)); - BA(SOLVE(box_scn, N, prims, NULL, 2, time_range, 1.0, 0, 0, 0, &estimator)); - BA(SOLVE(box_scn, N, prims, sides, 0, time_range, 1.0, 0, 0, 0, &estimator)); - BA(SOLVE(box_scn, N, prims, sides, 2, NULL, 1.0, 0, 0, 0, &estimator)); - BA(SOLVE(box_scn, N, prims, sides, 2, time_range, 1.0, 0, 0, 0, NULL)); - tr[0] = tr[1] = -1; - BA(SOLVE(box_scn, N, prims, sides, 2, tr, 1.0, 0, 0, 0, NULL)); - tr[0] = 1; - BA(SOLVE(box_scn, N, prims, sides, 2, tr, 1.0, 0, 0, 0, NULL)); - tr[1] = 0; - BA(SOLVE(box_scn, N, prims, sides, 2, tr, 1.0, 0, 0, 0, NULL)); + + BA(SOLVE(NULL, &bound_args, &estimator)); + BA(SOLVE(box_scn, NULL, &estimator)); + BA(SOLVE(box_scn, &bound_args, NULL)); + bound_args.nrealisations = 0; + BA(SOLVE(box_scn, &bound_args, &estimator)); + bound_args.nrealisations = N; + bound_args.primitives = NULL; + BA(SOLVE(box_scn, &bound_args, &estimator)); + bound_args.primitives = prims; + bound_args.sides = NULL; + BA(SOLVE(box_scn, &bound_args, &estimator)); + bound_args.sides = sides; + bound_args.nprimitives = 0; + BA(SOLVE(box_scn, &bound_args, &estimator)); + bound_args.nprimitives = 2; + prims[0] = 12; + BA(SOLVE(box_scn, &bound_args, &estimator)); + prims[0] = 6; + sides[0] = SDIS_SIDE_NULL__; + BA(SOLVE(box_scn, &bound_args, &estimator)); + sides[0] = SDIS_FRONT; + bound_args.time_range[0] = bound_args.time_range[1] = -1; + BA(SOLVE(box_scn, &bound_args, &estimator)); + bound_args.time_range[0] = 1; + BA(SOLVE(box_scn, &bound_args, &estimator)); + bound_args.time_range[1] = 0; + BA(SOLVE(box_scn, &bound_args, &estimator)); + bound_args.time_range[0] = bound_args.time_range[1] = INF; /* Average temperature on the right side of the box */ - OK(SOLVE(box_scn, N, prims, sides, 2, time_range, 1.0, 0, 0, 0, &estimator)); + OK(SOLVE(box_scn, &bound_args, &estimator)); printf("Average temperature of the right side of the box = "); check_estimator(estimator, N, ref); - BA(GREEN(NULL, N, prims, sides, 2, 1.0, 0, 0, &green)); - BA(GREEN(box_scn, 0, prims, sides, 2, 1.0, 0, 0, &green)); - BA(GREEN(box_scn, N, NULL, sides, 2, 1.0, 0, 0, &green)); - BA(GREEN(box_scn, N, prims, NULL, 2, 1.0, 0, 0, &green)); - BA(GREEN(box_scn, N, prims, sides, 0, 1.0, 0, 0, &green)); - BA(GREEN(box_scn, N, prims, sides, 2, 0.0, 0, 0, &green)); - BA(GREEN(box_scn, N, prims, sides, 2, 1.0, 0, 0, NULL)); + BA(GREEN(NULL, &bound_args, &green)); + BA(GREEN(box_scn, NULL, &green)); + BA(GREEN(box_scn, &bound_args, NULL)); + bound_args.nrealisations = 0; + BA(GREEN(box_scn, &bound_args, &green)); + bound_args.nrealisations = N; + bound_args.primitives = NULL; + BA(GREEN(box_scn, &bound_args, &green)); + bound_args.primitives = prims; + bound_args.sides = NULL; + BA(GREEN(box_scn, &bound_args, &green)); + bound_args.sides = sides; + bound_args.nprimitives = 0; + BA(GREEN(box_scn, &bound_args, &green)); + bound_args.nprimitives = 2; + prims[0] = 12; + BA(GREEN(box_scn, &bound_args, &green)); + prims[0] = 6; + sides[0] = SDIS_SIDE_NULL__; + BA(GREEN(box_scn, &bound_args, &green)); + sides[0] = SDIS_FRONT; + - OK(GREEN(box_scn, N, prims, sides, 2, 1.0, 0, 0, &green)); + OK(GREEN(box_scn, &bound_args, &green)); check_green_function(green); - OK(sdis_green_function_solve(green, time_range, &estimator2)); + OK(sdis_green_function_solve(green, bound_args.time_range, &estimator2)); check_estimator(estimator2, N, ref); OK(sdis_green_function_ref_put(green)); @@ -439,21 +476,28 @@ main(int argc, char** argv) OK(sdis_estimator_ref_put(estimator2)); /* Dump path */ - OK(SOLVE(box_scn, N_dump, prims, sides, 2, time_range, 1.0, 0, 0, - SDIS_HEAT_PATH_ALL, &estimator)); + bound_args.nrealisations = N_dump; + bound_args.register_paths = SDIS_HEAT_PATH_ALL; + OK(SOLVE(box_scn, &bound_args, &estimator)); dump_heat_paths(fp, estimator); OK(sdis_estimator_ref_put(estimator)); + /* Switch in 2D */ + bound_args.nrealisations = N; + bound_args.register_paths = SDIS_HEAT_PATH_NONE; + bound_args.nprimitives = 1; + prims[0] = 4; + BA(SOLVE(square_scn, &bound_args, &estimator)); + /* Average temperature on the right side of the square */ prims[0] = 3; - sides[0] = SDIS_FRONT; - OK(SOLVE(square_scn, N, prims, sides, 1, time_range, 1.0, 0, 0, 0, &estimator)); + OK(SOLVE(square_scn, &bound_args, &estimator)); printf("Average temperature of the right side of the square = "); check_estimator(estimator, N, ref); - OK(GREEN(square_scn, N, prims, sides, 1, 1.0, 0, 0, &green)); + OK(GREEN(square_scn, &bound_args, &green)); check_green_function(green); - OK(sdis_green_function_solve(green, time_range, &estimator2)); + OK(sdis_green_function_solve(green, bound_args.time_range, &estimator2)); check_estimator(estimator2, N, ref); OK(sdis_green_function_ref_put(green)); @@ -461,16 +505,14 @@ main(int argc, char** argv) OK(sdis_estimator_ref_put(estimator2)); /* Dump path */ - OK(SOLVE(square_scn, N_dump, prims, sides, 1, time_range, 1.0, 0, 0, - SDIS_HEAT_PATH_ALL, &estimator)); + bound_args.nrealisations = N_dump; + bound_args.register_paths = SDIS_HEAT_PATH_ALL; + OK(SOLVE(square_scn, &bound_args, &estimator)); dump_heat_paths(fp, estimator); OK(sdis_estimator_ref_put(estimator)); - /* Check out of bound prims */ - prims[0] = 12; - BA(SOLVE(box_scn, N, prims, sides, 2, time_range, 1.0, 0, 0, 0, &estimator)); - prims[0] = 4; - BA(SOLVE(square_scn, N, prims, sides, 1, time_range, 1.0, 0, 0, 0, &estimator)); + bound_args.register_paths = SDIS_HEAT_PATH_NONE; + bound_args.nrealisations = N; /* Average temperature on the left+right sides of the box */ prims[0] = 2; @@ -480,13 +522,14 @@ main(int argc, char** argv) ref = (ref + Tb) / 2; - OK(SOLVE(box_scn, N, prims, sides, 4, time_range, 1.0, 0, 0, 0, &estimator)); + bound_args.nprimitives = 4; + OK(SOLVE(box_scn, &bound_args, &estimator)); printf("Average temperature of the left+right sides of the box = "); check_estimator(estimator, N, ref); - OK(GREEN(box_scn, N, prims, sides, 4, 1.0, 0, 0, &green)); + OK(GREEN(box_scn, &bound_args, &green)); check_green_function(green); - OK(sdis_green_function_solve(green, time_range, &estimator2)); + OK(sdis_green_function_solve(green, bound_args.time_range, &estimator2)); check_estimator(estimator2, N, ref); OK(sdis_green_function_ref_put(green)); @@ -496,13 +539,14 @@ main(int argc, char** argv) /* Average temperature on the left+right sides of the square */ prims[0] = 1; prims[1] = 3; - OK(SOLVE(square_scn, N, prims, sides, 2, time_range, 1.0, 0, 0, 0, &estimator)); + bound_args.nprimitives = 2; + OK(SOLVE(square_scn, &bound_args, &estimator)); printf("Average temperature of the left+right sides of the square = "); check_estimator(estimator, N, ref); - OK(GREEN(square_scn, N, prims, sides, 2, 1.0, 0, 0, &green)); + OK(GREEN(square_scn, &bound_args, &green)); check_green_function(green); - OK(sdis_green_function_solve(green, time_range, &estimator2)); + OK(sdis_green_function_solve(green, bound_args.time_range, &estimator2)); check_estimator(estimator2, N, ref); OK(sdis_green_function_ref_put(green));