8.2
general documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Atmospheric examples

Local variables to be added for the Fortran examples

integer ifac, ii
integer izone
integer ilelt, nlelt
integer f_id_rough, f_id_t_rough
double precision d2s3
double precision zref, xuref
double precision ustar, rugd, rugt
double precision zent, xuent, xvent
double precision xkent, xeent
integer, pointer, dimension(:,:) :: icodcl
double precision, pointer, dimension(:,:,:) :: rcodcl
integer, allocatable, dimension(:) :: lstelt
double precision, dimension(:), pointer :: bpro_roughness
double precision, dimension(:), pointer :: bpro_roughness_t

Initialization and finalization

Initialization and finalization is similar to that of the base examples

Example 1 (Fortran)

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

call getfbr('11',nlelt,lstelt)
! Get a new zone number (1 <= izone <= nozppm)
izone = maxval(izfppp) + 1
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
! - Zone to which the face belongs
izfppp(ifac) = izone
! - boundary condition type can be set to ientre or i_convective_inlet
itypfb(ifac) = ientre
! - automatic determination of type (inlet/outlet) according to sign of
! mass flux
iautom(ifac) = 1
enddo
subroutine getfbr(fstr, facnb, faces)
Build the list of boundary faces matching a criteria string.
Definition: cs_selector_f2c.f90:111

Example 2 (Fortran)

For boundary faces of color 21, assign an inlet boundary condition prescribed from the meteo profile.

call getfbr('21',nlelt,lstelt)
! Get a new zone number (1 <= izone <= nozppm)
izone = maxval(izfppp) + 1
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
! - Zone to which the face belongs
izfppp(ifac) = izone
! - Assign inlet boundary conditions
itypfb(ifac) = ientre
enddo

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 *restrict)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);
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;
}
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;
}
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;
}
}
}
const cs_zone_t * cs_boundary_zone_by_name(const char *name)
Return a pointer to a boundary zone based on its name if present.
Definition: cs_boundary_zone.c:711
#define restrict
Definition: cs_defs.h:141
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:347
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
@ nusa
Definition: cs_field_pointer.h:81
@ k
Definition: cs_field_pointer.h:70
@ eps
Definition: cs_field_pointer.h:71
@ omg
Definition: cs_field_pointer.h:80
@ rij
Definition: cs_field_pointer.h:73
@ phi
Definition: cs_field_pointer.h:75
@ f_bar
Definition: cs_field_pointer.h:76
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:51
static CS_F_HOST_DEVICE cs_real_t cs_math_pow3(cs_real_t x)
Compute the cube of a real value.
Definition: cs_math.h:274
static CS_F_HOST_DEVICE cs_real_t cs_math_pow2(cs_real_t x)
Compute the square of a real value.
Definition: cs_math.h:258
@ CS_INLET
Definition: cs_parameters.h:85
double cs_turb_cmu
Definition: cs_turbulence_model.c:505
double cs_turb_xkappa
Definition: cs_turbulence_model.c:446
const cs_turb_model_t * cs_glob_turb_model
@ CS_TURB_SPALART_ALLMARAS
Definition: cs_turbulence_model.h:69
@ CS_TURB_V2F_PHI
Definition: cs_turbulence_model.h:66
@ CS_TURB_K_OMEGA
Definition: cs_turbulence_model.h:68
int iturb
Definition: cs_turbulence_model.h:117
int itytur
Definition: cs_turbulence_model.h:139
Definition: cs_zone.h:55
const cs_lnum_t * elt_ids
Definition: cs_zone.h:65

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 = NULL;
cs_real_t *bpro_roughness_t = NULL;
if (cs_field_by_name_try("boundary_roughness") != NULL)
bpro_roughness = cs_field_by_name_try("boundary_roughness")->val;
if (cs_field_by_name_try("boundary_thermal_roughness") != NULL)
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 != NULL)
bpro_roughness[face_id] = rugd;
if (bpro_roughness_t != NULL)
bpro_roughness_t[face_id] = 0.01;
}
}
cs_field_t * cs_field_by_name_try(const char *name)
Return a pointer to a field based on its name if present.
Definition: cs_field.c:2515
@ CS_ROUGHWALL
Definition: cs_parameters.h:90
cs_real_t * val
Definition: cs_field.h:152
cs_lnum_t n_elts
Definition: cs_zone.h:64