Computational Fluid Dynamics using OpenCL a Practical Introduction

Similar documents
Lab 9: FLUENT: Transient Natural Convection Between Concentric Cylinders

FOURTH ORDER COMPACT FORMULATION OF STEADY NAVIER-STOKES EQUATIONS ON NON-UNIFORM GRIDS

Driven Cavity Example

MESHLESS SOLUTION OF INCOMPRESSIBLE FLOW OVER BACKWARD-FACING STEP

Investigation of cross flow over a circular cylinder at low Re using the Immersed Boundary Method (IBM)

IJISET - International Journal of Innovative Science, Engineering & Technology, Vol. 2 Issue 11, November

cuibm A GPU Accelerated Immersed Boundary Method

CGT 581 G Fluids. Overview. Some terms. Some terms

Flow and Heat Transfer in a Mixing Elbow

Visualization of three-dimensional incompressible flows by quasitwo-dimensional

Using a Single Rotating Reference Frame

NUMERICAL VISCOSITY. Convergent Science White Paper. COPYRIGHT 2017 CONVERGENT SCIENCE. All rights reserved.

Computational Study of Laminar Flowfield around a Square Cylinder using Ansys Fluent

Faculty of Mechanical and Manufacturing Engineering, University Tun Hussein Onn Malaysia (UTHM), Parit Raja, Batu Pahat, Johor, Malaysia

1.2 Numerical Solutions of Flow Problems

Pressure Correction Scheme for Incompressible Fluid Flow

Introduction to ANSYS CFX

CFD MODELING FOR PNEUMATIC CONVEYING

Benchmark tests of Parallel PHOENICS for Windows (collected by jzw, 2006; edited by dbs)

Introduction to C omputational F luid Dynamics. D. Murrin

Available online at ScienceDirect. Parallel Computational Fluid Dynamics Conference (ParCFD2013)

LS-DYNA 980 : Recent Developments, Application Areas and Validation Process of the Incompressible fluid solver (ICFD) in LS-DYNA.

Performance of Implicit Solver Strategies on GPUs

IMAGE ANALYSIS DEDICATED TO POLYMER INJECTION MOLDING

Analysis, extensions and applications of the Finite-Volume Particle Method (FVPM) PN-II-RU-TE Synthesis of the technical report -

Stream Function-Vorticity CFD Solver MAE 6263

Program: Advanced Certificate Program

ENERGY-224 Reservoir Simulation Project Report. Ala Alzayer

Efficient Tridiagonal Solvers for ADI methods and Fluid Simulation

Parallelization study of a VOF/Navier-Stokes model for 3D unstructured staggered meshes

Ashwin Shridhar et al. Int. Journal of Engineering Research and Applications ISSN : , Vol. 5, Issue 6, ( Part - 5) June 2015, pp.

Verification and Validation of Turbulent Flow around a Clark-Y Airfoil

COMPUTATIONAL FLUID DYNAMICS ANALYSIS OF ORIFICE PLATE METERING SITUATIONS UNDER ABNORMAL CONFIGURATIONS

Speed and Accuracy of CFD: Achieving Both Successfully ANSYS UK S.A.Silvester

FAST ALGORITHMS FOR CALCULATIONS OF VISCOUS INCOMPRESSIBLE FLOWS USING THE ARTIFICIAL COMPRESSIBILITY METHOD

Modeling External Compressible Flow

Realistic Animation of Fluids

Free Convection Cookbook for StarCCM+

Introduction to Computational Fluid Dynamics Mech 122 D. Fabris, K. Lynch, D. Rich

A higher-order finite volume method with collocated grid arrangement for incompressible flows

2D numerical simulation of ocean waves

NUMERICAL 3D TRANSONIC FLOW SIMULATION OVER A WING

Block Nested Refinement and Numerical Estimation for Sudden Expansion Pipes in Various Step Angles

Backward facing step Homework. Department of Fluid Mechanics. For Personal Use. Budapest University of Technology and Economics. Budapest, 2010 autumn

CS205b/CME306. Lecture 9

Advanced Computation in the design and development of aircraft engines. Serge Eury SNECMA

CFD Analysis of 2-D Unsteady Flow Past a Square Cylinder at an Angle of Incidence

CFD Project Workflow Guide

Keywords: flows past a cylinder; detached-eddy-simulations; Spalart-Allmaras model; flow visualizations

Solving Partial Differential Equations on Overlapping Grids

Using the Discrete Ordinates Radiation Model

Express Introductory Training in ANSYS Fluent Workshop 04 Fluid Flow Around the NACA0012 Airfoil

Numerical and theoretical analysis of shock waves interaction and reflection

