Computational Fluid Dynamics - CFD Francisco Palacios & Markus Widhalm fpalacios@gmail.com, markus.widhalm@dlr.de Basque Center for Applied Mathematics (BCAM). February 22nd to 26th, 2010 1
Grid generation Outline Motivation - CFD Process Chain Computer Aided Design - CAD Surface representation Computational grids Cartesian meshes Structured meshes Unstructured meshes Flow Simulation Metric preparation Spatial discretization Accuracy 2
CFD Process Chain CAD geometry CAD prep./ repair CATIA V4/5 CADFIX Watertight geom. Mesh generation Centaur MEGACADS ICEM-HEXA (SOLAR) CFD mesh Computation TAU FLOWer Results Coefficients Field data Surface data Conv. history Visualization Tecplot Fieldview Ensight Gold Pictures, movies, Slide 30.10.2008 3
CFD Process Chain CAD geometry Slide 30.10.2008 4
CFD Process Chain CAD geometry CAD prep./ repair CATIA V4/5 CADFIX Watertight geom. Mesh generation Centaur MEGACADS ICEM-HEXA (SOLAR) CFD mesh Computation TAU FLOWer Results Coefficients Field data Surface data Conv. history Visualization Tecplot Fieldview Ensight Gold Pictures, movies, Slide 30.10.2008 5
CFD Process Chain CAD prep./ repair CATIA V4/5 CADFIX Watertight geom. Slide 30.10.2008 6
CFD Process Chain CAD geometry CAD prep./ repair CATIA V4/5 CADFIX Watertight geom. Mesh generation Centaur MEGACADS ICEM-HEXA (SOLAR) CFD mesh Computation TAU FLOWer Results Coefficients Field data Surface data Conv. history Visualization Tecplot Fieldview Ensight Gold Pictures, movies, Slide 30.10.2008 7
CFD Process Chain Mesh generation Centaur MEGACADS ICEM-HEXA (SOLAR) CFD mesh block-structured mesh MEGACADS Hybrid mesh Centaur Slide 30.10.2008 8
CFD Process Chain CAD geometry CAD prep./ repair CATIA V4/5 CADFIX Watertight geom. Mesh generation Centaur MEGACADS ICEM-HEXA (SOLAR) CFD mesh Computation TAU FLOWer Results Coefficients Field data Surface data Conv. history Visualization Tecplot Fieldview Ensight Gold Pictures, movies, Slide 30.10.2008 9
CFD Process Chain Computation TAU FLOWer C 2 A 2 S 2 E Cluster (SUN) 16 compute racks, 48 blades 2 AMD Opteron quad core processor, 1.9 GHz (Barcelona) 768 nodes, 6144 cores 46.6 TFlop/s Peak performance TAU 1 core: 1 GFlop/s all cores: 3 TFlop/s 12.288 GB Main memory 16 GB per node (758 nodes) 32 GB per node ( 10 nodes) SUN Mega Switch Parallel file system (GPFS) High speed link to Airbus Bremen (100 Mbit/s) Dedicated to aircraft research 2010 performance update by factor 3 Slide 30.10.2008 10
CFD Process Chain Results Coefficients Field data Surface data Conv. history Visualization Tecplot Fieldview Ensight Gold Pictures, movies, Slide 30.10.2008 11
CFD Process Chain Results Coefficients Field data Surface data Conv. history Visualization Tecplot Fieldview Ensight Gold Pictures, movies, Virtual Reality Visualization and analysis of complex flow fields System available since spring 2007 Powerwall 2.7m x 2.0m 2 projectors IR tracking system 2 Dualcore Opteron processors Ensight gold 8.2 visualization software So far prototypic use of VR Goal: Integration of VR in routine work flow Slide 30.10.2008 12
Computer Aided Design - CAD Representation of flow body What makes a good solid representation? Accurate Concise concerning the formulation Intuitive specification Local support modification on certain input should result in local impact Affine invariant - frame independent Arbitrary topology Easy acquisition Guaranteed continuity and validity Efficient display Efficient boolean operations cutting of solids, efficient intersections 13
Computer Aided Design - CAD Classification Discrete Continuous Combinatorial Functional Explicit Implicit Parametric 14
Computer Aided Design - CAD Bezier curves A Bezier Curve is determined by Control Points. a parametric Bezier Curve is defined by P (t) = with the basis or blending function J n,i (t) = n B i J n,i (t) i=0 n! i!(n i)! ti (1 t) n i 0 t 1 0! 1 from the basis functions several properties are known degree of the polynomial defining the curve is one less than the number of control polygon points first and last points on the curve are coincident with the first and last points of the control polygon but generally do not pass through inner control points tangent vectors at the ends of the curve - same direction as the first and last polygon span - permits piecing of multiple curve curve is contained within the convex hull of the control points curve is invariant under an affine transformation 15
Computer Aided Design - CAD Bezier curves special cases for Bezier curves only one control point B0, n=0, then P(t) = B0 for all t only two points B0 and B1, n=1, then the formula reduces to a line segment between the two control points P (t) = B 0 + t(b 1 B 0 ) adding multiple control points at a single position in space will add more weight to that point pulling the Bezier curve towards it. closed curves are generated by specifying the first point the same as the last point. if the tangents match at the endpoints - curve is closed with first order geometric continuity. Mention: A circle cannot be exactly represented by a Bezier curve 16
Computer Aided Design - CAD B-Spline curves A B-Spline Curve is determined by: P (t) = n+1 i=1 B i N i,k (t) t min t t max, 2 k n + 1 Bi position vectors of the n+1 control polygon vertices N is the normalized B-Spline basis function the i-th normalized basis function of order k (degree k-1) is defined by the Cox-de Boor recursion formulas N i,1 (t) = 1 if x i t x i+1 0 otherwise N i,k (t) = (t x i)n i,k 1 (t) x i+k 1 x i + (x i+k t)n i+1,k 1 (t) x i+k x i+1 17
Computer Aided Design - CAD B-Spline curves xi are elements of the knot vector satisfying: and are monotonically increasing series of real numbers the parameter t varies along the curve from tmin to tmax a B-Spline is defined as a polynomial spline function of order k P(t) is a polynomial of degree k-1 on each interval Properties of a B-Spline: x i t x i+1 sum of the B-spline basis functions for any parameter t is: n+1 N i,k (t) 1 i=1 each basis function is positive or zero for all parameter values maximum order equals the number of control polygon vertices - maximum degree is one less curve is contained within the convex hull of the control points affine transformation can be applied to the curve by applying it to the control polygon vertices 18
Computer Aided Design - CAD B-Spline curves B-Spline Curve Control type of knot vector into periodic uniform, open uniform or nonuniform order of k of the basis function multiple polygon vertices or multiple knot values in the knot vector number and position of the control polygon vertices 11 10 9 B2 Order k Inserting B s Moving B s k = 2 7 6 6 B2 B4 B5 5 B2 Y 8 7 6 5 4 3 k = 4 k = 3 B3 B4 B5 Y 5 4 3 2 B3, 2*B3 Y 4 3 2 B1 B3 B5 B5 B7 B8 2 1 B1 0 0 2 4 6 X 8 10 12 1 B1 0 0 2 4 X 6 8 1 B6 B4 0 0 2 4 B5 6 8 10 X 19
Computer Aided Design - CAD Rational B-Spline curves - NURBS A Rational B-Spline Curve is determined by: projection of a non-rational B-Spline curve in 4D back to physical 3D P (t) = n+1 i=1 B h i N i,k (t) 0 h i weights projection back into 3D space by dividing through the homogeneous coordinates yields P (t) = n+1 i=1 n+1 B i h i N i,k (t) h i N i,k (t) i=1 = n+1 i=1 Rational B-Spline Basis function B i R i,k (t) R i,k (t) = h in i,k (t) n+1 i=1 h i N i,k (t) 20
Computer Aided Design - CAD NURBS curves Characteristics each rational basis function is positive or zero for all parameters sum of the B-spline basis functions for any parameter t is: n+1 i=1 R i,k (t) 1 maximum order of rational B-Spline curve is equal to the number of control polygon vertices curve generally follows the shape of the control polygon for hi > 0 the curve lies within the convex hull of the control points thus curve is always well behaved and does not oscillate erratically projective transformations is applied to the rational B-Spline curve by applying it to the control polygon vertices (curve is invariant to a projective transformation) - stronger condition than affine 21
Computer Aided Design - CAD NURBS curves Example: Open Rational B-Spline Curve 0 1 B 1 =, B 2 =, 0 2 5 B 3 = 2 4, B 4 = 0 2 5 B 5 = 0 calculating 3rd order rational B- Spline curves with weighting factors h3 = 0, 1/4, 1, 5 Knot vector becomes: [0 0 0 1 2 3 3 3] Y Y 2.5 B2 B4 2 1.5 1 0.5 B1 B3 B5 0 0 1 2 X 3 4 5 2.5 B2 h = 0 B4 2 1.5 h = 1 4 1 h = 1 0.5 h = 5 B1 B3 B5 0 0 1 2 3 4 5 X 22
Curve and Surface Representation NURBS curves 1 0.8 Rational B-Spline basis functions h = 0 h = 1 1 1 4 R 1,3 R R 1,3 2,3 R R 5,3 4,3 R 2,3 R 4,3 R 5,3 0.8 0.8 1 0.8 Y 0.6 0.6 Y 0.6 0.6 Y 0.4 0.4 0.4 R 3,3 0.4 Y 0.2 0.2 R 3,3 0 0 0 0.5 1 1.5 2 2.5 3 1 0.8 0.6 0.4 X 1 0.8 0.6 0.4 Y 0.2 0 0 0.5 1 1.5 2 2.5 3 h = 1 h = 5 R R 1,3 R 1,3 R R 5,3 5,3 3,3 R 3,3 R 2,3 R 4,3 1 0.8 0.6 0.4 R 2,3 X R 4,3 0.2 0 1 0.8 0.6 0.4 Y 0.2 0.2 0.2 0.2 0 0 0.5 1 1.5 2 2.5 3 X 0 0 0 0.5 1 1.5 2 2.5 3 X 0 23
Computational Grids Basics Solving the state equations within finite volume elements Finite Differences Finite Volumes Finite Element Usage of many different kinds of elements Tetrahedrons Pyramids Prisms Hexahedrons Generate grids around complex configurations Specific approaches for resolving boundary layer regions FLOWer TAU 24
Grid generation Three main approaches Cartesian grids Edges of the grid cells are parallel oriented to the cartesian coordinates. The grid cells have perpendicular edges. Grid points between cells can be placed independently of each other and called hanging nodes. Schwartz Schwartz 25
Grid generation Cartesian grids Main advantages: very quick meshing evaluation of fluxes, gradients or boundary treatments are straight forward over perpendicular edges - high accuracy easy refinement strategies with hanging nodes QuadTree 2D OctTree 3D Main disadvantages: Automatic Digital Tree boundary cutting of cells boundary layer resolution Schwartz 26
Grid generation Three main approaches Structured grids Each grid point is uniquely identified by the indices i,j,k and corresponding cartesian coordinates xi,j,k, yi,j,k and zi,j,k. The grid cells are quadrilaterals in 2D and hexahedra in 3D. i, j + 1 i, j i + 1, j i 1, j i, j 1 27
Grid generation Structured grids Main advantages: i,j,k order represents a linear address space access of neighboring grid points is easy evaluation of fluxes, gradients or boundary treatments are greatly simplified Implementation of implicit schemes straight forward because of the well-ordered, banded flux jacobian matrix body fitted coordinates system transformation into curvilinear coordinate system 28
Grid generation Structured grids Main disadvantages resolution of shocks imposes many additional points due to geometric restrictions - highly skewed cells Schwartz complex geometries multiblock approach time consuming grid generation communication tables for data exchange but: if grid is available very easy to generate again Schwartz 29
Grid generation Structured grids Classification of structured grids O-Grid C-Grid H-Grid 30
Grid generation Three main approaches Unstructured grids Grid cells as well as grid points have no particular ordering. Neighboring cells or grid points cannot be directly identified by their indices. An extra connectivity list is necessary. Today unstructured grids contains tetrahedra, pyramids, prisms and hexahedra and are called hybrid grids 56 14 1 6 3 22 82 31
Grid generation Unstructured grids Main advantages: Offer the largest flexibility for complex geometries Triangles or Tetrahedra can be generated in principle automatically Generate mixed grids reduces the number of grid cells but is non-trivial 5&'',($/3/(-) $+,6$768'$-) 3*+-$7&/()$*+ to setup a grid with good quality ) *+,-$.&/-$. 0$1* 23&4$##$"5 6"$517 Less time consumption for grid generation than for structured multiblock grids Usage of solution dependent grid refinement - adaptation #$%&'()$*+,*-,./*&+0,1--23)4 32
Grid generation Unstructured grids Further considerations and disadvantages: resolve boundary layer regions it is advised to generate a prismatic or hexahedral layer employ sophisticated data structures to handle different volume elements independently usually higher memory requirements than structured grids due to unstructured point numbering bandwidth optimizations and cache coloring increase efficiency remarkable 33
Grid generation Unstructured grids Advancing front algorithm discretized boundaries form the initial front grid is generated step by step from outside to inside inner surface of the elements form an advancing front 34 Jonathan Richard Shewchuk Consider: Figure 2.30: Several stages in the progression of an advancing front algorithm. Initial spacing of the boundaries should be well behaved 2.2.2 Advancing Front Methods when the advanced walls of elements collide at the center of the mesh, that they are merged together with good quality triangles Advancing front methods [62, 6, 51, 64] begin by dividing the boundaries of the mesh into edges (in two dimensions) or triangular faces (in three). These discretized boundaries form the initial front. Triangles or tetrahedra are generated one-by-one, starting from the boundary edges or faces, and work toward the center of the region being meshed, as illustrated in Figure 2.30. The inner surface of these elements collectively form an advancing front.!form meshes from inside to outside! Advancing front methods require a good deal of second-guessing, first to ensure that the initial division of the boundaries!use a isdelaunay prudent, and second triangulation to ensure that whento theget advancing seeding walls of elements points! collide at the center of the mesh, they are merged together in a manner that does not compromise the quality of the elements. In both cases, a poor choice of element sizes may result in disaster, as when a front of small elements collides with a front of large elements, making it impossible to fill the space between with nicely shaped elements. These problems are sufficiently difficult that there are, to my knowledge, no provably good advancing front algorithms. Advancing front methods typically create astonishingly good triangles or tetrahedra near the boundaries of the mesh, but are much less effective where fronts collide. 34
Grid generation Final Comments Cartesian Grids are still used successful whenever boundary layer region can be resolved background far-field grid body fitted surface grid with overlapping region Structured Grids are still widely used because of their obtained accuracy through the flow solver (quadrilaterals - hexahedrons) higher order elements! very quick re-meshing whenever the grid is could be set up Unstructured Grids have the most impact for any complex configuration quick meshing provided together with Grid Adaptation it becomes a powerful tool BUT: still a lot of experience necessary because it is much more difficult to provide a good quality grid due to difficult influence on the grid generation process! point seeding, source distribution,... 35
Flow simulation preparation 36
Preprocessing How to we prepare the grid for flow simulation? Bundling the necessary information in a data structure for Finite Volume schemes Setting up the structure for flux integration node centered schemes cell centered schemes 37
Preprocessing From grid generation we will get the discretized flow domain in particular small control volumes: Multi-Block Structured grids deliver hexahedral s: Unstructured grids deliver elements of: 38
Preprocessing looking at integral which has to be solved: t e.g. continuity equation V ρdx + V (ρu)dx = V ρ t + (ρu) dx = 0 Extracting data for applying flux integration must include face normals on each side of the element usually mean value of face area volume of element point coordinates Need of storage of variables and fluxes either at physical or artificial locations concerning the grid What fashion can we use to compute now the fluxes efficiently? 39
Preprocessing What about taking the edges of the element and creating a secondary control volume like: ending up in an edge based structure with a dual control volume 40
Preprocessing What about taking the edges of the element and creating a secondary control volume like: Node based scheme with dual metric Cell based scheme 41
Preprocessing Consider the following differences between the two approaches when using the same primary grid for both approaches: cell centered scheme: faces computed are exact and not a sum up of facets - Schwartz inequality (area) - planar faces computing which much more unknown - more faces other possibly important metrics can be established more easily - e.g. face center imposing boundary conditions! - usually extrapolation necessary but still advantageous for sharp trailing edges node centered scheme or cell vertex with dual metric: reduction of faces enormous - tetrahedral s by a factor of about 1:7 direct imposing of boundary conditions on surface nodes needs higher resolution of grid to get same accuracy as cell centered scheme 42
Flow simulation process 43
Flow simulation Considering the spatial discretization: Upwind scheme Central scheme Accuracy assessments difficulties when using upwind scheme in a node centered scheme central scheme approaches for artificial dissipation node centered versus cell centered metric 44
Flow simulation Considering the spatial discretization Flux density vector over a single face becomes: F lr n lr = 1 2 Fr + Fl n lr 1 2 Ā( w r, w l, n lr ) ( w r w l ) which can either be an upwind or an central scheme: depends on how you compute: 1 2 Fr + Fl n lr and 1 2 Ā( w r, w l, n lr ) ( w r w l ) 45
Flow simulation Upwind scheme Considering the spatial discretization for Upwind schemes Flux density vector over a single face becomes for Roe s flux difference splitting - solving approximate Riemann solver on each control volume face: F lr n lr = 1 2 Fr + Fl n lr 1 2 Ā( w r, w l, n lr ) ( w r w l ) approximation of first term is basically always of first order!! 1 Fr + Fl n lr 2 simple difference of left and right state! 46
Flow simulation Upwind scheme But we want to have second order which means extend the computation of flow variables with Taylor series -> include gradients: v face,l = v node,l + 1 2 Ψ v l ( l l l r ) v face,r = v node,r + 1 2 Ψ v r ( l r l l ) Ψ... limiter Reconstruction of flow variables Limiter necessary for monotonicity and is used for blending the gradient 47
Flow simulation Upwind scheme Upwind: What does the second part become: 1 2 Ā( w r, w l, n lr ) where A will be the flux jacobean: ( w r w l ) λ = A = F w = T λ T 1 v n + c 0 0 0 0 0 v n c 0 0 0 0 0 v n 0 0 0 0 0 v n 0 0 0 0 0 v n 48
Flow simulation Upwind scheme Mainly the computation of Matrix A is not very difficult you can precompute A and directly put it into your code quite a lot of if statements due to left and right running eigenvalues Expensive part is the reconstruction computation of gradients from flow variables needed limiter computation to preserve monotonicity in the vicinity of shocks choosing the right limiter is an issue since nearly 30 years more importance becomes the accurate reconstruction of the flow variables for computing the gradient Accuracy of Upwind schemes in node and cell centered schemes especially when using unstructured grids mixed types of elements and dual mesh approach is difficult 49
Flow simulation Upwind scheme Gradient Computation: due to simplicity and data available Gaussian Integral theorem is widely used v = 1 n 1 V 2 (v i + v 0 ) n i σ but: linear function v = x+y becomes i 50
Flow simulation Upwind scheme for linear reconstruction of gradients it is more reliable to use a least-square technique, Taylor series from central point and using Gram-Schmidt and QR decomposition v = x = R 1 Q T b now: linear function v = x+y becomes 51
Testcase - 2D Subsonic flow around profile Ma = 0.2, Re = 6 Mill., α = 0, 5, 10 hybrid mesh with blunt trailing edge 52
Testcase - 2D Subsonic flow around profile Ma = 0.2, Re = 6 Mill., α = 0, 5, 10 Integral values of lift coefficient and pressure part of drag evaluated at the surface default upwind 53
Flow simulation Central scheme Considering the spatial discretization for Central schemes Flux density vector over a single face becomes for the central scheme like before: F lr n lr = 1 2 Fr + Fl n lr 1 2 Ā( w r, w l, n lr ) ( w r w l ) approximation of first term is basically always a central difference! 1 Fr + Fl n lr 2 looping around faces of a control volume gives you automatically the central difference - mention the face normal vector nlr 54
Flow simulation Central scheme Considering the spatial discretization for Central schemes Needs an artificial dissipation added to become a stable scheme 1 2 Ā( w r, w l, n lr ) ( w r w l ) first approach from Jameson/Schmidt/Turkel - JST scheme A is taken as a scalar value - the maximum local eigenvalue on the particular face - Scalar Dissipation A k λ max = k v n + c D =(w r w l )= 2 (u r u l ) 4 (L(u r ) L(u l )) 2 = f(k 2, λ, ω) 4 = f(k 4, 2 ) 55
Flow simulation Central scheme taking the maximum local eigenvalue makes it robust but dissipative too! try to precise the artificial dissipation by using the same procedure as for Roe s scheme - Matrix Dissipation D =(w r w l )= 2 (u r u l ) 4 (L(u r ) L(u l )) A = F w = T λ T 1 λ = diag( λ 1, λ 2, λ 3, λ 4, λ 5 ) λ 1 = max[ v n + c ), δ a ( v n + c)] λ 2 = max[ v n c ), δ a ( v n + c)] λ 3, λ 4, λ 5 = max[ v n ), δ v ( v n + c)] 56
Flow simulation Central scheme - NACA0012 Profil, Ma = 0.8, α = 1.25 Matrix Dissipation 57
Node - Cell Center Sharp trailing edge flux evaluation on a metric discontinuity applying boundary conditions Cell center Node center 58
Node - Cell Center Pressure distribution Cp and pressure loss pl at the trailing edge 59
Conclusion - Remarks Central schemes with scalar dissipation is one of the most widely used spatial discretization s in flow solvers for sub- and transsonic flows usually flux computation about twice as fast as for upwind schemes the dissipation factors k2 and k4 can be used for tuning Upwind schemes widely used for transsonic and supersonic flows but lacking of computing exact gradients and limiters very sensitive on precomputed metric s much better usable in cell centered metrics using a cell centered or node centered metric still an ongoing issue for the numeric community solution: Implement both metric approaches and choose wherever you might experience efficiency in computational time accuracy,?!?! 60