CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Implementation of boundary conditions (https://www.cfd-online.com/Forums/openfoam-programming-development/141218-implementation-boundary-conditions.html)

Floreas September 2, 2014 15:24

Implementation of boundary conditions
 
Hi,

I try to understand how are the boundary conditions implemented in the source code of a certain application.
As a concrete example, let's say that the application is interFoam and the boundary condition is inletOutlet. My question is where in the code of interFoam are called (if they are) the functions of the class inletOutletFvPatchField.
May someone help me with some hints or links to some documentation?

Thanks in advance,
Daniel

marupio September 3, 2014 04:24

That's OpenFOAM's runtime selection mechanism. You won't find any reference to derived boundary conditions in the solvers (or you shouldn't... sometimes one may depend on a specific type). The solvers only need to know about fvPatch and fvPatchField (which are the base classes for the mesh boundary and the boundary condition). fvPatch and fvPatchField are smart enough that when you build the mesh in the solver (e.g. #include "createMesh.H") they will load the correct derived boundary conditions (e.g. inletOutletFvPatchField). The solver only needs interact with the base class, such as patch.correct() or .update() or whatever functions exist in fvPatchField.

The reason this mechanism exists is it allows you to add/modify/remove the boundary conditions, without having to change the code in the solvers... there's dozens of solvers, and that would be impractical.

The actual implementation of the runtime selection is a bit ugly with a lot of pre-defined macros. This attempts to describe it:

http://openfoamwiki.net/index.php/Op...tion_mechanism

Enjoy!


All times are GMT -4. The time now is 00:38.