2. 2M
This offering is not approved or endorsed
by OpenCFD Limited, producer and
distributor of the OpenFOAM software via
www.openfoam.com, and owner of the
OPENFOAM® and OpenCFD® trade
marks.
3. • What is OpenFOAM® and what can it do for me
• Examples
• Droplet formation and detachment
• Electron beam melting
• Vacuum arc remelting
• Solidification of steel ingots
• OpenFOAM®: idiosyncrasies and annoyances
Outline
3
4. Short OpenFOAM® history (official one)
• 199x – Weller started development of what will become OpenFOAM®
• 2004 – OpenCFD® is created (Weller, Greenshields, Janssens)
• Aug. 2011 – OpenCFD® is bought by SGI
• Sep. 2012 – OpenCFD® is bought by ESI
• 2014 – Weller & Greeshields left ESI to start CFD Direct
4
5. OpenFOAM® history (Jasak’s apocryphe)
• 199x – development started by Charlie Hill
• 1993 – Jasak and Weller became primary developers
• 2000 – Jasak and Weller created Nabla Ltd, main developer of FOAM
• 2004 – due to internal conflict Nabla Ltd ceased to exist, OpenFOAM®
released under GPL license
5
6. OpenFOAM®: shipped capabilities
• Mesh generation/manipulation
• Using dictionary for blocks description
• Generation from STLs
• Import
• Solvers
• Incompressible and compressible Navier-Stokes on arbitrary (moving) meshes
• Combustion
• Heat transfer
• Multi-phase flows (VoF)
• Solid body deformation
• Pre-processing
• Turbulence generation
• Field initialisation
• Post-processing
• Probing and sampling
• Calculations on flow field
6
7. OpenFOAM®: advantages
• It available, it is free, one can freely modify it
• C++: operator overloading and templates
• Run-time selectable behaviour
• Extensibility
• Lots of readily available physicochemical models
• Steep learning curve
• Community
7
8. OpenFOAM® advantages: operator overloading and templates
8
{
…
// Updating sources with new temperature
greybody_radiation.Correct();
cooling_circuit.Correct();
fvScalarMatrix temperature_equation(
fvm::ddt(T)
+ fvm::div(phi, T)
- fvm::laplacian(alphaEff, T)
+ solidification.latent_heat());
…
// Adding energy brought by the load
load.AddTemperatureSource(temperature_equation);
temperature_equation.relax();
temperature_equation.solve();
rhok = 1.0 - alloy.betaT()*(T - alloy.Tref());
}
9. OpenFOAM® advantages: operator overloading and templates
9
namespace Foam
{
template<class T>
inline void Swap(T& a, T& b)
{
T tmp = a;
a = b;
b = tmp;
}
} // End namespace Foam
• Express type-independent algorithms (typical example - sort)
• Allow compile time specialisation of the function and data structures,
aka safe alternative to preprocessor
• Avoid certain verbosity
10. OpenFOAM® advantages: run-time selectable behaviour
10
• Simulation behaviour is described in a set of dictionaries with relatively
documented syntax
• Run-time selection mechanism is well-polished, though could be
verbose
solvers
{
p
{
solver GAMG;
tolerance 1e-08;
relTol 0.1;
smoother DICGaussSeidel;
}
U
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-08;
relTol 0.01;
}
}
11. OpenFOAM® advantages: extensibility and freedom
11
• Well defined API and procedure for extension
• User can start from code stream (coded initial/boundary conditions,
coded post-processing)
• And then proceed with implementation of custom library
• If standard solvers/libraries are completely unsuitable for the purpose,
everything could be rewritten from scratch
12. OpenFOAM® examples: drop formation and detachment
Ti drop(s) (𝜚 = 4200 kg/m3, 𝛾 = 1.2 N/m)
Flow rate ~ 0.1 mm/s
8M cells, decomposed into 84 subdomains, 0.5 T of data
* P. Chapelle, C. Noël, A. Risacher, J. Jourdan, A.
Jardy, J. Jourdan, Optical investigation of the
behavior of the electric arc and the metal transfer
during vacuum remelting of a Ti alloy, Journal of
Materials Processing Technology, vol. 214,
2268-2275 (2014).
12
13. OpenFOAM® examples: electron beam melting
Problem
Create a 3D solver for modelling of remelting in
electron beam furnace.
Solver should be capable of describing the
following phenomena:
• Electron beam energy deposition.
• Phase change.
• Momentum and heat transfer inside
specimen.
• Turbulence development in the liquid pool.
• Cooling through radiation and water
cooling circuit.
• Evaporation of solutes.
Electron beam
Radiative
heat transfer
Water cooling
13
16. OpenFOAM® examples: vacuum arc remelting
Problem
Create a 3D solver for modelling of vacuum arc
remelting process.
Solver should address the following phenomena:
• Ingot growth.
• Electric arc energy deposition.
• Electric current and induced magnetic field,
volumetric forces created by interaction between
them.
• External magnetic field
• Phase change.
• Momentum, heat, and mass transfer inside
ingot.
• Turbulence development in the liquid pool.
• Cooling through radiation and water cooling
circuit.
• Evaporation of solutes.
• Macrosegregation.
DC
Pump
Water in
Water out
Electrode
Solid ingot
Liquid pool
Copper crucible
Arc
Gas
16
26. OpenFOAM®: idiosyncrasies and annoyances
• Fragmentation, versioning, packaging
• C++: heavy use of preprocessor and templates
• Weight
• Documentation or lack of
• License
• Community
26
29. OpenFOAM®: C++: heavy use of preprocessor and templates
error-example.C: Dans la fonction « int main(int, char**) »:
error-example.C:44:37: error: pas de fonction correspondant à l'appel
« gSum(Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>
>) »
Info<< gSum(fvc::grad(T)) << endl;
In file included from $FOAM_SRC/OpenFOAM/lnInclude/Field.C:87
from $FOAM_SRC/OpenFOAM/lnInclude/Field.H:40
from $FOAM_SRC/OpenFOAM/lnInclude/scalarFiel
from $FOAM_SRC/OpenFOAM/lnInclude/dimensionS
from $FOAM_SRC/OpenFOAM/lnInclude/dimensione
from $FOAM_SRC/OpenFOAM/lnInclude/dimensione
from $FOAM_SRC/OpenFOAM/lnInclude/TimeState.
from $FOAM_SRC/OpenFOAM/lnInclude/Time.H:47,
from $FOAM_SRC/finiteVolume/lnInclude/fvCFD.
from error-example.C:18:
$FOAM_SRC/OpenFOAM/lnInclude/FieldFunctions.C:543:24: note: c
G_UNARY_FUNCTION(Type, gSum, sum, sum)
^
$FOAM_SRC/OpenFOAM/lnInclude/FieldFunctions.C:533:12: note: d
ReturnType gFunc(const UList<Type>& f, const label comm)
^~~~~
$FOAM_SRC/OpenFOAM/lnInclude/FieldFunctions.C:543:24: note:
G_UNARY_FUNCTION(Type, gSum, sum, sum)
^
[— several pages later —]
$FOAM_SRC/OpenFOAM/lnInclude/FieldFieldFunctions.C:400:12: no
returnType func(const tmp<FieldField<Field, Type>>& tf1)
^~~~
$FOAM_SRC/OpenFOAM/lnInclude/FieldFieldFunctions.C:559:1: not
G_UNARY_FUNCTION(Type, gSum, sum, sum)
^~~~~~~~~~~~~~~~
error-example.C:44:37: note: types « Foam::FieldField<Field, Type> » et « Foam::Geometri
Info<< gSum(fvc::grad(T)) << endl;
^ 29
31. OpenFOAM®: documentation
• OpenFOAMUseGuide-(A4|USletter).pdf in distribution
• Doxygen generated API reference
• Due to fast evolution OpenFOAMProgrammerGuide was removed from
distribution (becomes outdated too fast)
• « Source code is documentation » philosophy
• Dictionary syntax is usually documented in headers of models, often
comments are misleading/outdated
31
32. • Office 1-008
• OpenFOAM® consulting
• On-demand development
• Transform PDEs into OpenFOAM® C++ code
• Transform process into a set of PDE/ODEs and transform them
OpenFOAM® C++ code
O2M Solutions
32