A method of defining an inlet condition which converges towards an infinite channel profile is based simply on feedback from values computed downstream from the inlet.
Here, we define an inlet boundary condition for a very long channel or duct with a section matching the boundary faces of zone 'INLET'.
Initialization and finalization is similar to that of the base examples, with the addition of the mapping object, described in a specific section hereafter
The base definition given here ensures initialization of a (flat) inlet profile with the required mean velocity.
To define the appropriate mapping object, the cs_boundary_conditions_map function is used. In this example, coordinates of the selected inlet face are shifted by a constant distance (5.95 meters along the x axis), and mapped to the corresponding mesh cells. Here, all cells are selected as point location candidates, but optionally, a restricted list of cells may be provided, which may accelerate location (or ensure it is done on a selected subset). In most cases, as in this example, a constant coordinate shift is used for all inlet points, but it is possible to define a specific shift for each face.
In general, when defining a pseudo-periodic boundary condition, it is assumed that the mesh is not moving, so the mapping may be defined once and for all. Hence the test on nt_cur and nt_prev and the save attribute for the inlet_1 pointer.
At all time steps after the first (possibly even the first if the flow at the mapping locations is initialized to nonzero values), the values at points mapped to inlet face centers are applied to the field->bc_coeffs->rcodcl1 values of the corresponding faces, using the cs_boundary_conditions_mapped_set function. Optionally, a normalization by be applied, ensuring the mean values initially defined are preserved. Normalization is recommended for the velocity, and possibly scalars, but not for turbulent quantities, which should adapt to the velocity.
At the end of the computation, it is good practice to free the mapping structure: