MESH MOVEMENT 241 the ring region between these two are allowed to deform. One can then either remesh this region or simply switch the diagonals. However, simply switching diagonals will not always work, as points that have slightly different radii will tend to overtake each other, potentially creating very small elements. Thus, the option of adding or removing points, which is always possible with local remeshing, should always be available. Figure 12.11. Simultaneous seat ejection 12.9. Applications The following section shows the mesh velocity fields obtained using the techniques described in this chapter for several examples. 12.9.1. MULTIPLE SPHERES The last decade has seen a continuousinterest in the dynamics of bubbles or granular material immersed in a fluid. Figure 12.10 shows a planar cut for a simulation with 36 spheres falling towards the bottom surface. As the spheres get close to the bottom wall, they are removed automatically and the resulting voids are remeshed. Similarly, new spheres are introduced at the top. One can clearly see the velocity field of the mesh movement. Note the almost constant contour levels close to the spheres, which indicates that the mesh in the vicinity of the sphere moves almost rigidly. 242 APPLIED COMPUTATIONAL FLUID DYNAMICS TECHNIQUES (a) (b) (c) Figure 12.12. Tanker Fleet: (a) free surface; and (b) mesh velocity in two planes; (c) mesh velocity (detail) 12.9.2. PILOT EJECTION FROM F18 Every new generation of ejection seat must be tested for safe deployment. Figure 12.11shows a planar cut for a simulation with two pilots ejecting simultaneously (Sharov et al. (2000b)). As before, the velocity field of the mesh movement displays almost constant contour levels close to the pilots, indicating nearly rigid mesh movement. 12.9.3. DRIFTING FLEET OF SHIPS This case, taken from Löhner et al. (2007c),considers a fleet of tankers that are freely floating objects subject to the hydrodynamic forces of an incoming wavefield. The surface nodes of the ships move according to a 6 degree of freedom integration of the rigid body motion MESH MOVEMENT 243 equations, and 30 layers of elements surrounding the ships are moved. The volume mesh has approximately 10 million elements. Figure 12.12(a) shows the free surface at 200 s. The absolute value of the mesh velocity in two planes, as well as a detailed view of the mesh velocity on the surface of one of the tankers and a plane are displayed in Figures 12.12(b) and (c). Several local and global remeshings were required during the run to keep the mesh quality acceptable. 13 INTERPOLATION The need to interpolate quickly fields of unknowns from one mesh to another is common to many areas of CFD and, more generally, to computational mechanics and computational physics. The following classes of problems require fast interpolation algorithms. (a) Simulations that require different grids as the solution proceeds. Examples of this kind are adaptive remeshing for steady-state and transient simulations (Löhner and Ambrosiano (1990), Peraire et al. (1992b), Weatherill et al. (1993b)), as well as simple remeshing for problems where grid distortion due to movement becomes too severe (Baum and Löhner (1993), Mestreau et al. (1993), Löhner et al. (1999)). (b) Simulations with overlapping grids. The key idea here is to simplify the mesh generation process and to avoid the regeneration of grids for problems with moving bodies by generating for each component (e.g., wing, pylon, tail, engine inlet, etc.) a local, independent grid. These independent grids overlap in certain regions. The solution to the global problem is obtained by interpolating between the grids after each timestep (Benek et al. (1985), Dougherty and Kuan (1989), Meakin and Suhs (1989), Meakin (1993, 1997), Rogers et al. (1998), Nakahashi et al. (1999)). (c) Loose coupling of d ifferent codes for multi-disciplinary applications. In this case, if any of the codes in question are allowed to perform adaptive mesh refinement, the worst- case scenario requires a new interpolation problem at every timestep (Guruswamy and Byun (1993), Rausch et al. (1993), Löhner et al. (1995,2004d), Cebral and Löhner (1997)). (d) Interpolation of d iscrete data for the initialization or continuous update of boundary conditions. Common examples are meteorological simulations, as well as geotechnical data for seepage problems. (e) Particle/grid codes. These codes, commonly used for plasma and particle beam simulations, as well as solid rocket motor applications, require the efficient tracking of a large number (>10 6 ) of particles, making an efficient interpolation algorithm a prime requirement. (f) Visualization. This large class of problems makes extensive use of interpolation algorithms, especially for the comparison of different data sets on similar problems. In the following, the focus will be on the fast interpolation between different unstructured grids that are composed of the same type of elements, surface-grid-to-surface-grid interpo- lations and element-to-particle interpolations. In particular, linear triangles and tetrahedra Applied Computational Fluid Dynamics Techniques: An Introduction Based on Finite Element Methods, Second Edition. Rainald Löhner © 2008 John Wiley & Sons, Ltd. ISBN: 978-0-470-51907-3 246 APPLIED COMPUTATIONAL FLUID DYNAMICS TECHNIQUES are considered. The ideas developed are general and can be applied to any type of element and grid. On the other hand, other types of grids (e.g. Cartesian structured grids) will lend themselves to specialized algorithms that may be more efficient and easier to implement. 13.1. Basic interpolation algorithm Consider an unstructured finite element or finite volume mesh, as well as a point p with coordinates x p . A simple way to determine whether the point p is inside a given element el is to determine the shape-function values of p with respect to the coordinates of the points belonging to el: x p = i N i x i . (13.1) For triangles in two dimensions and tetrahedra in three dimensions, we have, respectively, two equations for three shape functions and three equations for four shape functions. The sum property of shape functions, i N i = 1, (13.2) yields the missing equation, making it possible to evaluate the shape functions from the following system of equations: x p y p z p 1 = x 1 x 2 x 3 y 1 y 2 y 3 z 1 z 2 z 3 111 · N 1 N 2 N 3 N 4 , (13.3) or, in concise matrix notation, x p = X · N → N = X −1 · x p . (13.4) Then, the point p is in element el if min(N i , 1 −N i )>0, ∀i. (13.5) For other types of elements more nodes than equations are encountered. The easiest way to determine whether a point is inside an element is to split the element into triangles or tetrahedra and evaluate each of these sub-elements in turn. If the point happens to be in any of them, it is inside the element. This procedure may not be unique for highly deformed bricks, as shown in Figure 13.1. Depending on how the diagonals are taken for the face A–B–C–D, the point to be interpolated may or may not be inside the element. Therefore, subsequent iterations may be required for bricks or higher-order elements with curved boundaries. Other ways to determine whether a point is inside a bilinear element may be found in Westermann (1992). The criterion set forth in (13.5) is used to determine whether a point lies within the confines of an element. In what follows, different ways of determining the element in question as quickly as possible are considered. The possible improvements in speed depend mostly on the assumptions one can make with respect to the information available. INTERPOLATION 247 A B C D Point to be Interpolated Figure 13.1. Interpolation for a deformed brick element 13.2. Fastest 1-time algorithm: brute force Suppose we only have a given grid and a point p with coordinates x p . The simplest way to find the element into which point p falls is to perform a loop over all the elements, evaluating their shape functions with respect to x p : do ielem=1,nelem ! Loop over all the elements Evaluate N i from Eqn.(13.4); if: Criterion (13.5) is satisfied: exit enddo Since the outer loop over all the elements can readily be vectorized and/or parallelized, this algorithm is extremely fast. This brute force search is used in more refined algorithms both as a start-up procedure and as a fall-back position. 13.3. Fastest N-time algorithm: octree search Suppose that as before we only have a given grid, but instead of just one point p a considerable number of points needs to be interpolated.In this case, the brute-force algorithm described before will possibly require a complete loop over the elements for each point to be interpolated, and, on average, a loop over half the elements. A significant improvement in speed maybe realized by only checking the elements that cover the immediateneighbourhood of the point to be interpolated. A number of ways can be devised to determine the neighbourhood (see Figure 13.2 and Chapter 2): - bins, i.e. the superposition of a Cartesian mesh (Löhner and Morgan (1987), Meakin (1993)); - octrees, i.e. the superposition of an adaptively refined Cartesian mesh (Knuth (1973), Samet (1984)); and - alternate digital trees (Bonet and Peraire (1991)). 248 APPLIED COMPUTATIONAL FLUID DYNAMICS TECHNIQUES We consider octrees here, as bins perform poorly for problems where the nearest-neighbour distances vary by more than two orders of magnitude in the domain. One may form an octree with the element centroids or points. It is advisable to choose the latter option, as for 3-D tetrahedral grids the number of points is significantly less than the number of elements. Denoting by coint(1:ndimn,1:npint) the coordinates of the npint points to be interpolated, the octree search algorithm proceeds as follows: For the given mesh: Form the octree for the points Form the list of elements surrounding points (esup1,esup2) do ipint=1,npint ! Loop over the points to be interpolated Obtain close points of given mesh from the octree; Obtain the elements surrounding the close points from esup1,esup2, and store in lcloe(1:ncloe) do icloe=1,ncloe ! Loop over the close elements ielem=lcloe(icloe) Evaluate N i from equation (13.4); if: Criterion (13.5) is satisfied: exit enddo As we have failed to find the host element: Use brute-force enddo ) ) a) b) Figure 13.2. Algorithms to determine spatial proximity: (a) bin; (b) quadtree Several improvements are possible for this algorithm. One may, in a first pass, evaluate the point of the given mesh closest to x p , and only consider the elements surrounding that point. In general this pass is successful. Should it fail, the elements surrounding all the close points are considered in a second pass. If this second pass also fails (see Figure 13.3 for some pathological cases), one may either enlarge the search region, or use the brute-force algorithm described above. The octree search algorithm is scalar for the first (integer) phase INTERPOLATION 249 Boundary Closest point of Known Grid Point to be Interpolated Point to be Interpolated Closest point of Known Grid Figure 13.3. Interpolation with internal boundaries (obtaining the close points and elements), but all other stages may be vectorized. The vector lengths obtained for 3-D grids are generally between 12 and 50, i.e. sufficiently long for good performance. 13.4. Fastest known vicinity algorithm: neighbour-to-neighbour Suppose that as before we only have a given grid and a considerable number of points need to be interpolated. Moreover, assume that, for any given point to be interpolated, an element of the known grid that is in the vicinity is known. In this case, it may be faster to jump from neighbour to neighbour in the known grid, evaluating the shape-function criterion given by (13.5) (see Figure 13.4). Point to be Interpolated Figure 13.4. Neighbour-to-neighbour search 250 APPLIED COMPUTATIONAL FLUID DYNAMICS TECHNIQUES If the element into which x falls can be found in a few attempts (<10), this procedure, although scalar, will outperform all other ones. The neighbour-to-neighboursearch algorithm may be summarized as follows: For the given mesh: Form the list of elements adjacent to elements ⇒ esuel(1:nfael,1:nelem) do ipint=1,npint ! Loop over the points to be interpolated iesta=lesta(ipint) ! Obtain a good starting element do itry=1,mtry ! Loop over the nearest neighbour tries For iesta:EvaluateN i from equation (13.4); if (13.5) is satisfied then exit else Obtain node inmin for min(N i ) iesta=esuel(inmin,iesta) ! Jump to neighbour endif enddo enddo The neighbour-to-neighbour algorithm performs very well in the domain, but can have problems on the boundary.Whereas the brute-force and octree search algorithms can ‘jump’ over internal or external boundaries, the neighbour-to-neighbour algorithm can stop there (see Figure 13.5). Its performance depends heavily on how good a guess the starting element iesta is: it can be provided by bins, octrees or alternate digital trees. On the other hand, due to its scalar nature, such an algorithm will not be able to compete with the octree search algorithm described in Chapter 3. Its main use is for point-to-grid or grid-to-grid transfer, where a very good guess for iesta may be provided. This fastest grid-to-grid interpolation technique is described in the next section. Boundary IESTA Point to be Interpolated Figure 13.5. Internal boundaries 13.5. Fastest grid-to-grid algorithm: advancing-front vicinity The crucial new assumption made here as opposed to all the interpolation algorithms described so far is that the points to be interpolated belong to a grid, and that the grid connectivity (e.g. the points belonging to each element) is given as input. In this case, whenever the element ieend of the known grid into which a point of the unknown grid falls is found, all the surrounding points of the unknown grid that have not yet been interpolated INTERPOLATION 251 are given as a starting guess ieend, and stored in a list of ‘front’ points lfrnt. The next point to be interpolated is then drawn from this list, and the procedure is repeated until all points have been interpolated. The procedure is sketched in Figure 13.6, where the notion of ‘front’ becomes apparent. The complete algorithm may be summarized as follows: For the given mesh: Form the list of elements adjacent to elements ⇒ esuel(1:nfael,1:nelem) For the unknown mesh: Form the list of points surrounding points ⇒ psup1, psup2 lpunk(1:npunk)=0 ! Mark points of unknown grid as untouched nfrnt=1 ! Initialize list of front points lfrnt for unknown grid lfrnt(1)=1 lpunk(1)=1 while(nfrnt.gt.0): nfrn1 =0 ! Initialize next front do ifrnt=1,nfrnt ! Loop over front points ipunk=lfrnt(ifrnt) ! Point of unknown grid iesta=lpoi2(ipunk) ! Starting element in known grid Attempt nearest neighbour search for ntry attempts if Unsuccessful: Use brute force if Unsuccessful: Stop or skip else ⇒ ieend endif endif Store shape-functions and host elementieend lpunk(ipunk)=ieend ! Mark point as interpolated ! Loop over points surrounding ipunk do istor=psup2(ipunk)+1,psup2(ipunk+1) jpunk=psup1(istor) if(lpunk(jpunk).eq.0) then Store ieend as starting element for this point lpunk(jpunk)=ieend nfrn1=nfrn1+1 ! Update new front counter lfrn1(nfrn1)=jpunk ! Include this point in the new front endif enddo enddo Reset nfrnt, and see if we have a new front nfrnt=nfrn1 if(nfrnt.gt.0) then Transcribe the new front and proceed lfrnt(1:nfrnt)=lfrn1(1:nfrnt) endif endwhile [...]... conservation of forces for fluid-structure interaction problems: s2 d = s1 d (13 .10 ) i u2 = N2 ui2 , ˆ (13 .11 ) Writing the unknowns on both grids as i u1 = N1 ui1 , ˆ let us consider the weighted residual statement (or L2 projection) j i N2 N2 d uj 2 = ˆ j i N2 N1 d uj 1 ˆ (13 . 12 ) This may be expressed in matrix form as Mc u2 = r = Lu1 , (13 .13 ) 25 8 APPLIED COMPUTATIONAL FLUID DYNAMICS TECHNIQUES where Mc is... elements 25 7 INTERPOLATION Table 13 .1 Mesh-to-mesh interpolation timings Case Cube1 Cube2 Train1 Train2 nelem1 nelem2 # BFS Scalar Vector Speedup 34 6 61 34 6 61 180 670 18 0 670 30 8 01 160 355 24 3 068 24 3 068 0 0 31 0 0 .13 99 0.5360 1. 12 9 0 0.9905 0. 028 3 0 .11 04 0.3405 0 .20 20 4.94 4.86 3. 32 4.90 with three or more nodes on the boundary As one can see, this exhaustive search, which runs at 325 Mflops on the Cray-C90,... interpolation property ( i Nsi (x) = 1) , we can express the conservation statement given by (13 .8) as u2 d j = N2 d j uj 2 = ˆ i N2 N2 d i j = i N2 N1 d j uj 2 = ˆ uj 2 ˆ j uj 1 = ˆ i N2 N2 d i j uj 1 = ˆ i N2 N1 d i uj 1 = ˆ N1 d u1 d i (13 .14 ) The weighted residual statement given by (13 . 12 ) therefore leads to a conservative transfer of unknowns as expressed by (13 .8) However, one is faced with the... in 3-D space This implies that further criteria, like relative distances normal to the surface, will have to be employed in order to make the problem unique The basic procedure is to compute the shape functions of the surface triangles as before Using the notation of Figure 13 .19 , we can write xp = x0 + α i gi , (13 .20 ) i where g1 × g2 , |g1 × g2 | (13 . 21 a,b) α0 = 1 − 1 − 2 (13 . 21 c,d) g1 ,2 = x1 ,2. .. 1: IF1 satisfies (13 .22 a), but IF2 is better Case 2: IF1, IF2 have the same distance, implying that IF2 is preferred as it satisfies (13 .25 a) Case 1: Concave Case 2: Convex IF2 IF2 IF1 IF1 Point to be Interpolated Figure 13 . 21 Interpolation to corners/ridges In general, it is advisable to perform a local exhaustive search using all the faces surrounding the points of the host face found (see Figure 13 .22 )... igniting fluid) Given that (13 .13 ) is conveniently 26 0 APPLIED COMPUTATIONAL FLUID DYNAMICS TECHNIQUES Gauss Points Mesh 1 (Known) Mesh 2 (Unknown) Figure 13 .15 Projection via quadrature: adaptive loop over elements of mesh 1 solved iteratively as Ml ui +1 = r + (Ml − Mc )ui , 2 2 i = 1, niter, (13 .18 ) with u0 = 0 and Ml the lumped mass matrix, one can borrow the concept of flux-corrected transport (FCT,... x0 , α 1 ,2 = N 1 ,2 , g3 = Point xp may be considered as being on the surface face if min(N i , 1 − N i ) ≥ 0, ∀i = 0, 1, 2, (13 .22 a) and dn = |α 3 g3 | < ct · |g1 × g2 |0.5 (13 .22 b) Here ct denotes a tolerance for the relative distance normal to the surface face Even though this may be a problem-dependent variable, values of ct = O(0.05) work well As before, an 26 3 INTERPOLATION xp g3 g2 n x0 g1 Figure.. .25 2 APPLIED COMPUTATIONAL FLUID DYNAMICS TECHNIQUES Several possible improvements for this algorithm, layering of brute-force searches, inside-out interpolation, measuring concavity and vectorization, are detailed in the following Step 2 Step 1 4 3 2 1 Step 3 Known Grid Unknown Grid 8 Active Front 7 6 5 Figure 13 .6 Advancing-front vicinity search 13 .5 .1 LAYERING OF BRUTE-FORCE SEARCHES... element size of mesh 1 is smaller than the element size of mesh 2 h1 < h2 some points of mesh 1 may not contribute to mesh 2 Consider next the option of performing a loop over the elements of mesh 1 (the mesh from which the solution is being interpolated) The residual vector r i for every point of mesh 2 is evaluated as ri = j i N2 N1 d uj 1 = ˆ j i Wqp N2 (xqp )N1 (xqp )uj 1 ˆ V1 1 (13 .17 ) qp In contrast... with αes = 1, ces = 0.5 Then, keep the face closest to the point being interpolated: - if (13 .22 a) is satisfied then the distance to the face is given by δ = dn ; - if (13 .22 a) is not satisfied, the closest distance to the face edges is taken: δ = minij |xp − (1 − βij )xi − βij xj |, (xp − xi ) · (xj − xi ) βij = (xj − xi ) · (xj − xi ) (13 .25 ) (13 .26 ) For the cases shown in Figure 13 . 21 we have the . (or L2 projection) N i 2 N j 2 d ˆu j2 = N i 2 N j 1 d ˆu j1 . (13 . 12 ) This may be expressed in matrix form as M c u 2 = r = Lu 1 , (13 .13 ) 25 8 APPLIED COMPUTATIONAL FLUID DYNAMICS TECHNIQUES where. elements INTERPOLATION 25 7 Table 13 .1. Mesh-to-mesh interpolation timings Case nelem 1 nelem 2 # BFS Scalar Vector Speedup Cube 1 34 6 61 30 8 01 0 0 .13 99 0. 028 3 4.94 Cube 2 34 6 61 160 355 0 0.5360 0 .11 04 4.86 Train 1 180. configuration. 25 6 APPLIED COMPUTATIONAL FLUID DYNAMICS TECHNIQUES Figures 13 .11 and 13 . 12 show the surface grids of some of these grids. Table 13 .1 summarizes the performance recorded on the Cray-C90