commit 9d1d3f9949a449aabe624e8e149442a2f05e6686
parent 8fa232aee7cc1141261c86d159b3832bdf66f4ae
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 11 Apr 2024 18:34:35 +0200
Get radiative properties depending on the radiation source
Emissivity and specular fraction are now recovered according to the
radiation source, which is internal everywhere except when processing
external flux.
We check this feature by updating the test on external flux calculation.
In this test, the internal radiation source must be deactivated. To do
this, we had set the reference temperature to 0. Now, we set a valid
reference temperature but an emissivity of 0 for the internal radiation
source, which effectively disables its influence.
Diffstat:
8 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/src/sdis_heat_path_boundary_Xd_handle_external_net_flux.h b/src/sdis_heat_path_boundary_Xd_handle_external_net_flux.h
@@ -272,23 +272,27 @@ XD(setup_fragment)
static INLINE res_T
XD(setup_brdf)
(struct sdis_device* dev,
+ const struct sdis_source* src,
struct brdf* brdf,
const struct sdis_interface* interf,
const struct sdis_interface_fragment* frag)
{
double epsilon = 0;
double alpha = 0;
+ unsigned src_id = 0;
res_T res = RES_OK;
ASSERT(brdf && frag);
ASSERT((frag->side == SDIS_FRONT
&& sdis_medium_get_type(interf->medium_front) == SDIS_FLUID)
|| sdis_medium_get_type(interf->medium_back) == SDIS_FLUID);
- epsilon = interface_side_get_emissivity(interf, frag);
+ src_id = sdis_source_get_id(src);
+
+ epsilon = interface_side_get_emissivity(interf, src_id, frag);
res = interface_side_check_emissivity(dev, epsilon, frag->P, frag->time);
if(res != RES_OK) goto error;
- alpha = interface_side_get_specular_fraction(interf, frag);
+ alpha = interface_side_get_specular_fraction(interf, src_id, frag);
res = interface_side_check_specular_fraction(dev, alpha, frag->P, frag->time);
if(res != RES_OK) goto error;
@@ -364,7 +368,7 @@ XD(compute_incident_diffuse_flux)
res = check_interface(interf, &frag);
if(res != RES_OK) goto error;
- XD(setup_brdf)(scn->dev, &brdf, interf, &frag);
+ XD(setup_brdf)(scn->dev, scn->source, &brdf, interf, &frag);
/* Check if path is absorbed */
if(ssp_rng_canonical(rng) < brdf.emissivity) break;
@@ -447,6 +451,7 @@ XD(handle_external_net_flux)
double emissivity = 0; /* Emissivity */
double Ld = 0; /* Incident radiance [W/m^2/sr] */
double cos_theta = 0;
+ unsigned src_id = 0;
int handle_flux = 0;
res_T res = RES_OK;
ASSERT(scn && args && T);
@@ -494,7 +499,8 @@ XD(handle_external_net_flux)
incident_flux = incident_flux_direct + incident_flux_diffuse; /* [W/m^2] */
/* Calculate the net flux */
- emissivity = interface_side_get_emissivity(args->interf, &frag);
+ src_id = sdis_source_get_id(scn->source);
+ emissivity = interface_side_get_emissivity(args->interf, src_id, &frag);
res = interface_side_check_emissivity(scn->dev, emissivity, frag.P, frag.time);
if(res != RES_OK) goto error;
net_flux = incident_flux * emissivity; /* [W/m^2] */
diff --git a/src/sdis_heat_path_boundary_Xd_solid_fluid_picard1.h b/src/sdis_heat_path_boundary_Xd_solid_fluid_picard1.h
@@ -159,7 +159,8 @@ XD(solid_fluid_boundary_picard1_path)
delta = solid_get_delta(solid, &rwalk->vtx);
/* Fetch the boundary emissivity */
- epsilon = interface_side_get_emissivity(interf, &frag_fluid);
+ epsilon = interface_side_get_emissivity
+ (interf, SDIS_INTERN_SOURCE_ID, &frag_fluid);
if(epsilon <= 0) {
Tref = 0;
diff --git a/src/sdis_heat_path_boundary_Xd_solid_fluid_picardN.h b/src/sdis_heat_path_boundary_Xd_solid_fluid_picardN.h
@@ -209,7 +209,8 @@ XD(solid_fluid_boundary_picardN_path)
delta = solid_get_delta(solid, &rwalk->vtx);
/* Fetch the boundary emissivity */
- epsilon = interface_side_get_emissivity(interf, &frag_fluid);
+ epsilon = interface_side_get_emissivity
+ (interf, SDIS_INTERN_SOURCE_ID, &frag_fluid);
/* Note that the reinjection distance is *FIXED*. It MUST ensure that the
* orthogonal distance from the boundary to the reinjection point is at most
diff --git a/src/sdis_heat_path_radiative_Xd.h b/src/sdis_heat_path_radiative_Xd.h
@@ -143,7 +143,7 @@ XD(trace_radiative_path)
XD(setup_interface_fragment)(&frag, &rwalk->vtx, &rwalk->hit, rwalk->hit_side);
/* Fetch the interface emissivity */
- epsilon = interface_side_get_emissivity(interf, &frag);
+ epsilon = interface_side_get_emissivity(interf, SDIS_INTERN_SOURCE_ID, &frag);
if(epsilon > 1 || epsilon < 0) {
log_err(scn->dev,
"%s: invalid overall emissivity `%g' at position `%g %g %g'.\n",
@@ -185,7 +185,7 @@ XD(trace_radiative_path)
goto error;
}
}
- alpha = interface_side_get_specular_fraction(interf, &frag);
+ alpha = interface_side_get_specular_fraction(interf, SDIS_INTERN_SOURCE_ID, &frag);
r = ssp_rng_canonical(rng);
if(r < alpha) { /* Sample specular part */
reflect_3d(dir, f3_minus(dir, dir), N);
diff --git a/src/sdis_interface_c.h b/src/sdis_interface_c.h
@@ -143,6 +143,7 @@ interface_side_get_flux
static INLINE double
interface_side_get_emissivity
(const struct sdis_interface* interf,
+ const unsigned source_id,
const struct sdis_interface_fragment* frag)
{
const struct sdis_interface_side_shader* shader;
@@ -153,13 +154,14 @@ interface_side_get_emissivity
default: FATAL("Unreachable code\n"); break;
}
return shader->emissivity
- ? shader->emissivity(frag, SDIS_INTERN_SOURCE_ID, interf->data)
+ ? shader->emissivity(frag, source_id, interf->data)
: 0;
}
static INLINE double
interface_side_get_specular_fraction
(const struct sdis_interface* interf,
+ const unsigned source_id,
const struct sdis_interface_fragment* frag)
{
const struct sdis_interface_side_shader* shader;
@@ -170,7 +172,7 @@ interface_side_get_specular_fraction
default: FATAL("Unreachable code\n"); break;
}
return shader->specular_fraction
- ? shader->specular_fraction(frag, SDIS_INTERN_SOURCE_ID, interf->data)
+ ? shader->specular_fraction(frag, source_id, interf->data)
: 0;
}
diff --git a/src/sdis_solve_boundary_Xd.h b/src/sdis_solve_boundary_Xd.h
@@ -784,7 +784,7 @@ XD(solve_boundary_flux)
if(res_local!= RES_OK) { ATOMIC_SET(&res, res_local); continue; }
/* Fetch interface parameters */
- epsilon = interface_side_get_emissivity(interf, &frag);
+ epsilon = interface_side_get_emissivity(interf, SDIS_INTERN_SOURCE_ID, &frag);
hc = interface_get_convection_coef(interf, &frag);
Tref = interface_side_get_reference_temperature(interf, &frag);
if(epsilon <= 0) {
diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h
@@ -880,7 +880,8 @@ XD(solve_probe_boundary_flux)
/* Compute hr and hc */
frag_local.time = time;
frag_local.side = fluid_side;
- epsilon = interface_side_get_emissivity(interf, &frag_local);
+ epsilon = interface_side_get_emissivity
+ (interf, SDIS_INTERN_SOURCE_ID, &frag_local);
Tref = interface_side_get_reference_temperature(interf, &frag_local);
hc = interface_get_convection_coef(interf, &frag_local);
if(epsilon <= 0) {
diff --git a/src/test_sdis_external_flux.c b/src/test_sdis_external_flux.c
@@ -45,7 +45,7 @@
*/
#define T_FLUID 300.0 /* [K] */
-#define T_REF 0 /* [K] */
+#define T_REF 300.0 /* [K] */
/*******************************************************************************
* Geometries
@@ -202,7 +202,7 @@ INTERF_PROP(reference_temperature, T_REF) /* [K] */
struct interface* interf_data = NULL; \
(void)frag, (void)source_id; /* Avoid the "unused variable" warning */ \
interf_data = sdis_data_get(data); \
- return interf_data->Prop; \
+ return source_id == SDIS_INTERN_SOURCE_ID ? 0 : interf_data->Prop; \
}
INTERF_PROP(emissivity)
INTERF_PROP(specular_fraction)