The preferred method for defining boundary conditions (besides using the GUI) is to assign zone-based definitions in the cs_user_boundary_conditions_setup function (cs_user_boundary_conditions.cpp).
As an alternative, the same definitions may be defined in cs_user_finalize_setup_wrapper (cs_user_parameters), which is called immediately after cs_user_boundary_conditions_setup. Choosing one or the other should be based on the best balance for reability and maintainability,
Initialization
The following initialization block needs to be added for the following examples:
const cs_lnum_t n_b_faces = domain->mesh->n_b_faces;
const cs_lnum_t *b_face_cells = domain->mesh->b_face_cells;
double cs_real_t
Floating-point value.
Definition: cs_defs.h:342
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:335
int cs_field_n_fields(void)
Return the number of defined fields.
Definition: cs_field.cpp:1593
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.cpp:2781
@ vel
Definition: cs_field_pointer.h:70
@ rho_b
Definition: cs_field_pointer.h:100
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:51
const cs_fluid_properties_t * cs_glob_fluid_properties
Definition: cs_physical_constants.cpp:465
real(c_double), pointer, save viscl0
reference molecular dynamic viscosity.
Definition: cstphy.f90:160
double viscl0
Definition: cs_physical_constants.h:75
Body
In the body, we may define several boundary conditions. Here are a few examples.
Inlet example with hydraulic diameter
Assign an inlet to boundary faces of in zone 'inlet_1'.
- Warning
- the <, <=, >, and >= operators may only be used with variables x, y, and z. This syntax is not a full equation interpreter, so formulas involving x, y, or z are not allowed.
Set a a Dirichlet value on the three components of
on the faces with the selection criterion '2 and x < 0.01' and set a Dirichlet to all the scalars
.
Turbulence example computed using equations valid for a pipe.
We will be careful to specify a hydraulic diameter adapted to the current inlet.
We will also be careful if necessary to use a more precise formula for the dynamic viscosity use in the calculation of the Reynolds number (especially if it is variable, it may be useful to take the law from cs_user_physical_properties. Here, we use by default the 'viscl0" value.
Regarding the density, we have access to its value at boundary faces (b_roh) so this value is the one used here (specifically, it is consistent with the processing in cs_user_physical_properties, in case of variable density).
vel_rcodcl1[n_b_faces*0 + face_id] = 0;
vel_rcodcl1[n_b_faces*1 + face_id] = 1.1;
vel_rcodcl1[n_b_faces*2 + face_id] = 0;
uref2,
xdh,
b_rho,
}
for (int f_id = 0; f_id < n_fields; f_id++) {
}
}
}
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.cpp:711
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.cpp:3275
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.cpp:2465
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:561
static CS_F_HOST_DEVICE cs_real_t cs_math_fmax(cs_real_t x, cs_real_t y)
Compute the max value of two real values.
Definition: cs_math.h:503
cs_real_t cs_notebook_parameter_value_by_name(const char *name)
Return a parameter value (real).
Definition: cs_notebook.cpp:410
@ CS_INLET
Definition: cs_parameters.h:85
void cs_turbulence_bc_inlet_hyd_diam(cs_lnum_t face_id, double uref2, double dh, double rho, double mu)
Set inlet boundary condition values for turbulence variables based on a diameter and the reference v...
Definition: cs_turbulence_bc.cpp:772
cs_real_t * rcodcl1
Definition: cs_field.h:109
Field descriptor.
Definition: cs_field.h:131
cs_field_bc_coeffs_t * bc_coeffs
Definition: cs_field.h:163
const cs_lnum_t * elt_ids
Definition: cs_zone.h:65
cs_lnum_t n_elts
Definition: cs_zone.h:64
Inlet example with turbulence intensity
Assign an inlet to boundary faces of zone 'inlet_2'.
Set a a Dirichlet value on the three components of
on the faces with the selection criterion '3' and set a Dirichlet to all the scalars
.
Turbulence example computed using turbulence intensity data.
We will be careful to specify a hydraulic diameter adapted to the current inlet.
Calculation of
and
at the inlet (xkent and xeent) using the turbulence intensity and standard laws for a circular pipe (their initialization is not needed here but is good practice)
vel_rcodcl1[n_b_faces*0 + face_id] = 0;
vel_rcodcl1[n_b_faces*1 + face_id] = 1.1;
vel_rcodcl1[n_b_faces*2 + face_id] = 0;
}
for (int f_id = 0; f_id < n_fields; f_id++) {
}
}
}
void cs_turbulence_bc_inlet_turb_intensity(cs_lnum_t face_id, double uref2, double t_intensity, double dh)
Set inlet boundary condition values for turbulence variables based on a diameter ,...
Definition: cs_turbulence_bc.cpp:800
Assign an outlet to boundary faces of zone 'outlet'
Outlet:
- zero flux for velocity and temperature, prescribed pressure
- Note that the pressure will be set to P0 at the first
- free outlet face (CS_OUTLET)
}
@ CS_OUTLET
Definition: cs_parameters.h:86
Wall example
Assign a wall to boundary faces of zone '5'.
Wall:
- zero flow (zero flux for pressure)
- friction for velocities (+ turbulent variables)
- zero flux for scalars
if (th_f == nullptr)
continue;
}
@ CS_SMOOTHWALL
Definition: cs_parameters.h:89
cs_field_t * cs_thermal_model_field(void)
Definition: cs_thermal_model.cpp:216
cs_real_t * rcodcl2
Definition: cs_field.h:110
cs_real_t * rcodcl3
Definition: cs_field.h:111
int * icodcl
Definition: cs_field.h:108
Rough wall example
Assign a rough wall to boundary faces of zone '7'.
Wall:
- zero flow (zero flux for pressure)
- rough friction for velocities (+ turbulent variables)
- zero flux for scalars
cs_real_t *bpro_roughness =
nullptr, *bpro_roughness_t =
nullptr;
if (bpro_roughness != nullptr)
bpro_roughness[face_id] = 0.01;
if (bpro_roughness_t != nullptr)
bpro_roughness_t[face_id] = 0.01;
CS_F_(
vel)->bc_coeffs->rcodcl1[face_id] = 1.;
}
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.cpp:2515
@ CS_ROUGHWALL
Definition: cs_parameters.h:90
cs_real_t * val
Definition: cs_field.h:152
Symmetry example
Assign a symmetry condition to boundary faces of zone '4'
}
@ CS_SYMMETRY
Definition: cs_parameters.h:87