CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   Beginner needs some advice how to get into programming a solver (

ThomasV August 28, 2013 10:43

Beginner needs some advice how to get into programming a solver

I'm new to OpenFOAM and really need some advice. My job is to write a solver which is going to be about melting/solidification and a simple laminar flow of the fluid phase (which actually has been done by some persons here in the forum so I have some code to look at which is close to what I want to accomplish)...

My problem now is to get into the programming side of OpenFoam. In order to introduce myself I worked through the usual tutorials and e.g. created some custom geometry with in-/outlets and gave interFoam some work to do with it. So the general way of how to set up a project is clear to me. When diving into the code behind I'm facing huge problems though and I hope that someone here can help me with that...

1) Lack of comments / descriptions
Do things like solvers really have no real description? It seems like the source files don't give any more information than the wiki / user guide does. Let's have a look at interFoam's description:

Solver for 2 incompressible, isothermal immiscible fluids using a VOF
(volume of fluid) phase-fraction based interface capturing approach.

The momentum and other fluid properties are of the "mixture" and a single
momentum equation is solved.

Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected.

For a two-fluid approach see twoPhaseEulerFoam.
Is that really all information I can get (especially as this is one of the more "lengthy" descriptions) or is there more elsewhere? I mean I don't expect to find every step described in detail but are there no details like "model XYZ is used here with approach ABC". Does one really have to stumble upon topics like THIS where you get to know not just you wrote the solver but also which scheme was used?

2.) Understanding what the code does
Probably my worst problem right now. When e.g. looking at icoFoam there are things I'd like to know what exactly they do. There for example is:

00063        solve(UEqn == -fvc::grad(p));
I now would like to know what the solve method does. The C++ documentation unfortunately just leads me HERE. I just can't figure out how to get to the actual implementation of the solve method. It's the same for e.g. this:

00090                pEqn.solve();
I can search for pEqn in the C++ documentation but I end up with a list of pEqn.h files but no implementation of what "solve()" actually does.

3.) IDE?
Is there some way to make use of some kind of IDE like Eclipse? I did use Qt for a while and enjoyed not only having things like proposals for what I want might to write right now in terms of e.g. class names or methods a class offers but one also can simply point at e.g. a function and jump to the position where it's defined...

All times are GMT -4. The time now is 21:59.