Moukalled F., Mangani L., Darwish M. The finite volume method in computational fluid dynamics. An advanced introduction with OpenFOAM and Matlab (811443), страница 28
Текст из файла (страница 28)
Furthermore the orientation of the face can be defined in a standard fashionby indexing the elements in a specified order. In this case the normal vector at theinterface between two elements is oriented from element 1 to element 2, which arealso denoted in OpenFOAM® by the owner and neighbor elements, respectively, asshown in Fig. 6.10.Therefore if the interface is considered with element 2, then it should be multiplied by a negative sign.
Thus considering the faces that bound element 9, theconnectivity information is defined as shown in Fig. 6.11.The computation of the gradient can be done for every element. However as theflux /f Sf at every interface is the same for the straddling elements with the(a)(b)ownerfaceownerfaceneighbourSfneighbourFig. 6.10 Owners, neighbors, and faces for a 2D and b 3D elements112382299FaceConnectivityElementslocal indexglobal index1 2[8 9]FaceConnectivityElements1 2[9 11]local indexglobal index1182223156169156FaceConnectivityElements1 2[6 9]1119Elements9FaceConnectivity102Elements910111 2[1 9]local indexglobal index1101016local indexglobal indexFaceConnectivity921 2[9 10]FaceConnectivityElements1 2[2 9]local indexglobal indexFig. 6.11 An example of face, element, and node connectivities for unstructured gridslocal indexglobal index1506 The Finite Volume MeshFig.
6.12 An unstructuredmesh system28212720222624191817232515161181471396511021234difference being its sign, the computation of the gradient could proceed in a moreefficient manner by computing the gradient over the entire domain (e.g., the entiredomain shown in Fig. 6.12) rather than element by element.
This is done by loopingover all the faces in the computational domain and directly updating the value of thegradient for the elements straddling the interface by incrementing and decrementingthe calculated flux from the gradient of element 1 and element 2, respectively.Therefore the algorithm on an unstructured grid for calculating a gradient fieldbecomesAlgorithm for computing the gradient on an unstructured grid system1. D eclare gradient array and initialize it to zero2. Loop over interior faces> compute flux_f = phi_f*Sf> add flux_f to gradient of owner element and flux_f to gradient of neighbor element3.Loop over boundary faces> compute flux_f = phi_f Sf> add flux_f to gradient of owner element4.Loop over elements> divide gradient by volume of elementThis basically yields the gradient at each element in the computational domain asper Eq.
(6.20). The same algorithm could be used with a structured grid to reducethe computational cost.Example 3Write the connectivity arrays for elements 1 and 5, and faces 1, 7, 11 and 23for the mesh shown in Figs. 6.13 and 6.14.6.4 Unstructured Grids151Fig. 6.13 An unstructured mesh for Example 2SolutionFor elements, the neighbors are stored in the increasing index number ofshared faces, and interior faces are stored in increasing index number, followed by boundary faces again stored in increasing index number.element 5neighbors 6 3faces 12 13 15 16element 1neighbors 2 6 3 8 4faces 1 3 5 7 14Fig. 6.14 Surface vector direction at faces 1, 7, and 23 for Example 21526 The Finite Volume MeshFor a face the owner is the element of lower index and the neighbor is theelement of higher index.
A Boundary face has only an owner. The directionof the surface vector associated with any face is oriented from owner toneighbor.face 1owner 1neighbor 2face 7owner 1neighbor 8face 11owner 7neighbor 9face 23 (a boundary face)owner 8neighbor -1 (a boundary face has no neighbor)6.5Geometric QuantitiesIn addition to topological data, the finite volume mesh incorporates informationabout its geometric entities, such as the volume of elements, the area of faces, thecentroids of elements and faces, the alignment of faces with the vectors joining thecentroids of the owner and neighbor elements (Fig. 6.15), etc.
The calculations ofsome of these geometric quantities will be presented next. The type of elements thatNSf1fCFig. 6.15 Angle between surface vector and vector joining the centroids of the owner andneighbor elements6.5 Geometric Quantities153can be used in generating the mesh are first described, followed by the techniquesemployed for computing the geometric information.6.5.1Element TypesAn element in the finite volume mesh is basically a polyhedron in a threedimensional mesh (Fig. 6.16) or a polygon in a two-dimensional mesh (Fig. 6.17).The most widely used three-dimensional shapes, as displayed in Fig. 6.16, aretetrahedrons, hexahedrons, prisms, and in some cases general polyhedrons.The type of faces for these three-dimensional elements, which also represent thetype of two-dimensional elements (Fig.
6.17), vary greatly, with the ones that arethe most widely used being quadrilaterals, triangles and pentagons, though generalpolygons have also been adopted in some applications.TetrahedronHexahedronPrismPolyhedronFig. 6.16 Three-dimensional element typesQuadrilateralTrianglePentagonFig. 6.17 Three-dimensional face types or two-dimensional element types1546 The Finite Volume MeshThe computation of geometric factors for such elements and faces will now bedetailed. It is worth noting that when working with a two-dimensional mesh thevolume of the elements are considered to be the area of the two dimensionalelements multiplied by a unit dimension in the off plane direction.
Thus the techniques to compute the volume of elements of two-dimensional meshes are exactlythose used in computing the surface area of faces of three-dimensional meshes.Other variables arising during discretization, which are solely dependent on geometric quantities, will be presented when needed.6.5.2Computing Surface Area and Centroid of FacesThe general shape of an element face in a three-dimensional finite volume mesh is apolygon, though triangular and quadrilateral faces are the most widely used.
Thecomputation of the surface vector and centroid follows the same procedure for alltypes of polygons. Basically a point is constructed within the polygon based on theaverage of all the points that define the polygon. This point is the geometric centreof the polygon xG ¼ ðxG ; yG ; zG Þ, which coincides with the centroid of the polygonxCE ¼ ðxCE ; yCE ; zCE Þ only for some very special shapes, which include triangles.Therefore the geometric centre of k points forming a polygon is computed asxG ¼k1Xxik i¼1ð6:21ÞUsing the geometric centre (Fig.
6.18) a number of triangles are formed with thecentre as the apex for each side of the polygon. For each of the triangles the centroid(since for triangles xG and xCE coincide) and area are readily computed. The sum oftheir areas will give the total area of the polygon. For computing the centroid thearea-weighted centroid (or geometric centre) of each sub-triangle are summed overthe polygon and divided by the polygon area, yielding the centroid of the polygon.Mathematically this is computed assub-triangle centroidcentroidpolygon centerFig.
6.18 The geometric centre and centroid of a polygon6.5 Geometric Quantities155Sf ¼XSttSubtrianglesðC ÞPðxCE Þf ¼6.5.2.1tSubtrianglesðC ÞðxCE Þt Stð6:22ÞSfSurface of a TriangleThe area of a triangle is computed using vector product. The magnitude of thevector product of two vectors represents the area of the parallelogram formed by thetwo vectors. Thus the area of the triangle is half the magnitude of the vector productof the two vectors.
Denoting the position vectors of the three vertices 1, 2, and 3 ofthe triangle shown in Fig. 6.19 by r1 , r2 , and r3 , respectively, the surface vector ofthe triangle can be computed as ijk 11 S ¼ ðr2 r1 Þ ðr3 r1 Þ ¼ x2 x1 y2 y1 z2 z1 ¼ Sx i þ Sy j þ Sz k22x3 x1 y3 y1 z3 z1 ð6:23Þ( r2r1 )( r3r1 )Sf =z(r2r1 )(r3r1 )231r1r3r22ySxFig. 6.19 Surface vector and area magnitude of a triangle in a three dimensional space1566 The Finite Volume Meshand the magnitude of the area is given byS¼qffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiS2x þ S2y þ S2zð6:24ÞTo know whether the surface vector is pointing outward, its dot product with theposition vector that joins the centroid of the element CE to the centroid of thesurface ce is computed.
If the sign of the dot product is positive then the surfacevector is pointing outward, otherwise it is pointing inward. The same approach maybe used to discern the orientation of the surface vector in two dimensions.For a two dimensional grid the surface area represents the volume of the controlcell with a unit depth in the off-plane direction. Therefore the volume of a triangularcell in a two dimensional grid is calculated using11V ¼ jðr2 r1 Þ ðr3 r1 Þj ¼ ½ðx2 x1 Þðy3 y1 Þ ðx3 x1 Þðy2 y1 Þ221¼ ½ x1 ð y2 y3 Þ þ x2 ð y3 y1 Þ þ x3 ð y1 y2 Þ 2ð6:25ÞNote that the signed volume (or area) will be positive if the vertices 1, 2 and 3 areoriented counterclockwise around the triangle, otherwise it will be negative.
Takingthe absolute value of the right hand side of Eq. (6.25) will always result in thecorrect volume value.Example 4Compute the centroid and area of the polygon shown in Fig. 6.20 whosecoordinates are displayed in Table 6.2.1G ( xG , yG )55124234Fig. 6.20 A polygonal element3CE ( xCE , yCE )6.5 Geometric Quantities157Table 6.2 Coordinates of the polygonal element for Example 3Node12345xy16.42.44.020.20.4004.0SolutionFor this polygon k = 5. Thus its geometric centre GðxG ; yG Þ is located at1xG ¼ ð1 þ 2:4 þ 2 þ 0:4 þ 0Þ ¼ 1:1651yG ¼ ð6:4 þ 4 þ 0:2 þ 0 þ 4Þ ¼ 2:925The polygon is decomposed into 5 triangles of apex GðxG ; yG Þ. The centroidof triangle 1 is located at1xG1 ¼ ð1:16 þ 1 þ 2:4Þ ¼ 1:5231yG1 ¼ ð2:92 þ 6:4 þ 4Þ ¼ 4:443In a similar way the centroids of other triangles are found and are presented inTable 6.3.Table 6.3 Coordinates of the triangles’ centroidsTriangle12345x-centroidy-centroid1.524.441.853332.373331.186661.040.522.306660.724.44The areas of the triangles are found using Eq.
(6.25) and for triangle 1 isgiven by1S1 ¼ ½xG ðy2 y1 Þ þ x2 ðy1 yG Þ þ x1 ðyG y2 Þ21¼ ½1:16ð4 6:4Þ þ 2:4ð6:4 2:92Þ þ 1ð2:92 4Þ ¼ 2:2442In a similar way the areas for the other triangles are found and are presentedin Table 6.4.Table 6.4 Areas of the various trianglesTriangle12345Area2.2442.142.622.1041.9321586 The Finite Volume MeshThe area of the polygon is found to beSt ¼5XSi ¼ 2:244 þ 2:14 þ 2:62 þ 2:104 þ 1:932 ¼ 11:04i¼1The coordinates of its centroid can be obtained asxC ¼51XSi xCi ¼ 1:174925St i¼1yC ¼51XSi yCi ¼ 2:825940St i¼1The difference between the geometric centre and centroid is clear.6.5.2.2Volume and Centroid of ElementsThe general procedure followed to compute the volume and centroid of a generalpolyhedron is conceptually simple.