Upload
hadieu
View
240
Download
0
Embed Size (px)
Citation preview
Object-Oriented CFDSolver Design
Hrvoje Jasak
Wikki Ltd. United Kingdom
10/Mar2005
Object-Oriented CFD Solver Design – p.1/29
Outline
Objective
• Present new approach to software design inComputational Continuum Mechanics
Topics
• A new approach to model representation
• Object-orientation in numerical simulationsoftware: code re-use and layered design
• Examples of complex model implementation
Object-Oriented CFD Solver Design – p.2/29
Background
State of the Art
• Numerical modelling is becoming a part ofproduct 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.3/29
Software Design
“Physics-based” approach
• Traditional view of the problem
• Well defined physics, studied in isolation
• Clearly defined objective
• Numerical software sometimes limitingdesign: e.g. Lockheed Martin F-117 Stealth
Typically handled by monolithic software with
well-defined capabilities
Object-Oriented CFD Solver Design – p.4/29
Software Design
“Application-based” approach
• A collection of components involving variousphysics phenomena (beyond CFD)
• Complex model-to-model interaction
• Complex simulation and optimisationobjectives, unexpected conclusions
• Made-to-measure modelling
Requires more flexible software design:
can object orientation help?
Object-Oriented CFD Solver Design – p.5/29
FOAM: CCM in C++
FOAM: Field Operation and Manipulation
• Natural language of continuum mechanics:partial differential equations
∂k
∂t+ ∇•(uk) −∇•[(ν + νt)∇k] =
νt
[
1
2(∇u + ∇u
T )
]2
−εo
ko
k
Object-Oriented CFD Solver Design – p.6/29
FOAM: CCM in C++
Objective: Represent equations in software inthe natural language
solve
(
fvm::ddt(k)
+ fvm::div(phi, k)
- fvm::laplacian(nu() + nut, k)
== nut*magSqr(symm(fvc::grad(U)))
- fvm::Sp(epsilon/k, k)
);
Object-Oriented CFD Solver Design – p.7/29
FOAM: CCM in C++
Object Software representation C++ Class
Space and time Mesh + time (database) polyMesh, time
Tensor (List of) numbers + algebra vector, tensor
Field List of values Field
Boundary condition Values + condition patchField
Geometric field Field + boundary conditions geometricField
Field algebra + − ∗ / tr(), sin(), exp() . . . field operators
Interpolation Differencing schemes interpolation
Differentiation ddt, div, grad, curl fvc, fec
Matrix Matrix coefficients lduMatrix
Discretisation ddt, d2dt2, div, laplacian fvm, fem, fam
Model library Library turbulenceModel
Application main() –
Object-Oriented CFD Solver Design – p.8/29
FOAM: CCM in C++
Common interface for related models
class turbulenceModel
{
virtual volTensorField R() const = 0;
virtual fvVectorMatrix divR
(
volVectorField& U
) const = 0;
virtual void correct() = 0;
};
class SpalartAllmaras : public turbulenceModel{};
Object-Oriented CFD Solver Design – p.9/29
FOAM: CCM in C++
Model-to-model interaction
fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(phi, U)
+ turbulence->divR(U)
==
- fvc::grad(p)
);
New components do not disturb existing code
Object-Oriented CFD Solver Design – p.10/29
Geometry Handling
Complex geometry requirements
• Complex geometry is a rule, 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 FVMprovides equivalent accuracy at lower cost
Object-Oriented CFD Solver Design – p.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
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.14/29
Layered Development
• Design encourages code re-use: shared tools
• Code developed and tested in isolation◦ Vectors, tensors and field algebra◦ Mesh handling, refinement, topo changes◦ Discretisation, boundary conditions◦ Matrices and solver technology◦ Physics by segment◦ Custom applications
• Ultimate user-coding capabilities!
Object-Oriented CFD Solver Design – p.15/29
Examples of Application
Objective: illustrate examples of FOAM library inuse
• 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
Diesel Combustion
Diesel Combustion in Scania D-12 Engine
• 1/8 sector with 75 % load and n-heptane fuel
• RANS, k − ε turbulence model, simplified5-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
Object-Oriented CFD Solver Design – p.18/29
Capillary Jet
Ink-jet printer nozzle, 20µm diameter
• Pulsating flow, umean = 20m/s
• Tuning frequency (50kHz) and amplitude (5%)
Object-Oriented CFD Solver Design – p.19/29
Diesel Injector
LES of a Diesel Injector
• d = 0.2mm, high velocity and surface tension
• Mean injection velocity: 460m/s
• Diesel fuel injected into air, 5.2MPa, 900K
• Turbulent and subsonic flow, no cavitation◦ 1-equation LES model with no free surface
correction◦ Fully developed pipe flow inlet
Object-Oriented CFD Solver Design – p.20/29
Diesel Injector
• Mesh size: 1.2 to 8 million CVs, aggressivelocal refinement, 50k time-steps
• 6µs initiation time, 20µs averaging time
Object-Oriented CFD Solver Design – p.21/29
Surface tracking
rF
vF
vb = −vF
y
x
y′
x′
aF
o′SA
SB
o
Free
surface
Free surface tracking
• 2 phases = 2 meshes
• Mesh adjusted forinterface motion
• Coupled b.c.
Air-water system
• 2-D: rb = 0.75 mm
• 3-D: rb = 1 mm
Object-Oriented CFD Solver Design – p.22/29
Surfactant Effect
Clean surface
Pollution by surfactant chemicals
Object-Oriented CFD Solver Design – p.23/29
3-D Rising Bubble
Complex coupling problem: FVM flow solver +
FEM mesh motion + FAM surfactantsObject-Oriented CFD Solver Design – p.24/29
Fluid-Solid Coupling
Pipeline failure: crack propagation and leakage
Object-Oriented CFD Solver Design – p.25/29
Fluid-Solid Coupling
Enlarged deformation of the pipe
Object-Oriented CFD Solver Design – p.26/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 re-
search: excellent numerics and pre-implemented
models
Object-Oriented CFD Solver Design – p.27/29
Summary
• Object-oriented approach facilitates modelimplementation: layered design + re-use
• Equation mimicking opens new CCM grounds
• Extensive capabilities already implemented
• Open design for easy user customisation
Acknowledgements
• Scania engine: Dr. Niklas Nordin, Chalmers University Sweden
• Spray breakup: Eugene de Villiers, Imperial College
• Cracking pipe: Dr. Vlado Tropša, prof. A Ivankovic, UC Dublin
• Foam and OpenFOAM are released under GPL: http://www.openfoam.org
Object-Oriented CFD Solver Design – p.28/29
FOAM: CCM in C++
Main characteristics
• Wide area of applications: all of CCM!
• Shared tools and code re-use
Versatility
• Unstructured meshes, automatic meshmotion + topological changes
• Finite Volume, Finite Element, Lagrangiantracking and Finite Area methods
• Efficiency through massive parallelism
Object-Oriented CFD Solver Design – p.29/29