commit 03868ab2b876c366c7233339b6ebfd1300b16cb7
parent 56a09c32a1e1d4a45476f7d553c3a882ad6e7172
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 16 Oct 2018 11:51:26 +0200
Merge branch 'feature_no_unknown_external_fluid' into develop
Diffstat:
4 files changed, 53 insertions(+), 11 deletions(-)
diff --git a/src/sdis_solve_Xd.h b/src/sdis_solve_Xd.h
@@ -565,10 +565,13 @@ 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_ARG;
}
/* The hc upper bound can be 0 is h is uniformly 0. In that case the result
diff --git a/src/test_sdis_solve_boundary.c b/src/test_sdis_solve_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)
@@ -181,6 +185,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;
@@ -194,8 +199,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;
@@ -294,6 +304,11 @@ main(int argc, char** argv)
check_estimator(estimator, N, ref);
CHK(sdis_estimator_ref_put(estimator) == RES_OK);
+ /* 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_ARG);
+ 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);
@@ -301,6 +316,11 @@ main(int argc, char** argv)
printf("Boundary temperature of the square at (%g %g) = ", SPLIT2(pos));
check_estimator(estimator, N, ref);
CHK(sdis_estimator_ref_put(estimator) == RES_OK);
+
+ /* 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_ARG);
+ fluid_param->temperature = Tf;
#undef F
#undef SOLVE
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_ARG);
+
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_ARG);
+
CHK(sdis_scene_ref_put(scn) == RES_OK);
CHK(sdis_device_ref_put(dev) == RES_OK);