Object-Oriented CFD Solver Design

Hrvoje Jasak
h.jasak@wikki.co.uk

Wikki Ltd. United Kingdom 10/Mar2005

Object-Oriented CFD Solver Design – p.1/29

Outline
Objective • Present new approach to software design in Computational Continuum Mechanics Topics • A new approach to model representation • Object-orientation in numerical simulation software: code re-use and layered design • Examples of complex model implementation

Object-Oriented CFD Solver Design – p.2/29

3/29 .Background State of the Art • Numerical modelling is becoming a part of product design ◦ Improved computing performance ◦ Improved modelling ◦ Sufficient validation and experience • Two-fold requirements ◦ Ease of use and process integration ◦ Quick and reliable model implementation Object-Oriented CFD Solver Design – p.

studied in isolation • Clearly defined objective • Numerical software sometimes limiting design: e.4/29 .Software Design “Physics-based” approach • Traditional view of the problem • Well defined physics. Lockheed Martin F-117 Stealth Typically handled by monolithic software with well-defined capabilities Object-Oriented CFD Solver Design – p.g.

unexpected conclusions • Made-to-measure modelling Requires more flexible software design: can object orientation help? Object-Oriented CFD Solver Design – p.5/29 .Software Design “Application-based” approach • A collection of components involving various physics phenomena (beyond CFD) • Complex model-to-model interaction • Complex simulation and optimisation objectives.

6/29 .FOAM: CCM in C++ FOAM: Field Operation and Manipulation • Natural language of continuum mechanics: partial differential equations ∂k + ∂t • (uk) − νt • [(ν + νt ) k] = 2 1 ( u+ 2 u ) T − o ko k Object-Oriented CFD Solver Design – p.