ALE Seamless Immersed Boundary Method with Overset Grid System for Multiple Moving Objects

Module D: Laminar Flow over a Flat Plate

Debojyoti Ghosh. Adviser: Dr. James Baeder Alfred Gessow Rotorcraft Center Department of Aerospace Engineering

Modelling of Levitation Melting using a Fixed Mesh Method

Possibility of Implicit LES for Two-Dimensional Incompressible Lid-Driven Cavity Flow Based on COMSOL Multiphysics

SENSEI / SENSEI-Lite / SENEI-LDC Updates

A COUPLED FINITE VOLUME SOLVER FOR THE SOLUTION OF LAMINAR TURBULENT INCOMPRESSIBLE AND COMPRESSIBLE FLOWS

Investigation of mixing chamber for experimental FGD reactor

Preliminary Spray Cooling Simulations Using a Full-Cone Water Spray

Two-Phase flows on massively parallel multi-gpu clusters

Realistic Animation of Fluids

Comparison of Classic and Finned Piston Reciprocating Linear Air Compressor Using COMSOL Multiphysics

Multigrid Solvers in CFD. David Emerson. Scientific Computing Department STFC Daresbury Laboratory Daresbury, Warrington, WA4 4AD, UK

Tutorial: Heat and Mass Transfer with the Mixture Model

Numerical Wave Tank Modeling of Hydrodynamics of Permeable Barriers

Verification and Validation in CFD and Heat Transfer: ANSYS Practice and the New ASME Standard

Bidimensional modeling for incompressible viscous flow using the Circumcenter Based Approach in an unstructured grid

Coupled Analysis of FSI

Large-scale Gas Turbine Simulations on GPU clusters

Porting a parallel rotor wake simulation to GPGPU accelerators using OpenACC

Use of CFD in Design and Development of R404A Reciprocating Compressor

NUMERICAL INVESTIGATION OF THE FLOW BEHAVIOR INTO THE INLET GUIDE VANE SYSTEM (IGV)

3D ADI Method for Fluid Simulation on Multiple GPUs. Nikolai Sakharnykh, NVIDIA Nikolay Markovskiy, NVIDIA

Steady Flow: Lid-Driven Cavity Flow

Computational Fluid Dynamics as an advanced module of ESP-r Part 1: The numerical grid - defining resources and accuracy. Jordan A.

Application of CFD to Industrial Safety Studies (with Prediction Accuracy and Error estimations)

A 3D VOF model in cylindrical coordinates

Computation of Velocity, Pressure and Temperature Distributions near a Stagnation Point in Planar Laminar Viscous Incompressible Flow

FEMLAB Exercise 1 for ChE366

Auto Injector Syringe. A Fluent Dynamic Mesh 1DOF Tutorial

A Novel Approach to High Speed Collision

Tutorial 1. Introduction to Using FLUENT: Fluid Flow and Heat Transfer in a Mixing Elbow

Case Study - Computational Fluid Dynamics (CFD) using Graphics Processing Units

Numerical studies for Flow Around a Sphere regarding different flow regimes caused by various Reynolds numbers

Numerical Methods in Aerodynamics. Fluid Structure Interaction. Lecture 4: Fluid Structure Interaction

Large Eddy Simulation of Flow over a Backward Facing Step using Fire Dynamics Simulator (FDS)

Developing a New Design to Improve Radiation Heat Transfer in an Oven-Like Cavity

Development of an Integrated Computational Simulation Method for Fluid Driven Structure Movement and Acoustics

Parallel Direct Simulation Monte Carlo Computation Using CUDA on GPUs

c Fluent Inc. May 16,

This tutorial illustrates how to set up and solve a problem involving solidification. This tutorial will demonstrate how to do the following:

Compressible Flow in a Nozzle

Modeling and Simulation of Single Phase Fluid Flow and Heat Transfer in Packed Beds

Microwell Mixing with Surface Tension

The Development of a Navier-Stokes Flow Solver with Preconditioning Method on Unstructured Grids

Partial Differential Equations

Introduction to CFX. Workshop 2. Transonic Flow Over a NACA 0012 Airfoil. WS2-1. ANSYS, Inc. Proprietary 2009 ANSYS, Inc. All rights reserved.

Transcription:

