commit ca648a5dd0750769ac15fd7a0d00daa75b146a51
parent 639493a1e0a98f39e7b108977ba192d0626e4149
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 5 Sep 2025 11:24:54 +0200
Add a new solid/fluid connection with imposed flux
The new input directive F_SOLID_FLUID_CONNECTION describes a connection
between a solid and a fluid with an imposed flux on their common
interface. In reality, the flux could be a parameter of the normal
solid/fluid connection, with a value of NONE when no flux is imposed.
However, this would break compatibility with previous input files. Hence
the use of a new keyword inspired by the naming convention used in
boundary conditions.
The F_SOLID_FLUID_CONNECTION_PROG directive describes the same type of
connection, but with programmable arguments. In reality, this keyword is
redundant with SOLID_FLUID_CONNECTION_PROG: the caller could provide the
function returning a flux depending on whether a flux is actually
imposed on the interface or not. But this would break the symmetry with
other connection types that provide two keywords: one for constant
properties and one for programmable properties.
In other words, the two new keywords can describe a fluid-solid
connection more generally. They support regular fluid-solid connection
with the possibility of imposing a flux on it. The previous directives
are mainly retained for backward compatibility reasons.
Internally, there is no reason to differentiate between connections
between solids and fluids based on whether a flux is imposed or not. A
new "flux" variable is therefore added to the structures defining this
type of connection. Its value is simply set to "no flux" if no flux is
imposed.
Diffstat:
7 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/doc/stardis-input.5.in b/doc/stardis-input.5.in
@@ -185,8 +185,11 @@ that changes at
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.Ss Connection
.Bl -column (description-line) (::) ()
-.It Ao Va connection Ac Ta ::= Ta Ao Va solid-fluid Ac | Ao Va solid-solid Ac
+.It Ao Va connection Ac Ta ::= Ta Ao Va solid-fluid Ac
+.It Ta \& \& | Ta Ao Va solid-solid Ac
+.It Ta \& \& | Ta Ao Va solid-fluid-flux Ac
.It \ Ta Ta
+.\" Solid/fluid connection
.It Ao Va solid-fluid Ac Ta ::= Ta Ao Va solid-fluid-const Ac | Ao Va solid-fluid-prog Ac
.It Ao Va solid-fluid-const Ac Ta ::= Ta Li SOLID_FLUID_CONNECTION Ao Va connect-name Ac \e
.It Ta Ta Ao Va Tref Ac Ao Va emissivity Ac Ao Va specular-fraction Ac \e
@@ -194,12 +197,22 @@ that changes at
.It Ao Va solid-fluid-prog Ac Ta ::= Ta Li SOLID_FLUID_CONNECTION_PROG \e
.It Ta Ta Ao Va connect-name Ac Ao Va prog-desc Ac
.It \ Ta Ta
+.\" Solid/solid connection
.It Ao Va solid-solid Ac Ta ::= Ta Ao Va solid-solid-const Ac | Ao Va solid-solid-prog Ac
.It Ao Va solid-solid-const Ac Ta ::= Ta Li SOLID_SOLID_CONNECTION Ao Va connect-name Ac \e
.It Ta Ta Ao Va contact-resistance Ac Ao Va triangles Ac ...
.It Ao Va solid-solid-prog Ac Ta ::= Ta Li SOLID_SOLID_CONNECTION_PROG \e
.It Ta Ta Ao Va connect-name Ac Ao Va prog-desc Ac
.It \ Ta Ta
+.\" Solid/fluid connection with flux
+.It Ao Va solid-fluid-flux Ac Ta :: Ta Ao Va sf-flux-const Ac | Ao Va s-flux-prog Ac
+.It Ao Va sf-flux-const Ac Ta :: Ta Li F_SOLID_FLUID_CONNECTION Ao Va connect-name Ac \e
+.It Ta Ta Ao Va Tref Ac Ao Va emissivity Ac Ao Va specular-fraction Ac \e
+.It Ta Ta Ao Va hc Ac Ao Va flux Ac Ao Va triangles Ac ...
+.It Ao Va sf-flux-prog Ac Ta :: Ta Li F_SOLID_FLUID_CONNECTION_PROG \e
+.It Ta Ta Ao Va connect-name Ac Ao Va prog-desc Ac
+.It \ Ta Ta
+.\" Miscellaneous
.It Ao Va emissivity Ac Ta ::= Ta Vt real No # \&In [0,1]
.It Ao Va specular-fraction Ac Ta ::= Ta Vt real No # \&In [0,1]
.It Ao Va hc Ac Ta ::= Ta Vt real No # Convective coefficient > 0 [W/m^2/K]
diff --git a/src/stardis-intface.c b/src/stardis-intface.c
@@ -650,9 +650,14 @@ create_intface
interface_props->ref_temperature = intface->d.sf_connect->ref_temperature;
interface_props->emissivity = intface->d.sf_connect->emissivity;
interface_props->alpha = intface->d.sf_connect->specular_fraction;
+ interface_props->imposed_flux = intface->d.sf_connect->flux;
if(intface->d.sf_connect->hc > 0) {
interface_shader.convection_coef = interface_get_convection_coef;
}
+ if(intface->d.sf_connect->flux != SDIS_FLUX_NONE) {
+ interface_shader.front.flux = interface_get_flux;
+ interface_shader.back.flux = interface_get_flux;
+ }
ASSERT(fluid_side_shader);
fluid_side_shader->reference_temperature = interface_get_ref_temperature;
fluid_side_shader->specular_fraction = interface_get_alpha;
@@ -679,6 +684,10 @@ create_intface
= intface->d.sf_connect_prog->emissivity;
interface_props->get_alpha = intface->d.sf_connect_prog->alpha;
interface_shader.convection_coef = intface_prog_get_hc;
+ if(intface->d.sf_connect_prog->flux) {
+ interface_shader.front.flux = intface_prog_get_flux;
+ interface_shader.back.flux = intface_prog_get_flux;
+ }
ASSERT(fluid_side_shader);
fluid_side_shader->emissivity = intface_prog_get_emissivity;
fluid_side_shader->specular_fraction = intface_prog_get_alpha;
diff --git a/src/stardis-parsing.c b/src/stardis-parsing.c
@@ -1292,6 +1292,7 @@ error:
static res_T
process_sfc
(struct stardis* stardis,
+ const int with_flux,
wordexp_t* pwordexp)
{
char* arg = NULL;
@@ -1364,6 +1365,16 @@ process_sfc
goto error;
}
+ if(with_flux) {
+ CHK_ARG(idx, "flux");
+ res = cstr_to_double(arg, &sf_connect->flux);
+ if(res != RES_OK) {
+ logger_print(stardis->logger, LOG_ERROR,
+ "Invalid flux: %s\n", arg);
+ goto error;
+ }
+ }
+
ASSERT(sz <= UINT_MAX);
ERR(read_sides_and_files(stardis, 1, (unsigned)sz, pwordexp, &idx));
@@ -1377,6 +1388,7 @@ error:
static res_T
process_sfc_prog
(struct stardis* stardis,
+ const int with_flux,
wordexp_t* pwordexp)
{
char* arg = NULL;
@@ -1429,6 +1441,9 @@ process_sfc_prog
GET_LIB_SYMBOL(sf_connect_prog, hc, stardis_convection_coefficient);
GET_LIB_SYMBOL(sf_connect_prog, hmax, stardis_max_convection_coefficient);
GET_LIB_SYMBOL(sf_connect_prog, t_range, stardis_t_range);
+ if(with_flux) {
+ GET_LIB_SYMBOL(sf_connect_prog, flux, stardis_boundary_flux);
+ }
/* create and init custom data */
ctx.name = desc_name;
CREATE_DESC_DATA(sf_connect_prog);
@@ -2330,9 +2345,13 @@ process_model_line
else if(0 == strcasecmp(arg, "F_BOUNDARY_FOR_SOLID_PROG"))
ERR(process_flx_prog(stardis, pwordexp));
else if(0 == strcasecmp(arg, "SOLID_FLUID_CONNECTION"))
- ERR(process_sfc(stardis, pwordexp));
+ ERR(process_sfc(stardis, 0/* No flux*/, pwordexp));
+ else if(0 == strcasecmp(arg, "F_SOLID_FLUID_CONNECTION"))
+ ERR(process_sfc(stardis, 1/* Flux */, pwordexp));
else if(0 == strcasecmp(arg, "SOLID_FLUID_CONNECTION_PROG"))
- ERR(process_sfc_prog(stardis, pwordexp));
+ ERR(process_sfc_prog(stardis, 0/* No flux*/, pwordexp));
+ else if(0 == strcasecmp(arg, "F_SOLID_FLUID_CONNECTION_PROG"))
+ ERR(process_sfc_prog(stardis, 1/* Flux */, pwordexp));
else if(0 == strcasecmp(arg, "SOLID_SOLID_CONNECTION"))
ERR(process_ssc(stardis, pwordexp));
else if(0 == strcasecmp(arg, "SOLID_SOLID_CONNECTION_PROG"))
diff --git a/src/stardis-sfconnect-prog.c b/src/stardis-sfconnect-prog.c
@@ -105,4 +105,3 @@ sf_connect_prog_get_hmax
{
return connect->hmax(connect->prog_data);
}
-
diff --git a/src/stardis-sfconnect-prog.h b/src/stardis-sfconnect-prog.h
@@ -48,6 +48,7 @@ struct solid_fluid_connect_prog {
double (*alpha)
(const struct stardis_interface_fragment*, const unsigned src_id, void*);
double (*hc)(const struct stardis_interface_fragment*, void*);
+ double (*flux)(const struct stardis_interface_fragment*, void*);
double (*hmax)(void*);
double* (*t_range)(void*, double trange[2]);
};
diff --git a/src/stardis-sfconnect.c b/src/stardis-sfconnect.c
@@ -43,6 +43,7 @@ init_sf_connect
str_init(allocator, &(*dst)->name);
str_initialized = 1;
(*dst)->connection_id = UINT_MAX;
+ (*dst)->flux = SDIS_FLUX_NONE;
end:
return res;
error:
diff --git a/src/stardis-sfconnect.h b/src/stardis-sfconnect.h
@@ -31,6 +31,7 @@ struct solid_fluid_connect {
double emissivity;
double specular_fraction;
double hc;
+ double flux; /* [W/m^2] */
unsigned connection_id;
};