6.3
general documentation
Examples of volume exchange coefficient computation for SYRTHES coupling (cs_user_syrthes_coupling_volume_h)

The Examples function is required to compute a volume exchange coefficient for SYRTHES coupling.

Examples

The following code blocks show two examples of computation of a volume exchange coefficient.

Example 1

The first example corresponds to a constant volume exchange coefficient:

cs_real_t hvol_cst = 1.0e6;
for (cs_lnum_t i = 0; i < n_elts; i++) {
h_vol[i] = hvol_cst;
}

Example 2

The second example corresponds to a variable volume exchange coefficient defined as follows :

\[ h_{vol} = h_{surf} S \]

with S is the surface area where exchanges take place by unit of volume and

\[ h_{surf} = \frac{Nu \lambda}{L} \]

First, the values of the different fields that will be needed for the computation of the volume exchange coefficient are retrieved.

const cs_real_3_t *cvar_vel = (const cs_real_3_t *)CS_F_(vel)->val;
const cs_real_t *cpro_rom = (const cs_real_t *)CS_F_(rho)->val;
const cs_real_t *cpro_mu = (const cs_real_t *)CS_F_(mu)->val;
cs_real_t visls_0 = -1;
const cs_real_t *cpro_cp = NULL, *cpro_viscls = NULL;
cs_lnum_t cp_step = 0, viscls_step = 0;
if (CS_F_(cp) != NULL) {
cpro_cp = (const cs_real_t *)CS_F_(cp)->val;
cp_step = 1;
}
else {
cpro_cp = &cp0;
}
/* Get thermal field and associated diffusivity
(temperature only handled here) */
const int viscl_id = cs_field_get_key_int(fth,
cs_field_key_id("diffusivity_id"));
if (viscl_id > -1) {
cpro_viscls = (const cs_real_t *)cs_field_by_id(viscl_id)->val;
viscls_step = 1;
}
else {
visls_0 = cs_field_get_key_double(fth, cs_field_key_id("diffusivity_ref"));
cpro_viscls = &visls_0;
}
const int is_temperature
cs_field_key_id("is_temperature"));

Then the coefficient can be computed and assigned to all cells.

cs_real_t sexcvo = 36.18; /* Surface area where exchanges take
place by unit of volume */
cs_real_t l0 = 0.03; /* Characteristic length */
for (cs_lnum_t i = 0; i < n_elts; i++) {
cs_lnum_t c_id = elt_ids[i];
cs_real_t rho = cpro_rom[c_id];
cs_real_t mu = cpro_mu[c_id];
cs_real_t cp = cpro_cp[c_id*cp_step];
cs_real_t lambda, lambda_over_cp;
if (is_temperature) {
lambda = cpro_viscls[c_id*viscls_step];
lambda_over_cp = lambda / cp;
}
else {
lambda_over_cp = cpro_viscls[c_id*viscls_step];
lambda = lambda_over_cp * cp;
}
/* Compute a local molecular Prandtl **(1/3) */
cs_real_t pr = mu / lambda_over_cp;
/* Compute a local Reynolds number */
cs_real_t uloc = cs_math_3_norm(cvar_vel[c_id]);
cs_real_t re = fmax(uloc*rho*l0/mu, 1.); /* To avoid division by zero */
/* Compute Nusselt number using Colburn correlation */
cs_real_t nu = 0.023 * pow(re, 0.8) * pow(pr, 1./3.);
cs_real_t h_corr = nu * lambda / l0;
/* Compute hvol */
h_vol[i] = h_corr * sexcvo;
}

Not that in this example, no test is done on the coupling id or Syrthes instance name. The corresponding arguments can be used to apply specific computations in cas of multiple couplings.

Also, although a test is done to check if the scalar behaves as a temperature regarding multiplication by Cp for more generality, the Syrthes volume coupling currently only handles the temperature variable.

vel
@ vel
Definition: cs_field_pointer.h:68
lambda
@ lambda
Definition: cs_field_pointer.h:112
rho
@ rho
Definition: cs_field_pointer.h:103
cs_real_3_t
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:317
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:304
cs_fluid_properties_t::cp0
double cp0
Definition: cs_physical_constants.h:81
cs_field_get_key_double
double cs_field_get_key_double(const cs_field_t *f, int key_id)
Return a floating point value for a given key associated with a field.
Definition: cs_field.c:3171
cs_glob_fluid_properties
const cs_fluid_properties_t * cs_glob_fluid_properties
Definition: cs_physical_constants.c:385
cs_field_t::val
cs_real_t * val
Definition: cs_field.h:146
cs_thermal_model_field
cs_field_t * cs_thermal_model_field(void)
Definition: cs_thermal_model.c:207
cs_field_get_key_int
int cs_field_get_key_int(const cs_field_t *f, int key_id)
Return a integer value for a given key associated with a field.
Definition: cs_field.c:2991
CS_F_
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:51
cstphy::cp0
real(c_double), pointer, save cp0
reference specific heat.
Definition: cstphy.f90:233
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_field_by_id
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2314
cs_field_key_id
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2497
cp
@ cp
Definition: cs_field_pointer.h:106
coincl::fmax
double precision, save fmax
Definition: coincl.f90:133
cs_field_t
Field descriptor.
Definition: cs_field.h:125
mu
@ mu
Definition: cs_field_pointer.h:109