19th International Congress on Modelling and Simulation, Perth, Australia, 12 16 December 2011 http://mssanz.org.au/modsim2011 Computational Fluid Dynamics using OpenCL a Practical Introduction T Bednarz 1, Luke Domanski 2 and J A Taylor 3 1 CSIRO Mathematics Informatics & Statistics, Sydney, Australia. Email: tomasz.bednarz@csiro.au) 2 CSIRO Advanced Scientific Computing, Sydney, Australia 3 CSIRO Mathematics Informatics & Statistics, Canberra, Australia Abstract: The main aim of the Computational Fluid Dynamics (CFD) simulations is to reconstruct the reality of fluid motion and behaviour as accurately as possible in order to better understand the natural phenomena under specified conditions. Ideally, general solutions can also cover different scales and geometric configurations. Unfortunately, due to expensive algorithms, classic CFD codes most often require long computational times to satisfy the convergence criteria. With the advent of high-performance GPUs with massively-parallel multi-threaded architectures, basic CFD algorithms can now be implemented to give results in near real-time. The current work will briefly review our existing explicit solver based on finite difference methods, the derivation and discretisation of the mathematical model and equations, through to GPU algorithm implementation. During presentation, several case studies computed using CSIRO's CPU/GPU supercomputer cluster will be described and compared against well known analytical and experimental solutions, i.e. natural convection, driven cavity, scaling analysis, magneto-thermal convection, etc. Keywords: Computational Fluid Dynamics, Simulations, Numerical Modelling 608

1. INTRODUCTION AND MODEL EQUATIONS Experiments with fluids are usually very expensive and many times not feasible, or require work in harmful environments, etc. Therefore, in such cases, we re trying to replace them with numerical modelling whenever possible. Here comes Computational Fluid Dynamics (CFD) that aims to reconstruct the reality of fluid motion and behaviour as accurately as possible in order to better understand the natural phenomena under specified conditions. Ideally, general solutions can also cover different scales and geometric configurations and should be with an agreement with equivalent experimental results. Unfortunately, due to expensive algorithms, classic CFD codes most often require long computational times to satisfy the convergence criteria. With the advent of high-performance GPUs with massively-parallel multi-threaded architectures, basic CFD algorithms can now be implemented to give results in near realtime. The algorithms used to solve these problems utilize GPU and in this case OpenCL. Presented results demonstrate that GPU can be successfully used to accelerate fluid simulations. We have seen significant gains in productivity and opportunity as a result of leveraging GPUs, being able to tackle computational problems in which execution time was previously infeasible. 1.1. Model equations In order to solve general incompressible thermo-fluids problems in Cartesian coordinate system, the Navier- Stokes and energy equations can be defined as follows: U = 0 (1) DU Dt = C 1 P + C 2 2 U + C 3 (θ C 4 ) (2) Dθ Dt = C 5 2 θ (3) U is the velocity, t is the time, P is the pressure, θ is the temperature and coefficients C 1 to C 5 will where depend on a specific case considered. The same methodology can be applied to simulate wide range of different fluid flows: pipe flows, force convections, magneto-thermal convection, scaling analysis, exchange flows in reservoir model, mixing, fountain flows, bubble flow, step flows, heat exchangers, ventilation problems, etc. For instance, if under the consideration is a square cavity heated from one vertical wall and cooled from the opposite one with top and bottom walls kept adiabatic, those coefficients for dimensionless solution are defined as follows: C 1 =1; C 2 = Pr = ν α ; C = Pr Ra = ν gβ (Δθ)l3 3 ; C 4 = 0; C 5 =1.0 (4) α αν where ν is the kinematic viscosity, α is the thermal diffusivity, g is the gravitational acceleration, β is the thermal expansion coefficient, Δθ is the maximum temperature difference, l is the length of the cube, Pr is the Prandl number describing ratio of momentum and thermal diffusivities and Ra is the Rayleigh number associated with buoyancy driven flow describing strength of the convection. 2. NUMERICAL APPROACH Those equations are approximated with finite difference equations and the HSMAC (Highly Simplified Marker and Cell) method (Bednarz et al. 2005-2010, Hirt 1975) is used to iterate mutually the pressure and velocity fields on staggered mesh/grid allocation system, see Figure 1. The inertial terms in momentum equations are approximated using a third-order upwind UTOPIA scheme (Tagawa 1996). The absolute convergence criteria for the numerical solutions are specified based on the residual sums of all conserved quantities. If the residual sum is less than 10-6 for each conserved quantity, the equations are deemed to have converged at a specific time step. The time-step is chosen to ensure numerical stability according to the CFL condition. The numerical methods used in this work for simulation of natural convection have been widely verified by co-workers, by both the numerical and the experimental investigations for closely related problems (Bednarz et al. 2005-2010). 609

