Contrib icoBlockedCellFoam

From OpenFOAMWiki
Revision as of 07:18, 19 April 2011 by Makaveli lcf (Talk | contribs)

Valid versions: OF version 16.png OF version 17.png

1 Introduction

The current example is desired to show how the matrix coefficients of the linear system of equations are modified from user-side. The specific aim of the presented test case is to exclude single cell from the flow and pressure field calculations. The application of such approach can be found e.g. when modeling solidification processes where fully solidified regions should not produce neither flow nor pressure sources. Also it can be used for simulating obstacles immersed in the flow etc.

Disclaimer: this example is not claimed to be perfect and also physics behind can be discussed. So please consider it as a guide for the future steps.

To exclude one cell of the domain from calculations a following technique will be used: we set diagonal coefficient to the identity value and remove the influence of the neighboring cells. Latest is done by canceling the off-diagonal coefficients. Thereby matrix coefficients are adjusted in such manner for the system

A_{ii}\boldsymbol{\psi}_{i}+\sum_{j}A_{ij}\boldsymbol{\psi}_{j}=\mathbf{S}_{i}\qquad

that for the "blocked" cell (indexed as k) the diagonal element A_{kk} equals 1, and all off-diagonal coefficients A_{kj} are zeroed along with the source term \mathbf{S}_{k}. The consequence of the described operations with the system (1) is that

\left\{ \begin{array}{c}
A_{kk}=1,\\
A_{kj}=0,\\
\mathbf{S}_{k}=0.\end{array}\quad\Longrightarrow\quad\mathbf{1}\cdot\boldsymbol{\psi}_{k}=0.\right.
\qquad(2)

In accordance to (2) the solution for the cell value \boldsymbol{\psi}_{k} is trivial one. Hereby if one applies the condition (2) for the momentum and pressure matrices in the PISO algorithm, that results in zero velocity and pressure values automatically for the general solution of the full system (1). To get the solution in the cell different from the zero one, the source term can be adjusted to the corresponding value.

The source code example supplemented with the test case is a modification of the incompressible viscous flow solver icoFoam Further the required additions are described.

2 Mods to createFields.C file

The following modification should be applied to the initial createFields.C file. First for the allocation of the blocked cell it is required to define its position:

 
//  Read the position of the excluded cell
vector position_
(
    transportProperties.lookup("exclude")
);


Then exclude parameter should be defined in the transportProperties file in the case folder.

nu          nu [ 0 2 -1 0 0 0 0 ] 0.01;
exclude     (0.05 0.05 0.005);

In the above example the position vector will correspond to the center of the driven cavity.

3 Solver icoBlockedCell.C file