commit f3b82059a3b066678ecf9ff63b30f2d474350530
parent 500a3d18b2eca9176573552f48a22fe16c055c20
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Fri, 12 Oct 2018 12:19:14 +0200
Detect and report an external fluid with unknown temperature.
Diffstat:
5 files changed, 54 insertions(+), 14 deletions(-)
diff --git a/src/sdis_solve.c b/src/sdis_solve.c
@@ -262,7 +262,7 @@ exit:
}
if(rng_proxy) SSP(rng_proxy_ref_put(rng_proxy));
if(out_estimator) *out_estimator = estimator;
- return (res_T)res;
+ return (res_T)(res == RES_BAD_OP_IRRECOVERABLE ? RES_BAD_OP : res);
error:
if(estimator) {
SDIS(estimator_ref_put(estimator));
@@ -406,7 +406,7 @@ exit:
}
if(rng_proxy) SSP(rng_proxy_ref_put(rng_proxy));
if(out_estimator) *out_estimator = estimator;
- return (res_T)res;
+ return (res_T)(res == RES_BAD_OP_IRRECOVERABLE ? RES_BAD_OP : res);
error:
if(estimator) {
SDIS(estimator_ref_put(estimator));
diff --git a/src/sdis_solve_Xd.h b/src/sdis_solve_Xd.h
@@ -500,10 +500,12 @@ XD(fluid_temperature)
/* Fetch the enclosure data */
enc = scene_get_enclosure(scn, enc_id);
if(!enc) {
+ /* The possibility for a fluid enclosure to be unregistred is that it is
+ * the external enclosure. In this situation unknown temperature is forbidden. */
log_err(scn->dev,
-"%s: invalid enclosure. The position %g %g %g may lie in the surrounding fluid.\n",
- FUNC_NAME, SPLIT3(rwalk->vtx.P));
- return RES_BAD_OP;
+"%s: invalid enclosure. The surrounding fluid has an unset temperature.\n",
+ FUNC_NAME);
+ return RES_BAD_OP_IRRECOVERABLE;
}
/* The hc upper bound can be 0 is h is uniformly 0. In that case the result
@@ -1341,7 +1343,7 @@ exit:
#ifndef NDEBUG
sa_release(stack);
#endif
- return res == RES_BAD_OP_IRRECOVERABLE ? RES_BAD_OP : res;
+ return res;
error:
goto exit;
}
diff --git a/src/test_sdis_solve_probe.c b/src/test_sdis_solve_probe.c
@@ -289,12 +289,16 @@ main(int argc, char** argv)
CHK(nfails < N/1000);
CHK(eq_eps(T.E, ref, T.SE));
- CHK(sdis_estimator_ref_get(NULL) == RES_BAD_ARG);
+ CHK(sdis_estimator_ref_get(NULL) == RES_BAD_ARG);
CHK(sdis_estimator_ref_get(estimator) == RES_OK);
CHK(sdis_estimator_ref_put(NULL) == RES_BAD_ARG);
CHK(sdis_estimator_ref_put(estimator) == RES_OK);
CHK(sdis_estimator_ref_put(estimator) == RES_OK);
+ /* The external fluid cannot have an unknown temperature */
+ fluid_param->temperature = -1;
+ CHK(sdis_solve_probe(scn, N, pos, time, 1.0, 0, 0, &estimator) == RES_BAD_OP);
+
CHK(sdis_scene_ref_put(scn) == RES_OK);
CHK(sdis_device_ref_put(dev) == RES_OK);
diff --git a/src/test_sdis_solve_probe_2d.c b/src/test_sdis_solve_probe_2d.c
@@ -67,12 +67,16 @@ get_interface(const size_t iseg, struct sdis_interface** bound, void* context)
/*******************************************************************************
* Media & interface
******************************************************************************/
+struct fluid {
+ double temperature;
+};
+
static double
fluid_get_temperature
(const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
{
- (void)vtx, (void)data;
- return 300.0;
+ CHK(data != NULL && vtx != NULL);
+ return ((const struct fluid*)sdis_data_cget(data))->temperature;
}
static double
@@ -136,11 +140,13 @@ main(int argc, char** argv)
struct sdis_medium* fluid = NULL;
struct sdis_interface* interf = NULL;
struct sdis_scene* scn = NULL;
+ struct sdis_data* data = NULL;
struct sdis_estimator* estimator = NULL;
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 context ctx;
+ struct fluid* fluid_param;
double pos[2];
double time;
double ref;
@@ -154,8 +160,13 @@ main(int argc, char** argv)
(NULL, &allocator, SDIS_NTHREADS_DEFAULT, 1, &dev) == RES_OK);
/* Create the fluid medium */
+ CHK(sdis_data_create
+ (dev, sizeof(struct fluid), ALIGNOF(struct fluid), NULL, &data) == RES_OK);
+ fluid_param = sdis_data_get(data);
+ fluid_param->temperature = 300;
fluid_shader.temperature = fluid_get_temperature;
- CHK(sdis_fluid_create(dev, &fluid_shader, NULL, &fluid) == RES_OK);
+ CHK(sdis_fluid_create(dev, &fluid_shader, data, &fluid) == RES_OK);
+ CHK(sdis_data_ref_put(data) == RES_OK);
/* Create the solid medium */
solid_shader.calorific_capacity = solid_get_calorific_capacity;
@@ -206,6 +217,10 @@ main(int argc, char** argv)
CHK(sdis_estimator_ref_put(estimator) == RES_OK);
+ /* The external fluid cannot have an unknown temperature */
+ fluid_param->temperature = -1;
+ CHK(sdis_solve_probe(scn, N, pos, time, 1.0, 0, 0, &estimator) == RES_BAD_OP);
+
CHK(sdis_scene_ref_put(scn) == RES_OK);
CHK(sdis_device_ref_put(dev) == RES_OK);
diff --git a/src/test_sdis_solve_probe_boundary.c b/src/test_sdis_solve_probe_boundary.c
@@ -53,15 +53,19 @@
/*******************************************************************************
* Media
******************************************************************************/
+struct fluid {
+ double temperature;
+};
+
static double
fluid_get_temperature
(const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
{
- (void)data;
- CHK(vtx != NULL);
- return Tf;
+ CHK(data != NULL && vtx != NULL);
+ return ((const struct fluid*)sdis_data_cget(data))->temperature;
}
+
static double
solid_get_calorific_capacity
(const struct sdis_rwalk_vertex* vtx, struct sdis_data* data)
@@ -157,6 +161,7 @@ main(int argc, char** argv)
struct sdis_interface* box_interfaces[12 /*#triangles*/];
struct sdis_interface* square_interfaces[4/*#segments*/];
struct interf* interf_props = NULL;
+ struct fluid* fluid_param;
double uv[2];
double pos[3];
double ref;
@@ -170,8 +175,13 @@ main(int argc, char** argv)
(NULL, &allocator, SDIS_NTHREADS_DEFAULT, 1, &dev) == RES_OK);
/* Create the fluid medium */
+ CHK(sdis_data_create
+ (dev, sizeof(struct fluid), ALIGNOF(struct fluid), NULL, &data) == RES_OK);
+ fluid_param = sdis_data_get(data);
+ fluid_param->temperature = Tf;
fluid_shader.temperature = fluid_get_temperature;
- CHK(sdis_fluid_create(dev, &fluid_shader, NULL, &fluid) == RES_OK);
+ CHK(sdis_fluid_create(dev, &fluid_shader, data, &fluid) == RES_OK);
+ CHK(sdis_data_ref_put(data) == RES_OK);
/* Create the solid_medium */
solid_shader.calorific_capacity = solid_get_calorific_capacity;
@@ -277,6 +287,11 @@ main(int argc, char** argv)
CHK(nfails < N/1000);
CHK(eq_eps(T.E, ref, 3*T.SE));
+ /* The external fluid cannot have an unknown temperature */
+ fluid_param->temperature = UNKNOWN_TEMPERATURE;
+ CHK(SOLVE(box_scn, N, iprim, uv, INF, F, 1.0, 0, 0, &estimator) == RES_BAD_OP);
+ fluid_param->temperature = Tf;
+
uv[0] = 0.5;
iprim = 3;
CHK(SOLVE(square_scn, N, iprim, uv, INF, F, 1.0, 0, 0, &estimator) == RES_OK);
@@ -291,6 +306,10 @@ main(int argc, char** argv)
CHK(nfails + nreals == N);
CHK(nfails < N/1000);
CHK(eq_eps(T.E, ref, 3*T.SE));
+
+ /* The external fluid cannot have an unknown temperature */
+ fluid_param->temperature = UNKNOWN_TEMPERATURE;
+ CHK(SOLVE(square_scn, N, iprim, uv, INF, F, 1.0, 0, 0, &estimator) == RES_BAD_OP);
#undef SOLVE
CHK(sdis_scene_ref_put(box_scn) == RES_OK);