Figure 1. Staggered mesh grid allocations prevents possible pressure oscillations. Left: for 2-D cases all scalar variables are defined in the centre of cells, and vector variables in at the centre of vertical and horizontal cell faces accordingly. Right: grid for 3-D cases. 3. OPENCL IMPLEMENTATION The numerical code is ported from CPU to GPU version using the OpenCL API, see references. This was motivated by the need of improving computation speed, as in some cases, e.g. computation of single case of boundary layer evolution (Bednarz et al. 2009) could take up to 12 hours on grid size 256x256. Therefore, all critical parts of previously available CPU code are re-implemented in several OpenCL kernels that could be executed by thousands simultaneous threads by a GPU. Figure 2 shows the flow chart of our HSMAC- OpenCL solver. As seen, the initialization part includes: reading initial configuration files describing geometry and parameters of the problem to be computed, allocating memory for all field variables (pressure, velocity components, temperatures and spatial coordinates), preparing boundary conditions flags (to mark regions where the boundaries are located and what is their type). Once that s done, the OpenCL is initialized, proper compute device is attached to its context and the CL program is compiled. Also the device memory buffers are created and filled with initial data. Figure 2. Flow char of the OpenCL solver. 610

The solver / runtime execution of all OpenCL kernels is controlled by host device (CPU). The flow chart shows two main loops: the outer loop, which is responsible for general time-step iterations and the inner loop used for mutual iteration of velocity and pressure fields to satisfy the continuity equation, before solving each energy equation time-step (Hirt 1975). For instance calculation of pressure and velocity correction is done by execution of the kernel krnl_pressure_velocity_correction, calculation of energy equation by krnl_energy, etc. In addition the interoperability feature of OpenCL with OpenGL can be used to visualize the results while they are still under computation. After reaching final time step, all results can be saved on disk for further analysis. Figure 3 shows simplified code snippet of sample OpenCL kernel being used to calculate vertical component of tentative velocity from momentum equation. Please notice, that all derivatives for vertical velocity are calculated at the middle of top vertical cell edge. For simplicity of presentation, convection acceleration is calculated using central approach. In real simulations, as mentioned UTOPIA was used for accuracy and stability. Figure 3. Simplified OpenCL kernel that calculates tentative, vertical velocity component from the momentum equation. 4. RESULTS AND CONCLUSIONS Figure 4 depicts total execution times to reach final time of t = 5 for natural convection simulations at Pr = 0.71 and Ra = 10 6 versus different grid sizes denoted in total cell numbers (product of grid sizes in X- and Y-direction). These results show potential speed-ups that can be achieved using GPU compute devices. Initial tests comparing GT 330M to Intel Core i7 showed average 30X speedup of GPU/CPU. Further, comparing S2050 execution times to GT 330M, there was additional ~7-9X speedup (which is approximately equivalent to the ratio of the number of streaming cores between those two GPUs). These results are indication of what can be achieved when using OpenCL with today s GPUs for solving explicitly the Navier-Stokes equation for natural convection flows, i.e. obtaining converged results in few minutes instead of 10-12 hours. 5. REFERENCES Bednarz, T., Tagawa, T., Kaneda, M., Ozoe, H., and Szmyd, J.S. (2005) The convection of air in a cubic enclosure with an electric coil inclined in general orientations, Fluid Dynamics Research, Vol. 36, No. 2, pp. 91-106. Bednarz, T., Lin, W., Patterson, J.C., Lei, C., and Armfield, S.W. (2009) Scaling for unsteady thermomagnetic convection boundary layer of paramagnetic fluids of Pr > 1 in microgravity conditions, International Journal of Heat and Fluid Flow, Vol. 30, Issue 6, pp. 1157-1170. 611

Bednarz, T., Caris, C., and Taylor, J. (2010) A practical introduction to Computational Fluid Dynamics on GPUs, GTC 2010, San Jose, USA, September 20-23. Botella, O., and Peyret, R. (1998) Benchmark spectral results on the lid-driven cavity flow, Computers & Fluids, Volume 27, Issue 4, Pages 421-433. CSIRO GPU cluster: http://www.csiro.au/resources/gpu-cluster.html. De Vahl Davis, G. (1983) Natural convection of air in a square cavity: a bench mark numerical solution, International Journal of Numerical Methods in Fluids, Vol 3, pp 249-264. Hirt, C.W., Nichols, B.D., and Romero, N. (1975) A numerical solution algorithm for transient fluid flow, Los Alamos Scientific Laboratory, LA-5852. OpenCL: http://www.khronos.org/opencl/ Tagawa, T., and Ozoe, H. (1996) Effect of Prandtl number and computational schemes on the oscillatory natural convection in an enclosure, Numerical Heat Transfer A 30, 271-282. Figure 4. Total execution times for S2050 and GT330M against number of computational cells and converged temperature contours for Pr = 0.71 and Ra = 10 6 (left wall = heated, right wall = cooled). 612