OpenFOAM: Introduction, Capabilities and HPC Needs Hrvoje Jasak hrvoje.jasak@fsb.hr Faculty of Mechanical Engineering and Naval Architecture University of Zagreb, Croatia OpenFOAM: Introduction, Capabilities and HPC Needs p. 1
Background Objective Provide basic information about OpenFOAM software from User s viewpoint What is it? How do I run it? What capabilities does it have? Examine mode of use and HPC requirements in CFD Present examples of capabilities relevant to your needs Topics OpenFOAM: Executive Overview Running OpenFOAM Points of interest: why consider OpenFOAM HPC requirements in CFD Examples of capabilities 1. External aerodynamics 2. Free surface flows 3. CFD and geometric shape optimisation 4. OpenFOAM Turbo Tools 5. Vehicle soiling: Lagrangian tracking, finite area method and liquid film 6. Coupled simulations and Fluid-Structure coupling (FSI) OpenFOAM: Introduction, Capabilities and HPC Needs p. 2
OpenFOAM: Executive Overview What is OpenFOAM? OpenFOAM is a free-to-use Open Source numerical simulation software with extensive CFD and multi-physics capabilities Free-to-use means using the software without paying for license and support, including massively parallel computers: free multi-1000-cpu CFD license! Software under active development, capabilities mirror those of commercial CFD Substantial installed user base in industry, academia and research labs Possibility of extension to non-traditional, complex or coupled physics: Fluid-Structure Interaction, complex heat/mass transfer, internal combustion engines, nuclear Main Components Discretisation: Polyhedral Finite Volume Method, second order in space and time Lagrangian particle tracking, Finite Area Method (2-D FVM on a curved surface) Massive parallelism in domain decomposition mode Automatic mesh motion (FEM), support for topological changes All components implemented in library form for easy re-use Physics model implementation through equation mimicking OpenFOAM: Introduction, Capabilities and HPC Needs p. 3
Implementing Continuum Models Equation Mimicking Natural language of continuum mechanics: partial differential equations Example: turbulence kinetic energy equation k t + (uk) [(ν +ν t) k] = ν t [ ] 1 2 2 ( u+ ut ) ǫ o k k o Objective: represent differential equations in their 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) ); Correspondence between the implementation and the original equation is clear Library-based implementation of custom physical models with full freedom in solution algorithms. New: support for multi-equation implicit coupling OpenFOAM: Introduction, Capabilities and HPC Needs p. 4
OpenFOAM: Executive Overview Physical Modelling Capability Highlights Basic: Laplace, potential flow, passive scalar/vector/tensor transport Incompressible and compressible flow: segregated pressure-based algorithms Heat transfer: buoyancy-driven flows, conjugate heat transfer Multiphase: Euler-Euler, VOF free surface capturing and surface tracking RANS for turbulent flows: 2-equation, RSTM; full LES capability Pre-mixed and Diesel combustion, spray and in-cylinder flows Stress analysis, fluid-structure interaction, electromagnetics, MHD, etc. OpenFOAM: Introduction, Capabilities and HPC Needs p. 5
Running OpenFOAM Structure of OpenFOAM OpenFOAM is assembled from components Foundation libraries, containing discretisation, mesh handling etc. in re-usable form. Functionality shared across many application Physical modelling libraries: thermo-physical models (liquids and gasses), viscosity models, turbulence models, chemical reactions interface Utilities: mesh import and manipulation, parallel processing, post processor hook-up (reader module) and data manipulation Customised, purpose-written and optimised executables for each physics segment. All are founded on common components Linkage for user extensions and on-the-fly data analysis OpenFOAM Executable Custom executable for specific physics segment: few 100s of lines of code Easy to read, understand, modify or add further capability Existing code is used as a basis for own development: simulation environment Low-level functions, eg. mesh handling, parallelisation, data I/O handled transparently: no need for special coding at top level OpenFOAM: Introduction, Capabilities and HPC Needs p. 6
Point of Interest Why Consider OpenFOAM Open architecture Access to complete source: no secret modelling tricks, no cutting corners Both community-based and professional support available Common platform for new R&D projects: shipping results of research into the hands of a customer with no delay Low-cost CFD No license cost, portable to any computing platform (IBM Blue Gene) Easily scriptable and embeddable: automated CFD and optimisation Efficient on massively parallel computers, portable to new comms protocols Problem-independent numerics and discretisation Tackle non-standard continuum mechanics problem: looking beyond the capabilities of commercial CFD Efficient environment for complex physics problems Tackling difficult physics is made easier through equation mimicking Utility-level tools readily available: parallelism, moving mesh Track record in non-linear and strongly coupled problems Excellent piece of C++ and software engineering! Decent piece of CFD OpenFOAM: Introduction, Capabilities and HPC Needs p. 7
Massively Parallel Scaling Mesh size and resolution environment in 21st century are revolutionary different from (the comfortable) 1990s: thousands of processors, a billion cell mesh Complex hardware architecture without proper programming support complicates the programming and roll-out into real-world applications Still learning GPU lessons: potentially changing the way we write CFD codes back towards structured mesh codes and fixed internal infrastructure What about parallel CFD clouds: do we need custom infrastructure? OpenFOAM: Introduction, Capabilities and HPC Needs p. 8
Examples of Simulation Example of Capabilities of OpenFOAM Relevant to Your CFD Needs This is only a part of the OpenFOAM capabilities! Chosen for relevance and illustration of the range of capabilities rather than exhaustive illustration of range of capabilities In some cases, simplified geometry is used due to confidentiality Regularly, the work resulted in a new solver; in many cases, it is developed as an extension or combination of existing capabilities Description of Simulation and Setup Physics and numerical method setup Standard or customised solver; details of mesh resolution and customisation OpenFOAM: Introduction, Capabilities and HPC Needs p. 9
External Aerodynamics with LES Detached Eddy Simulation for External Aerodynamics Pushing state-of-the-art by applying Detached Eddy Simulation (DES) to full car body external aerodynamics simulations: native solver and mesher, no change Increase in simulation cost over transient RANS is over 1 order of magnitude! Controlling the Cost of Full Car DES: Automated meshing and simulation environment, from STL surface of the car body to averaged DES results and forces Hex-core mesher with near-wall layers and local refinement: mesh is designed to make it good for second-order LES numerics with minimal cost No parallel license cost of CFD solver: simulations run on approx. 200 CPUs Improvement in C D,C L and force-per-component predictions due to better capturing of turbulence and transient flow features Reproduced with permission SAE 2009-01-0333, Islam et.al. OpenFOAM: Introduction, Capabilities and HPC Needs p. 10
Free Surface Flows Free Surface Flow Simulations Efficient handling of interface breakup Accurate handling of dominant surface tension: no parasitic velocity OpenFOAM solver: interfoam, no modifications Ink-Jet Printer Nozzle, d = 20µm: Breakup Under Dominant Surface Tension Complex Surface Breakup Phenomena: Sloshing and wet wall impact OpenFOAM: Introduction, Capabilities and HPC Needs p. 11
Free Surface Flow Three-Phase Free Surface Flow in a Tundish 3 phases with extreme density ratio: liquid steel, liquid slag, air (7000:2500:1) Note the presence of multiple phase-to-phase interfaces: using consistent discretisation for multiple phase α equations Temperature-dependent properties of slag and steel Simultaneous filling and pouring with large outlet velocity Examples Simulation of a Turbo-Stop device for initial fill Simulated break-down of a slag layer: detail of flow at exit nozzle OpenFOAM: Introduction, Capabilities and HPC Needs p. 12
Free Surface Flow Naval Hydrodynamics Examples Naval hydrodynamics simulations require a special formulation of the free surface flow algorithm for robustness and accuracy Traditional steady-state VOF solver with under-relaxation Modified formulation for ship flows Incoming wave boundary conditions Numerical beach: damped boundary region removes wave reflection Support for dynamic mesh features Accurate reconstruction of the pressure field for moving bodies Post-processing and data extraction OpenFOAM: Introduction, Capabilities and HPC Needs p. 13
Complex Mesh Motion 6-DOF Floating Body in Free Surface Flow Flow solver: turbulent VOF free surface, with moving mesh support Mesh motion depends on the forces on the hull: 6-DOF solver 6-DOF solver: ODE + ODESolver energy-conserving numerics implemented using quaternions, with optional elastic/damped support Variable diffusivity Laplacian motion solver with 6-DOF boundary motion as the boundary condition for the mesh motion equation Topological changes to preserve mesh quality on capsize Coupled transient solution of flow equations and 6-DOF motion, force calculation and automatic mesh motion: custom solver is built from library components OpenFOAM: Introduction, Capabilities and HPC Needs p. 14
Complex Mesh Motion Dynamic Mesh Examples of Complex Combination of Motion and Sliding OpenFOAM: Introduction, Capabilities and HPC Needs p. 15
Geometric Shape Optimisation Geometric Shape Optimisation with Parametrised Geometry Specify a desired object of optimisation and use the parametrisation of geometry to explore the allowed solution space in order to find the minimum of the optimisation objective objective = f(shape) 1. Parametrisation of Geometry Computational geometry is complex and usually available as the computational mesh: a large amount of data Parametrisation tool: RBF mesh morphing, defining deformation at a small number of mesh-independent points in space 2. CFD Flow Solver is used to provide the flow solution on the current geometry, in preparation for objective evaluation 3. Evaluation of Objective: usually a derived property of the flow solution 4. Optimiser Algorithm: explores the solution space by providing sets of shape coordinates and receiving the value of objective. The search algorithm iteratively limits the space of solutions in search of a minimum value of objective OpenFOAM: Introduction, Capabilities and HPC Needs p. 16
Geometric Shape Optimisation Example: HVAC 90 deg Bend: Flow Uniformity at Outlet Flow solver: incompressible steady-turbulent flow, RANS k ǫ model; coarse mesh: 40 000 cells; 87 evaluations of objective with CFD restart RBF morphing: 3 control points in motion, symmetry constraints; 34 in total Objective: flow uniformity at outlet plane iter = 0 pos = (0.9 0.1 0.1) v = 22.914 size = 0.69282 iter = 5 pos = (0.1 0.1 0.1) v = 23.0088 size = 0.584096 iter = 61 pos = ((0.990164 0.992598 0.996147) v = 13.5433 size = 0.000957 OpenFOAM: Introduction, Capabilities and HPC Needs p. 17
OpenFOAM Turbo Tools General Grid Interface Turbomachinery CFD requires additional features: implemented in library form General Grid Interface (GGI) and its derived forms Cyclic GGI Partial overlap GGI Mixing plane interface (under testing) Implementation and parallelisation is complete: currently running validation cases in collaboration with commercial clients and Turbomachinery Working Group Other turbo-related components in pipeline: harmonic balance solver solver Library-level implementation allows re-use of GGI beyond turbomachinery OpenFOAM: Introduction, Capabilities and HPC Needs p. 18
Multi-Phase Compressibility Simulation of Under-Water Explosions This is ongoing collaboration with Johns Hopkins APL, Penn State University and Wikki: working hard for almost a year Dominating effects of compressibility in air and water: massive change in density, with propagating pressure waves Pressure ranges from 500 bar to 20 Pa Stiff numerics: collapse of over-expanded bubble due to combined compressibility of both phases are the basis of the phenomenon Test cases: Rayleigh-Plesset oscillation, undex under a plate, explosion Eric Paterson, Scott Miller, David Boger, Penn State; Ashish Nedungadi, JHU-APL OpenFOAM: Introduction, Capabilities and HPC Needs p. 19
Multi-Phase Compressibility First Simulations of Under-Water Explosions: Eric Paterson, Penn State Bubble of high initial pressure expands after explosion Initial pressure pulse is very fast - with little effect Bubble collapse creates re-entrant jer which pierces the free surface Stability problems resolved in segregated solver Next phase: block-coupled p α solution algorithm OpenFOAM: Introduction, Capabilities and HPC Needs p. 20
Lagrangian Phase Model Lagrangian Particle Modelling Particles are modelled in Lagrangian framework: tracked through fluid domain Equation of motion for a Lagrangian particle: m p dv p dt = 1 2 ρ v v P (v v P ) d2 pπ 4 C D +m p g ρ l ρ ρ l +F p where m p is the particle mass v p is the particle velocity v is fluid velocity d p is particle diameter C D is the drag coefficient g is the gravitational acceleration ρ l is the particle (liquid) density ρ is the fluid density F p is the force on the particle due to the fluid pressure gradient OpenFOAM: Introduction, Capabilities and HPC Needs p. 21
Lagrangian Phase Model Integration of Motion Equation Motion equation for a particle is an Ordinary Differential Equation (ODE) During integration, particle traverses a number of cells and continuous phase properties are updated based on its position For accurate integration, motion equation is formulated as an ODE and solver using an ODE solver Particle Tracking Cell-to-face-to-cell tracking: no inverted Jacobians, no lost particles If more accurate integration is necessary, sub-cycling is used Integration stencil U OpenFOAM: Introduction, Capabilities and HPC Needs p. 22
Lagrangian Phase Model Solid Particles with Wall Interaction Using particle tracking code with physics equations attached to a particles Particle-to-particle interaction: proximity model with correction Wall interaction model: bounce with energy loss Diesel Spray Model Consists of a parcel, injector, spray and a set of sub-models parcel class: a particle represents a population of droplets: mean diameter and statistical distribution of particle size and other properties Cloud of parcels = Diesel spray: spray Example: Junwei Su, Imperial College and Xi an Jiaotong University, China OpenFOAM: Introduction, Capabilities and HPC Needs p. 23
Finite Area Method Finite Area Discretisation Finite Area Method discretised equations on a curved surface in 3-D Surface is discretised using polygonal faces. Discretisation takes into account surface curvature. A level of smoothness is assumed in calculation of curvature terms Surface motion is allowed: decomposed into normal and tangential motion Nomenclature for a surface element P and its neighbour N n f j n P e L e n N e e m P i d e N S P OpenFOAM: Introduction, Capabilities and HPC Needs p. 24
Thin Liquid Film Model Modelling Assumptions: 2-D Approximation of a Free Surface Flow Isothermal incompressible laminar flow Boundary layer approximation: Tangential derivatives are negligible compared to normal Normal velocity component is negligible compared to tangential Pressure is constant across the film depth Similitude of the flow variables in the direction normal to the substrate Prescribed cubic velocity profile S fs h v S w σ v n v fs p g v g m d,i v d,i Dependent variables: h and v v = 1 h h 0 vdh v(η) = v fs diag(aη +bη 2 +cη 3 ) η = n h, 0 n h OpenFOAM: Introduction, Capabilities and HPC Needs p. 25
Thin Liquid Film Model Validation: Droplet Spreading Under Surface Tension Liquid film equations governing the flow; self-similar velocity profile Droplet spread driven by gravity and counteracted by surface tension Equation set possesses an (axi-symmetric) analytical solution: validation of implementation and numerics 4e-05 3.5e-05 3e-05 t = 0.000 s t = 0.015 s Analytical solution 2.5e-05 h, m 2e-05 1.5e-05 1e-05 5e-06 0 0 0.0005 0.001 0.0015 0.002 r, m Implementation of Liquid Film Model Volume-Surface-Lagrangian Coupling Full second order in space and time on curved moving surfaces Parallelisation bound to volumetric FVM Shared matrix and discretisation: possibility of close coupling with FVM OpenFOAM: Introduction, Capabilities and HPC Needs p. 26
Coupling Wall Film with Spray Volume-Surface-Lagrangian Coupling Coupling a volumetric flow model with Lagrangian particles for a dispersed phase to a thin liquid film model on the solid wall Custom solver In terms of numerics, coupling of volumetric, surface and Lagrangian models is easy to handle: different modelling paradigms Main coupling challenge is to implement all components side-by-side and control their interaction: volumetric-to-particle-to-surface data exchange Close coupling is achieved by sub-cycling or iterations over the system for each time-step OpenFOAM: Introduction, Capabilities and HPC Needs p. 27
Close Coupling: Matrix Level Assembling a Matrix for Conjugate Heat Transfer Problems OpenFOAM supports multi-region simulations, with possibility of separate addressing and physics for each mesh: multiple meshes, with local fields Some equations present only locally, while others span multiple meshes coupledfvscalarmatrix TEqns(2); TEqns.hook ( fvm::ddt(t) + fvm::div(phi, T) - fvm::laplacian(dt, T) ); TEqns.hook ( fvm::ddt(tsolid) - fvm::laplacian(dtsolid, Tsolid) ); TEqns.solve(); Coupled solver handles multiple matrices together in internal solver sweeps: arbitrary matrix-to-matrix and domain-to-domain coupling OpenFOAM: Introduction, Capabilities and HPC Needs p. 28
Linear Algebra and Solver Support Example: Conjugate Heat Transfer Coupling may be established geometrically: adjacent surface pairs Each variable is stored only on a mesh where it is active: (U, p, T) Choice of conjugate variables is completely arbitrary: e.g. catalytic reactions Coupling is established only per-variable: handling a general coupled complex physics problem rather than conjugate heat transfer problem specifically Allows additional models to be solved on each region without overhead: structural stress analysis, turbulence or LES OpenFOAM: Introduction, Capabilities and HPC Needs p. 29
Fluid-Structure Interaction Fluid-Structure Coupling Capabilities in OpenFOAM As a Continuum Mechanics solver, OpenFOAM can deal with both fluid and structure components: easier setup of coupling (Parallelised) surface coupling tools implemented in library form: facilitate coupling to external solvers without coupling libraries using proxy surface mesh Structural mechanics in OpenFOAM targeted to non-linear phenomena: consider best combination of tools Large deformation formulation in absolute Lagrangian formulation Independent parallelisation in the fluid and solid domain Parallelised data transfer in FSI coupling Dynamic mesh tools and boundary handling used to manipulate the fluid mesh OpenFOAM: Introduction, Capabilities and HPC Needs p. 30
Deployment and Support Deployment and Support OpenFOAM developed mainly on Linux/Unix: Windows and Mac OS X ports also exist but are not widely used. This needs to be improved: binary distribution for Mac OS X and native Microsoft Windows port Data input/output is in file form: there is no global graphical user interface that can be tailored to sufficient level of usability (work in progress) No built-in 3-D graphics; 2-D, graphing and sampling tools present External post-processing with integrated readers: parafoam (open source) OpenFOAM: Introduction, Capabilities and HPC Needs p. 31
Summary Project Status Summary OpenFOAM is a free software, available to all at no charge: GNU Public License Object-oriented approach facilitates model implementation Equation mimicking opens new grounds in Computational Continuum Mechanics Extensive capabilities already implemented; open design for easy customisation Solvers are validated in detail and match the efficiency of commercial codes Open Source model dramatically drops the cost of industrial CFD OpenFOAM in Research and Industry Technical development driven by Special Interest Groups & Birds-of-a-Feather Turbomachinery Ship Hydrodynamics Simulation of Engines Turbulence Fluid-Structure Interaction Multiphase Flows Aeroacoustics Combustion and explosions Solid Mechanics Documentation High Performance Computing OpenFOAM in Teaching Sixth OpenFOAM Workshop: Penn State University 13-16 June 2011 http://www.openfoamworkshop.org OpenFOAM: Introduction, Capabilities and HPC Needs p. 32