8.3
general documentation
Loading...
Searching...
No Matches
Atmospheric examples

Local variables to be added for the Fortran examples

Initialization and finalization

Initialization and finalization is similar to that of the base examples

Example 1 (Fortran)

For boundary faces of zone "open_11", assign an inlet boundary condition prescribed from the meteo profile with automatic choice between inlet/ outlet according to the meteo profile.

{
int *iautom = cs_glob_bc_pm_info->iautom;
const cs_zone_t *zn = cs_boundary_zone_by_name("open_11");
for (cs_lnum_t e_idx = 0; e_idx < zn->n_elts; e_idx++) {
const cs_lnum_t face_id = zn->elt_ids[e_idx];
bc_type[face_id] = CS_INLET;
iautom[face_id] = 1;
}
}

Example 3

For boundary faces of zone "inlet_3", assign an inlet boundary condition. Here, all other variables prescribed from the meteo profile are assumed to be managed by the GUI, except for dynamic variables which are prescribed with a rough log law.

{
const cs_lnum_t n_b_faces = domain->mesh->n_b_faces;
const cs_real_3_t *restrict b_face_cog
= (const cs_real_3_t *)domain->mesh_quantities->b_face_cog;
const cs_real_t d2o3 = 2./3;
/* Parameters for the analytical rough wall law (neutral) */
const cs_real_t rugd = 0.10;
const cs_real_t zref = 10.0;
const cs_real_t xuref = 10.0;
const cs_zone_t *zn = cs_boundary_zone_by_name("inlet_3");
for (cs_lnum_t e_idx = 0; e_idx < zn->n_elts; e_idx++) {
const cs_lnum_t face_id = zn->elt_ids[e_idx];
bc_type[face_id] = CS_INLET;
/* Dynamic variables are prescribed with a rough log law;
note: using functions from the `cs_turbulence_bc` series
is preferrable when the appropriate function is available. */
const cs_real_t zent = b_face_cog[face_id][2];
const cs_real_t ustar = cs_turb_xkappa*xuref/log((zref+rugd)/rugd);
const cs_real_t xkent = cs_math_pow2(ustar)/sqrt(cs_turb_cmu);
const cs_real_t xeent = cs_math_pow3(ustar)/cs_turb_xkappa/(zent+rugd);
if (cs_glob_turb_model->itytur == 2) {
CS_F_(k)->bc_coeffs->rcodcl1[face_id] = xkent;
CS_F_(eps)->bc_coeffs->rcodcl1[face_id] = xeent;
}
else if (cs_glob_turb_model->itytur == 3) {
for (int ii = 0; ii< 3; ii++)
CS_F_(rij)->bc_coeffs->rcodcl1[n_b_faces*ii + face_id] = d2o3*xkent;
for (int ii = 3; ii< 6; ii++)
CS_F_(rij)->bc_coeffs->rcodcl1[n_b_faces*ii + face_id] = 0;
CS_F_(eps)->bc_coeffs->rcodcl1[face_id] = xeent;
}
else if (cs_glob_turb_model->model == CS_TURB_V2F_PHI) {
CS_F_(k)->bc_coeffs->rcodcl1[face_id] = xkent;
CS_F_(eps)->bc_coeffs->rcodcl1[face_id] = xeent;
CS_F_(phi)->bc_coeffs->rcodcl1[face_id] = d2o3;
CS_F_(f_bar)->bc_coeffs->rcodcl1[face_id] = 0.0;
}
else if (cs_glob_turb_model->model == CS_TURB_K_OMEGA) {
CS_F_(k)->bc_coeffs->rcodcl1[face_id] = xkent;
CS_F_(omg)->bc_coeffs->rcodcl1[face_id] = xeent/cs_turb_cmu/xkent;
}
CS_F_(nusa)->bc_coeffs->rcodcl1[face_id]
= cs_turb_cmu*cs_math_pow2(xkent)/xeent;
}
}
}

Example 4

Define a rough wall at boundary faces of zone 'b_5'.

{
/* Parameters for the analytical rough wall law (neutral) */
const cs_real_t rugd = 0.10;
cs_real_t *bpro_roughness = nullptr;
cs_real_t *bpro_roughness_t = nullptr;
if (cs_field_by_name_try("boundary_roughness") != nullptr)
bpro_roughness = cs_field_by_name_try("boundary_roughness")->val;
if (cs_field_by_name_try("boundary_thermal_roughness") != nullptr)
bpro_roughness = cs_field_by_name_try("boundary_thermal_roughness")->val;
const cs_zone_t *zn = cs_boundary_zone_by_name("b_5");
for (cs_lnum_t e_idx = 0; e_idx < zn->n_elts; e_idx++) {
const cs_lnum_t face_id = zn->elt_ids[e_idx];
bc_type[face_id] = CS_ROUGHWALL;
if (bpro_roughness != nullptr)
bpro_roughness[face_id] = rugd;
if (bpro_roughness_t != nullptr)
bpro_roughness_t[face_id] = 0.01;
}
}