Local variables common to following examples
The following declaration and initialization block is required used for the examples of this section:
Field descriptor.
Definition: cs_field.h:275
int cs_field_n_fields(void)
Return the number of defined fields.
Definition: cs_field.cpp:1505
cs_field_t * cs_field(int id)
Return a pointer to a field based on its id. This function requires that a field of the given id is d...
Definition: cs_field.cpp:4295
Initialization and finalization
Initialization and finalization is similar to that of the base examples
Example 1
Example of specific boundary conditions fully defined by the user, on the basis of wall conditions selection (mass flow computation, specific logging, ...)
²We prescribe for zone 'wall_s' a wall, with in addition:
- a Dirichlet condition on velocity (sliding wall with no-slip condition)
- a Dirichlet condition on the first scalar.
{
int *vel_icodcl =
CS_F_(
vel)->bc_coeffs->icodcl;
auto vel_val_ext =
CS_F_(
vel)->bc_coeffs->get_val_ext_v();
auto vel_h_ext =
CS_F_(
vel)->bc_coeffs->get_h_ext_v();
auto vel_q_ext =
CS_F_(
vel)->bc_coeffs->get_q_ext_v();
for (
cs_lnum_t elt_idx = 0; elt_idx < n_elts; elt_idx++) {
scal_val_ext[face_id] = 10.;
vel_val_ext(face_id, 0) = 1.;
vel_val_ext(face_id, 1) = 0.;
vel_val_ext(face_id, 2) = 0.;
scal_q_ext[face_id] = 0;
vel_q_ext(face_id, 0) = 0;
vel_q_ext(face_id, 1) = 0;
vel_q_ext(face_id, 1) = 0;
}
}
cs_span< cs_real_t > get_h_ext() const
Return a 1D span view of boundary condition external exchange coefficient.
Definition: cs_field.cpp:5931
cs_span< cs_real_t > get_val_ext() const
Return a 1D span view of boundary condition external values.
Definition: cs_field.cpp:5826
cs_span< cs_real_t > get_q_ext() const
Return a 1D span view of boundary condition prescribed flux.
Definition: cs_field.cpp:6018
int * icodcl
Definition: cs_field.h:111
cs_field_bc_coeffs_t * bc_coeffs
Definition: cs_field.h:309
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:708
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
@ vel
Definition: cs_field_pointer.h:66
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:47
static constexpr cs_real_t cs_math_infinite_r
Definition: cs_math.h:105
@ CS_BC_DIRICHLET
Definition: cs_param_types.h:506
@ CS_SMOOTHWALL
Definition: cs_parameters.h:87
const cs_lnum_t * elt_ids
Definition: cs_zone.h:61
cs_lnum_t n_elts
Definition: cs_zone.h:60
Example 2
Example of specific boundary conditions fully defined by the user, with no definition of a specific type.
We prescribe at zone 'surf_h' a homogeneous Neumann condition for all variables.
{
for (
cs_lnum_t elt_idx = 0; elt_idx < n_elts; elt_idx++) {
}
for (int f_id = 0; f_id < n_fields; f_id++) {
continue;
for (
cs_lnum_t elt_idx = 0; elt_idx < n_elts; elt_idx++) {
val_ext(face_id, ii) = 0.;
q_ext(face_id, ii) = 0.;
}
}
}
}
cs::mdspan< cs_real_t, 2, cs::layout::left > get_q_ext_2d() const
Return a 2D span view of boundary condition prescribed flux (1st dimension: face id,...
Definition: cs_field.cpp:6038
cs::mdspan< cs_real_t, 2, cs::layout::left > get_val_ext_2d() const
Return a 2D span view of boundary condition external values (1st dimension: face id,...
Definition: cs_field.cpp:5868
cs::mdspan< cs_real_t, 2, cs::layout::left > get_h_ext_2d() const
Return a 2D span view of boundary condition external exchange coefficient (1st dimension: face id,...
Definition: cs_field.cpp:5951
int type
Definition: cs_field.h:282
int dim
Definition: cs_field.h:284
@ CS_BC_NEUMANN
Definition: cs_param_types.h:511
@ CS_UNDEF
Definition: cs_parameters.h:82
#define CS_FIELD_VARIABLE
Definition: cs_field.h:66
Example 3
Example of wall boundary condition with automatic continuous switch between rough and smooth.
{
for (
cs_lnum_t elt_idx = 0; elt_idx < n_elts; elt_idx++) {
bpro_roughness[face_id] = 0.05;
}
}
}
cs_span< cs_real_t > get_val_s(const int time_id=0) const
Return a 1D span view of field values. If the field is not a scalar a fatal error is provoked.
Definition: cs_field.cpp:5080
cs_field_t * cs_field_try(int id)
Return a pointer to a field based on its id. If no field of the given name is defined,...
Definition: cs_field.cpp:4371