9.2
general documentation
Examples of ALE boundary conditions

Mapping relative to ALE

const cs_lnum_t *b_face_vtx_idx = domain->mesh->b_face_vtx_idx;
const cs_lnum_t *b_face_vtx_lst = domain->mesh->b_face_vtx_lst;
const cs_lnum_t *b_face_cells = domain->mesh->b_face_cells;
const int nt_cur = domain->time_step->nt_cur;
const auto dt = CS_F_(dt)->get_val_s();
/* nodes displacement */
auto disale = cs_field("mesh_displacement")->get_val_v();
const cs_zone_t *zn = nullptr;
cs_span_2d< cs_real_t > get_val_v(const int time_id=0) const
Return a 2D span view of field values. If the field is not a vector a fatal error is provoked.
Definition: cs_field.cpp:5103
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
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
@ dt
Definition: cs_field_pointer.h:61
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:47
Definition: cs_zone.h:51

Assign boundary conditions to boundary faces

One may use selection criteria to filter boundary case subsets.
Loop on faces from a subset.
Set the boundary condition for each face.

Calculation of displacement at current time step

Example 1

Example : For boundary faces of color 4 assign a fixed velocity

/* Example: For boundary faces of zone 'fv' assign a fixed velocity */
auto mesh_u_val_ext = CS_F_(mesh_u)->bc_coeffs->get_val_ext_v();
/* Calculation of displacement at current time step */
const cs_real_t deltaa = sin(3.141596*(nt_cur-1)/50);
const cs_real_t delta = sin(3.141596*nt_cur/50.);
for (cs_lnum_t ilelt = 0; ilelt < zn->n_elts; ilelt++) {
const cs_lnum_t face_id = zn->elt_ids[ilelt];
const cs_lnum_t c_id = b_face_cells[face_id];
ale_bc_type[face_id] = CS_BOUNDARY_ALE_IMPOSED_VEL;
mesh_u_val_ext(face_id, 0) = 0;
mesh_u_val_ext(face_id, 1) = 0;
mesh_u_val_ext(face_id, 2) = (delta-deltaa)/dt[c_id];
}
@ CS_BOUNDARY_ALE_IMPOSED_VEL
Definition: cs_boundary.h:141
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
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
@ mesh_u
Definition: cs_field_pointer.h:84
const cs_lnum_t * elt_ids
Definition: cs_zone.h:61
cs_lnum_t n_elts
Definition: cs_zone.h:60

Example 2

Example: For boundary face of color 5 assign a fixed displacement on nodes

for (cs_lnum_t ilelt = 0; ilelt < zn->n_elts; ilelt++) {
const cs_lnum_t face_id = zn->elt_ids[ilelt];
for (cs_lnum_t ii = b_face_vtx_idx[face_id];
ii < b_face_vtx_idx[face_id+1];
ii++) {
const cs_lnum_t vtx_id = b_face_vtx_lst[ii];
if (impale[vtx_id] == 0) {
disale(vtx_id, 0) = 0;
disale(vtx_id, 1) = 0;
disale(vtx_id, 2) = delta;
impale[vtx_id] = 1;
}
}
}

Example 3

Example : For boundary faces of color 6 assign a sliding boundary

for (cs_lnum_t ilelt = 0; ilelt < zn->n_elts; ilelt++) {
const cs_lnum_t face_id = zn->elt_ids[ilelt];
ale_bc_type[face_id] = CS_BOUNDARY_ALE_SLIDING;
}
@ CS_BOUNDARY_ALE_SLIDING
Definition: cs_boundary.h:140

Example 4

Example : Prescribe elsewhere a fixed boundary

zn = cs_boundary_zone_by_name("fixed");
for (cs_lnum_t ilelt = 0; ilelt < zn->n_elts; ilelt++) {
const cs_lnum_t face_id = zn->elt_ids[ilelt];
ale_bc_type[face_id] = CS_BOUNDARY_ALE_FIXED;
}
@ CS_BOUNDARY_ALE_FIXED
Definition: cs_boundary.h:139