![]() |
programmer's documentation
|
This is an example of cs_user_extra_operations which performs scalar balances on specified zones.
The algorithm implemented in the subroutine balance_by_zone adds up contributions of fluxes on the boundary of the sub-domain defined by the user. The different contributions are classified according to their nature (inlet, outlet, wall, symmetry...) if they are boundary faces of the whole domain or according to the sign of the mass flux if they are boundary faces of the sub-domain but internal faces of the whole domain.
To ensure calculations have physical meaning, it is best to use a spatially uniform time step (idtvar = 0 or 1).
The balance at time step n over a subdomain of boundary
is equal to:
The first term is negative if the amount of scalar in the volume has increased (it is 0 in a steady regime).
The terms of convection and diffusion (at internal or boundary faces) are positive if the amount of scalar in the volume has increased.
In a steady regime, a positive balance thus indicates a scalar gain.
This example computes energy balance relative to temperature. We assume that we want to compute balances (convective and diffusive) at the boundaries of the calculation domain.
The scalar considered is the temperature, nevertheless it is multiplied by the specific heat at each cell so that the computed balance is on energy, hence in Joules.
Here is the corresponding code:
This example computes the balance relative to a scalar named "scalar1". We assume that we want to compute balances (convective and diffusive) on a box defined by two diagonally opposite points (the extrema in terms of coordinates).
The box criterium can be used as follows: box[ ,
,
,
,
,
].
Here is the corresponding code: