## Utilities in OpenFOAM

 applyBoundaryLayer

Description
Apply a simplified boundary-layer model to the velocity and turbulence fields based on the 1/7th power-law.

The uniform boundary-layer thickness is either provided via the -ybl option or calculated as the average of the distance to the wall scaled with the thickness coefficient supplied via the option -Cbl. If both options are provided -ybl is used.

The velocity profile is initialized based on the 1/7th power law turbulent velocity profile:
\begin{equation}
\boldsymbol{u} = \boldsymbol{U} \left( \frac{y_w}{\delta} \right)^{\frac{1}{7}}, \tag{1}
\end{equation}
where $$\boldsymbol{U}$$ is the main flow velocity, $$y_w$$ is the distance to the wall and $$\delta$$ is the boundary-layer thickness.

## Bandwidth, Profile and Frontwidth of Matrix

When we discretize the partial differential equations using the Finite Volume Method (FVM), we get sets of linear algebraic equations with large sparse coefficient matrices that are solved using iterative or direct methods. There is renumberMesh utility in OpenFOAM that is used to reduce the bandwidth of the coefficient matrices by renumbering the cell label list.

The bandwidth is not a special term in OpenFOAM but it is a general concept in the field of solving linear systems of equations. In this blog post, I will try to give a description of it and other important terms such as profile and frontwidth.

Keywords: bandwidth, profile, frontwidth, renumberMesh

 Definitions of bandwidth, profile and frontwidth

The definitions of these terms are clearly described in . Let $$A$$ be an $$N$$ by $$N$$ matrix with symmetric zero-nonzero structure, i.e. , $$a_{ij} \neq 0$$ if and only if $$a_{ji} \neq 0$$.

The $$i$$-th bandwidth of $$A$$ is:

\begin{align}
\beta_i(A) = i \; – \; {\rm min}\{ j \; | \; a_{ij} \neq 0\}. \tag{1} \label{eq:ithBandwidth}
\end{align}

The bandwidth of $$A$$ is defined by

\begin{align}
\beta = \beta(A) &= {\rm max} \{ \beta_i(A) \; | \; 1 \leq i \leq N\} \\
&= {\rm max} \{ |i-j| \; | \; a_{ij} \neq 0 \}. \tag{2} \label{eq:Bandwidth}
\end{align}

The quantity $$|Env(A)|$$ is called the profile or the envelope size of $$A$$, and is defined by:

\begin{align}
|Env(A)| = \sum_{i=1}^{N} \beta_i(A). \tag{4} \label{eq:Profile}
\end{align}

Another quantity called frontwidth is defined by the number of rows of the envelope of $$A$$ which intersect column $$i$$.

\begin{align}
\omega_i(A) = \{ k \; | \; k > i \; and \; \exists l \leq i \; s.t. \; a_{kl} \neq 0 \} \tag{5} \label{eq:frontwidth}
\end{align}

To estimate factorization time, a quantity called root mean square frontwidth is introduced by . This quantity is given by:

\begin{align}
f = \sqrt{\frac{1}{N} \left( \sum_{i=1}^{N} \omega_i^2 \right)}. \tag{8} \label{eq:rmsFrontwidth}
\end{align}

 Output of renumberMesh utility

When the renumberMesh utility is executed, the following data is reported to the screen.

Here, the band, profile and rms frontwidth correspond to \eqref{eq:Bandwidth}, \eqref{eq:Profile} and \eqref{eq:rmsFrontwidth}, respectively. We can confirm that they all decreased after renumbering the cell label using the Cuthill-McKee (CM) algorithm. The distributions of cell labels are visually compared between before and after reordering operations in Figure 1.

 Source code of renumberMesh utility

The getBand function is called from the main function. The variables band, profile and rmsFrontwidth represent \eqref{eq:Bandwidth}, \eqref{eq:Profile} and \eqref{eq:rmsFrontwidth}, respectively.

 References

## Postprocessing with foamCalc utility

After the simulation has finished, you can do simple calculation, such as addition and subtraction, with the field data using foamCalc utility. The source code is located in the following directories:

• applications/utilities/postProcessing/foamCalc
• src/postProcessing/foamCalcFunctions.
 components
 $foamCalc components U -latestTime  This example is to generate three component files Ux, Uy and Uz (volScalarField) from volVectorField U only at the latest time directory.  mag $ foamCalc mag U

This example is to generate velocity magnitude field $$|\boldsymbol{U}|$$ file magU at every existing time directory.

 magSqr
 $foamCalc magSqr U  This example is to generate magnitude squared field $$|\boldsymbol{U}|^2$$ file magSqrU at every existing time directory.  addSubtract $ foamCalc addSubtract T subtract -value 273.15 -resultName Tdeg -time 5000

This example is to convert the temperature unit from Kelvin to degrees at time 5000. The generated file name can be specified using –resultName option.

 div
 $foamCalc div phi  This example is to calculate the divergence of the flux field phi for the estimation of the continuity error of each cell for incompressible flow.  interpolate $ foamCalc interpolate T -latestTime

This example it to generate surfaceScalarField interpolateT from volScalarField T using the interpolation scheme specified in the system/fvSchemes file.