fvm::laplacian(nu() + nut. k) ). k) .FOAM: CCM in C++ Objective: Represent equations in software in the natural language solve ( fvm::ddt(k) + fvm::div(phi.fvm::Sp(epsilon/k. k) == nut*magSqr(symm(fvc::grad(U))) . Object-Oriented CFD Solver Design – p.7/29 .

time vector. sin(). exp() . laplacian Library main() C++ Class polyMesh. fam turbulenceModel – Object-Oriented CFD Solver Design – p. grad. curl Matrix coefficients ddt. d2dt2. div. fem. . Differencing schemes ddt.FOAM: CCM in C++ Object Space and time Tensor Field Boundary condition Geometric field Field algebra Interpolation Differentiation Matrix Discretisation Model library Application Software representation Mesh + time (database) (List of) numbers + algebra List of values Values + condition Field + boundary conditions + − ∗ / tr().8/29 . . tensor Field patchField geometricField field operators interpolation fvc. div. fec lduMatrix fvm.

FOAM: CCM in C++ Common interface for related models class turbulenceModel { virtual volTensorField R() const = 0. Object-Oriented CFD Solver Design – p. class SpalartAllmaras : public turbulenceModel{}.9/29 . virtual fvVectorMatrix divR ( volVectorField& U ) const = 0. }. virtual void correct() = 0.

FOAM: CCM in C++ Model-to-model interaction fvVectorMatrix UEqn ( fvm::ddt(rho.fvc::grad(p) ). New components do not disturb existing code Object-Oriented CFD Solver Design – p.10/29 . U) + fvm::div(phi. U) + turbulence->divR(U) == .

not exception • Polyhedral cell support ◦ Cell described as a polyhedron bounded by polygons ◦ Consistent handling of all cell types ◦ More freedom in mesh generation • Recent developments: polyhedral FVM provides equivalent accuracy at lower cost Object-Oriented CFD Solver Design – p.Geometry Handling Complex geometry requirements • Complex geometry is a rule.11/29 .

Geometry Handling Object-Oriented CFD Solver Design – p.12/29 .

Geometry Handling Time-varying geometry cases • Automatic mesh motion • Topological mesh changes with poly support Object-Oriented CFD Solver Design – p.13/29 .

14/29 .Speed of Execution Handling large-scale computations • Efficient numerics ◦ Best discretisation practice for a given problem ◦ Iterative solvers almost inevitable ◦ Careful analysis of non-linearity and inter-equation coupling • Massive parallelism: domain decomposition Object-Oriented CFD Solver Design – p.

15/29 .Layered Development • Design encourages code re-use: shared tools • Code developed and tested in isolation ◦ Vectors. boundary conditions ◦ Matrices and solver technology ◦ Physics by segment ◦ Custom applications • Ultimate user-coding capabilities! Object-Oriented CFD Solver Design – p. topo changes ◦ Discretisation. tensors and field algebra ◦ Mesh handling. refinement.

Examples of Application Objective: illustrate examples of FOAM library in use • Diesel Combustion: Scania D-12 Engine • Free surface flow modelling ◦ Capillary jets. LES + free surface ◦ Surface tracking: rising bubble • Solid-fluid interaction: plastic pipeline failure Object-Oriented CFD Solver Design – p.16/29 .

k − turbulence model. simplified 5-species chemistry and 1 reaction. Chalmers PaSR combustion model • Temperature on a cutting planes • Spray droplets coloured with temperature Object-Oriented CFD Solver Design – p.17/29 .Diesel Combustion Diesel Combustion in Scania D-12 Engine • 1/8 sector with 75 % load and n-heptane fuel • RANS.

Diesel Combustion Diesel Combustion in Scania D-12 Engine Object-Oriented CFD Solver Design – p.18/29 .

19/29 . umean = 20m/s • Tuning frequency (50kHz) and amplitude (5%) Object-Oriented CFD Solver Design – p. 20µm diameter • Pulsating flow.Capillary Jet Ink-jet printer nozzle.

5. no cavitation ◦ 1-equation LES model with no free surface correction ◦ Fully developed pipe flow inlet Object-Oriented CFD Solver Design – p.2MPa.2mm.20/29 . high velocity and surface tension • Mean injection velocity: 460m/s • Diesel fuel injected into air.Diesel Injector LES of a Diesel Injector • d = 0. 900K • Turbulent and subsonic flow.

aggressive local refinement.Diesel Injector • Mesh size: 1. 50k time-steps • 6µs initiation time.2 to 8 million CVs.21/29 . 20µs averaging time Object-Oriented CFD Solver Design – p.

75 mm • 3-D: rb = 1 mm vF SB SA y o aF x rF y o x Free surface Object-Oriented CFD Solver Design – p. Air-water system • 2-D: rb = 0.22/29 .c.Surface tracking vb = −vF Free surface tracking • 2 phases = 2 meshes • Mesh adjusted for interface motion • Coupled b.

23/29 .Surfactant Effect Clean surface Pollution by surfactant chemicals Object-Oriented CFD Solver Design – p.

24/29 .3-D Rising Bubble Complex coupling problem: FVM flow solver + FEM mesh motion + FAM surfactants Object-Oriented CFD Solver Design – p.

25/29 .Fluid-Solid Coupling Pipeline failure: crack propagation and leakage Object-Oriented CFD Solver Design – p.

26/29 .Fluid-Solid Coupling Enlarged deformation of the pipe Object-Oriented CFD Solver Design – p.

27/29 .Other Capabilities FOAM contains other capabilities as well • RANS and LES turbulence modelling • Thermophysical and transport model libraries • A-posteriori error estimation • Adaptive mesh refinement Software used for algorithm and numerics research: excellent numerics and pre-implemented models Object-Oriented CFD Solver Design – p.

Vlado Tropša.org Object-Oriented CFD Solver Design – p. Chalmers University Sweden • Spray breakup: Eugene de Villiers. prof.openfoam. Niklas Nordin.28/29 .Summary • Object-oriented approach facilitates model implementation: layered design + re-use • Equation mimicking opens new CCM grounds • Extensive capabilities already implemented • Open design for easy user customisation Acknowledgements • Scania engine: Dr. A Ivankovi c. Imperial College ´ • Cracking pipe: Dr. UC Dublin • Foam and OpenFOAM are released under GPL: http://www.

Lagrangian tracking and Finite Area methods • Efficiency through massive parallelism Object-Oriented CFD Solver Design – p.FOAM: CCM in C++ Main characteristics • Wide area of applications: all of CCM! • Shared tools and code re-use Versatility • Unstructured meshes. automatic mesh motion + topological changes • Finite Volume.29/29 . Finite Element.

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.