stardis-solver

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

commit 4941494975c3e111a251ab94284976f867aaf38b
parent f64caf42c080429a897bd09a03dcfbb008d712f1
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu,  3 Sep 2020 09:46:16 +0200

Rename mean_power in power

Diffstat:
Msrc/sdis.h | 20++++++++++----------
Msrc/sdis_estimator.c | 18+++++++++---------
Msrc/sdis_estimator_c.h | 16++++++++--------
Msrc/sdis_heat_path_boundary_Xd.h | 3+--
Msrc/sdis_solve.c | 8++++----
Msrc/sdis_solve_medium_Xd.h | 8++++----
Msrc/test_sdis_compute_mean_power.c | 44++++++++++++++++++++++----------------------
Msrc/test_sdis_utils.h | 12++++++------
8 files changed, 64 insertions(+), 65 deletions(-)

diff --git a/src/sdis.h b/src/sdis.h @@ -116,7 +116,7 @@ static const struct sdis_interface_fragment SDIS_INTERFACE_FRAGMENT_NULL = enum sdis_estimator_type { SDIS_ESTIMATOR_TEMPERATURE, /* In Kelvin */ SDIS_ESTIMATOR_FLUX, /* In Watt/m^2 */ - SDIS_ESTIMATOR_MEAN_POWER, /* In Watt */ + SDIS_ESTIMATOR_POWER, /* In Watt */ SDIS_ESTIMATOR_TYPES_COUNT__ }; @@ -503,22 +503,22 @@ struct sdis_solve_camera_args { static const struct sdis_solve_camera_args SDIS_SOLVE_CAMERA_ARGS_DEFAULT = SDIS_SOLVE_CAMERA_ARGS_DEFAULT__; -struct sdis_compute_mean_power_args { +struct sdis_compute_power_args { size_t nrealisations; struct sdis_medium* medium; /* Medium to solve */ double time_range[2]; /* Observation time */ double fp_to_meter; /* Scale from floating point units to meters */ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ }; -#define SDIS_COMPUTE_MEAN_POWER_ARGS_DEFAULT__ { \ +#define SDIS_COMPUTE_POWER_ARGS_DEFAULT__ { \ 10000, /* #realisations */ \ NULL, /* Medium */ \ {DBL_MAX,DBL_MAX}, /* Time range */ \ 1, /* FP to meter */ \ NULL /* RNG state */ \ } -static const struct sdis_compute_mean_power_args -SDIS_COMPUTE_MEAN_POWER_ARGS_DEFAULT = SDIS_COMPUTE_MEAN_POWER_ARGS_DEFAULT__; +static const struct sdis_compute_power_args +SDIS_COMPUTE_POWER_ARGS_DEFAULT = SDIS_COMPUTE_POWER_ARGS_DEFAULT__; BEGIN_DECLS @@ -945,9 +945,9 @@ sdis_estimator_get_total_flux struct sdis_mc* flux); SDIS_API res_T -sdis_estimator_get_mean_power +sdis_estimator_get_power (const struct sdis_estimator* estimator, - struct sdis_mc* mean_power); + struct sdis_mc* power); SDIS_API res_T sdis_estimator_get_paths_count @@ -1133,12 +1133,12 @@ sdis_solve_medium struct sdis_estimator** estimator); /* P = SUM(volumic_power(x)) / Nrealisations * Volume - * mean power (in Watt) = time_range[0] == time_range[1] + * power (in Watt) = time_range[0] == time_range[1] * ? P : P / (time_range[1] - time_range[0]) */ SDIS_API res_T -sdis_compute_mean_power +sdis_compute_power (struct sdis_scene* scn, - const struct sdis_compute_mean_power_args* args, + const struct sdis_compute_power_args* args, struct sdis_estimator** estimator); /******************************************************************************* diff --git a/src/sdis_estimator.c b/src/sdis_estimator.c @@ -146,18 +146,18 @@ sdis_estimator_get_total_flux } res_T -sdis_estimator_get_mean_power - (const struct sdis_estimator* estimator, struct sdis_mc* mean_power) +sdis_estimator_get_power + (const struct sdis_estimator* estimator, struct sdis_mc* power) { - if(!estimator || !mean_power || estimator->type != SDIS_ESTIMATOR_MEAN_POWER) + if(!estimator || !power || estimator->type != SDIS_ESTIMATOR_POWER) return RES_BAD_ARG; - SETUP_MC(mean_power, &estimator->mean_power.power); - mean_power->E *= estimator->mean_power.spread; + SETUP_MC(power, &estimator->power.power); + power->E *= estimator->power.spread; - if(estimator->mean_power.time_range[0] - != estimator->mean_power.time_range[1]) { - mean_power->E /= /* From Joule to Watt */ - (estimator->mean_power.time_range[1]-estimator->mean_power.time_range[0]); + if(estimator->power.time_range[0] + != estimator->power.time_range[1]) { + power->E /= /* From Joule to Watt */ + (estimator->power.time_range[1]-estimator->power.time_range[0]); } return RES_OK; } diff --git a/src/sdis_estimator_c.h b/src/sdis_estimator_c.h @@ -44,7 +44,7 @@ struct sdis_estimator { struct accum power; double spread; double time_range[2]; - } mean_power; + } power; size_t nrealisations; /* #successes */ size_t nfailures; @@ -105,7 +105,7 @@ estimator_setup_temperature } static INLINE void -estimator_setup_mean_power +estimator_setup_power (struct sdis_estimator* estim, const double sum, const double sum2, @@ -113,12 +113,12 @@ estimator_setup_mean_power const double time_range[2]) { ASSERT(estim && estim->nrealisations && time_range); - estim->mean_power.power.sum = sum; - estim->mean_power.power.sum2 = sum2; - estim->mean_power.power.count = estim->nrealisations; - estim->mean_power.spread = spread; - estim->mean_power.time_range[0] = time_range[0]; - estim->mean_power.time_range[1] = time_range[1]; + estim->power.power.sum = sum; + estim->power.power.sum2 = sum2; + estim->power.power.count = estim->nrealisations; + estim->power.spread = spread; + estim->power.time_range[0] = time_range[0]; + estim->power.time_range[1] = time_range[1]; } static INLINE void diff --git a/src/sdis_heat_path_boundary_Xd.h b/src/sdis_heat_path_boundary_Xd.h @@ -926,7 +926,6 @@ XD(solid_boundary_with_flux_path) rwalk->mdm = mdm; rwalk->hit = SXD_HIT_NULL; rwalk->hit_side = SDIS_SIDE_NULL__; - } /* Register the new vertex against the heat path */ @@ -990,7 +989,7 @@ XD(boundary_path) /* Check if the boundary flux is known. Note that currently, only solid media * can have a flux as limit condition */ mdm = interface_get_medium(interf, frag.side); - if(sdis_medium_get_type(mdm) == SDIS_SOLID ) { + if(sdis_medium_get_type(mdm) == SDIS_SOLID) { const double phi = interface_side_get_flux(interf, &frag); if(phi != SDIS_FLUX_NONE) { res = XD(solid_boundary_with_flux_path) diff --git a/src/sdis_solve.c b/src/sdis_solve.c @@ -541,15 +541,15 @@ sdis_solve_medium_green_function } res_T -sdis_compute_mean_power +sdis_compute_power (struct sdis_scene* scn, - const struct sdis_compute_mean_power_args* args, + const struct sdis_compute_power_args* args, struct sdis_estimator** estimator) { if(!scn) return RES_BAD_ARG; if(scene_is_2d(scn)) { - return compute_mean_power_2d(scn, args, estimator); + return compute_power_2d(scn, args, estimator); } else { - return compute_mean_power_3d(scn, args, estimator); + return compute_power_3d(scn, args, estimator); } } diff --git a/src/sdis_solve_medium_Xd.h b/src/sdis_solve_medium_Xd.h @@ -478,9 +478,9 @@ error: } static res_T -XD(compute_mean_power) +XD(compute_power) (struct sdis_scene* scn, - const struct sdis_compute_mean_power_args* args, + const struct sdis_compute_power_args* args, struct sdis_estimator** out_estimator) { struct darray_enclosure_cumul cumul; @@ -563,7 +563,7 @@ XD(compute_mean_power) [darray_enclosure_cumul_size_get(&cumul)-1].cumul; /* Create the estimator */ - res = estimator_create(scn->dev, SDIS_ESTIMATOR_MEAN_POWER, &estimator); + res = estimator_create(scn->dev, SDIS_ESTIMATOR_POWER, &estimator); if(res != RES_OK) goto error; nrealisations = args->nrealisations; @@ -640,7 +640,7 @@ XD(compute_mean_power) estimator_setup_realisations_count(estimator, nrealisations, acc_mpow.count); estimator_setup_realisation_time(estimator, acc_time.sum, acc_time.sum2); - estimator_setup_mean_power + estimator_setup_power (estimator, acc_mpow.sum, acc_mpow.sum2, spread, args->time_range); res = estimator_save_rng_state(estimator, rng_proxy); if(res != RES_OK) goto error; diff --git a/src/test_sdis_compute_mean_power.c b/src/test_sdis_compute_mean_power.c @@ -182,7 +182,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 interf_shader = SDIS_INTERFACE_SHADER_NULL; - struct sdis_compute_mean_power_args args = SDIS_COMPUTE_MEAN_POWER_ARGS_DEFAULT; + struct sdis_compute_power_args args = SDIS_COMPUTE_POWER_ARGS_DEFAULT; size_t nverts = 0; size_t ntris = 0; double ref = 0; @@ -229,35 +229,35 @@ main(int argc, char** argv) OK(sdis_scene_create(dev, ntris, get_indices, get_interface, nverts, get_position, &ctx, &scn)); - /* Test sdis_compute_mean_power function */ + /* Test sdis_compute_power function */ args.nrealisations = N; args.medium = solid0; args.time_range[0] = INF; args.time_range[1] = INF; - BA(sdis_compute_mean_power(NULL, &args, &estimator)); - BA(sdis_compute_mean_power(scn, NULL, &estimator)); - BA(sdis_compute_mean_power(scn, &args, NULL)); + 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_mean_power(scn, &args, &estimator)); + BA(sdis_compute_power(scn, &args, &estimator)); args.nrealisations = N; args.medium = NULL; - BA(sdis_compute_mean_power(scn, &args, &estimator)); + BA(sdis_compute_power(scn, &args, &estimator)); args.medium = solid0; args.fp_to_meter = 0; - BA(sdis_compute_mean_power(scn, &args, &estimator)); + BA(sdis_compute_power(scn, &args, &estimator)); args.fp_to_meter = 1; args.time_range[0] = args.time_range[1] = -1; - BA(sdis_compute_mean_power(scn, &args, &estimator)); + BA(sdis_compute_power(scn, &args, &estimator)); args.time_range[0] = 1; - BA(sdis_compute_mean_power(scn, &args, &estimator)); + BA(sdis_compute_power(scn, &args, &estimator)); args.time_range[1] = 0; - BA(sdis_compute_mean_power(scn, &args, &estimator)); + BA(sdis_compute_power(scn, &args, &estimator)); args.time_range[0] = args.time_range[1] = INF; - OK(sdis_compute_mean_power(scn, &args, &estimator)); + OK(sdis_compute_power(scn, &args, &estimator)); - BA(sdis_estimator_get_mean_power(NULL, &mpow)); - BA(sdis_estimator_get_mean_power(estimator, NULL)); - OK(sdis_estimator_get_mean_power(estimator, &mpow)); + 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 */ @@ -269,8 +269,8 @@ main(int argc, char** argv) /* Check results for solid 1 */ args.medium = solid1; - OK(sdis_compute_mean_power(scn, &args, &estimator)); - OK(sdis_estimator_get_mean_power(estimator, &mpow)); + 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); @@ -280,8 +280,8 @@ main(int argc, char** argv) /* Check for a not null time range */ args.time_range[0] = 0; args.time_range[1] = 10; - OK(sdis_compute_mean_power(scn, &args, &estimator)); - OK(sdis_estimator_get_mean_power(estimator, &mpow)); + 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); @@ -298,12 +298,12 @@ main(int argc, char** argv) /* Check invalid medium */ args.time_range[0] = args.time_range[1] = 1; args.medium = solid1; - BA(sdis_compute_mean_power(scn, &args, &estimator)); + BA(sdis_compute_power(scn, &args, &estimator)); /* Check non constant volumic power */ args.medium = solid0; - OK(sdis_compute_mean_power(scn, &args, &estimator)); - OK(sdis_estimator_get_mean_power(estimator, &mpow)); + 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); diff --git a/src/test_sdis_utils.h b/src/test_sdis_utils.h @@ -277,9 +277,9 @@ check_estimator_eq CHK(mc1.E - 3*mc1.SE <= mc2.E + 3*mc2.SE); break; - case SDIS_ESTIMATOR_MEAN_POWER: - OK(sdis_estimator_get_mean_power(e1, &mc1)); - OK(sdis_estimator_get_mean_power(e2, &mc2)); + case SDIS_ESTIMATOR_POWER: + OK(sdis_estimator_get_power(e1, &mc1)); + OK(sdis_estimator_get_power(e2, &mc2)); CHK(mc1.E + 3*mc1.SE >= mc2.E - 3*mc2.SE); CHK(mc1.E - 3*mc1.SE <= mc2.E + 3*mc2.SE); break; @@ -321,9 +321,9 @@ check_estimator_eq_strict CHK(mc1.E == mc2.E && mc1.V == mc2.V && mc1.SE == mc2.SE); break; - case SDIS_ESTIMATOR_MEAN_POWER: - OK(sdis_estimator_get_mean_power(e1, &mc1)); - OK(sdis_estimator_get_mean_power(e2, &mc2)); + case SDIS_ESTIMATOR_POWER: + OK(sdis_estimator_get_power(e1, &mc1)); + OK(sdis_estimator_get_power(e2, &mc2)); CHK(mc1.E == mc2.E && mc1.V == mc2.V && mc1.SE == mc2.SE); break;