7.3
general documentation
Examples of ALE boundary conditions

Mapping relative to ALE

const cs_lnum_t n_b_faces = domain->mesh->n_b_faces;
const cs_lnum_t *ipnfbr = domain->mesh->b_face_vtx_idx;
const cs_lnum_t *nodfbr = 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 cs_real_t *dt = CS_F_(dt)->val;
/* nodes displacement */
cs_real_3_t *disale
= (cs_real_3_t*)cs_field_by_name("mesh_displacement")->val;
const cs_zone_t *zn = NULL;

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 '4' assign a fixed velocity */
cs_field_t *mesh_u = CS_F_(mesh_u);
/* 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->bc_coeffs->rcodcl1[n_b_faces*0 + face_id] = 0;
mesh_u->bc_coeffs->rcodcl1[n_b_faces*1 + face_id] = 0;
mesh_u->bc_coeffs->rcodcl1[n_b_faces*2 + face_id] = (delta-deltaa)/dt[c_id];
}

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 = ipnfbr[face_id]; ii < ipnfbr[face_id+1]; ii++) {
const cs_lnum_t inod = nodfbr[ii];
if (impale[inod] == 0) {
disale[inod][0] = 0;
disale[inod][1] = 0;
disale[inod][2] = delta;
impale[inod] = 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;
}

Example 4

Example : Prescribe elsewhere a fixed boundary

zn = cs_boundary_zone_by_name("not (4 or 5 or 6)");
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;
}