Using Space Filling Curves for Efficient Contact

2 downloads 0 Views 665KB Size Report
Again, it is the box number the node is placed in, and all nodes are sorted .... Proof An insertion sort based on a balanced binary tree needs in average case c ...
Using Space Filling Curves for Efficient Contact Searching Ralf Diekmann∗ Lars Taenzer∗

Jan Hungersh¨ofer†

Michael Lux

Jens-Michael Wierum†

Abstract An efficient contact search for dynamic explicit finite element (FE) simulations with several moving bodies is essential to avoid unacceptable costs. The time spent for contact algorithms is mainly determined by the cost of the search phase. We present a variant of the position code algorithm for efficient global contact search. Instead of a row-wise ordering we propose a numbering that follows a space filling curve. An analysis proves that the new ordering is more efficient in case of long surface segments. The two variants of the position code algorithm and another widely used algorithm, which is based on a hierarchical ordering, are implemented in an industrial FE code and applied to problems in fastening and demolition technology. Experimental results show that the presented method is well suited for all types of meshes and meets the great demands on efficiency for the mentioned field while the other algorithms show disadvantages in some cases.

Key words: finite elements, contact search, space filling curves, complexity analysis. AMS subject classifications: 65Y20, 68Q25.

1

Introduction

In Lagrangian FE formulations, contact between moving surfaces and/or moving bodies is one of the most crucial parts of the whole simulation. Since there are N 2 possible contact combinations in a mesh with N surface nodes the contact detection is asymptotically very expensive. Therefore, an all-to-all comparison produces unacceptable costs in most situations. The need for an efficient algorithm for this phase of the simulation is obvious. Most algorithms for a self-acting contact search in FE simulations are split into two phases. We investigate the first phase, called global search or pre-contact, which reduces the number of tests for contact between surface segments and potentially penetrating nodes. In this phase, all potentially penetrating nodes which are close enough to have contact to a given segment within the next calculation steps are found. This allows the second phase, called local search or post-contact, to apply the exact contact-test only to those segment-node combinations which are close to each other. For this part of the contact search we have extended the inside/outside-algorithm by Wang and Nakamachi [9]. The three different approaches for the global search phase we have examined are: A hierarchical algorithm which groups together neighboring surface segments to higher order contact objects, and two methods creating an ordering over a grid of boxes being laid over the FE mesh. The first ordering is a straightforward line-by-line numbering, the second one is more complex using a space filling curve. All algorithms avoid the all-to-all comparison and reduce the time complexity for the contact detection. The algorithms have been implemented and tested in two-dimensional real-world FE applications. Some results are shown in the last section. Furthermore, we have analyzed two algorithm variants for their complexity in section 4. ∗ Hilti

Corp., Principality of Liechtenstein, {diekral,taenzer}@hilti.com Center for Parallel Computing, {hunger,jmwie}@upb.de

† Paderborn

c 2000 IMACS) 16th IMACS World Congress (

1

Using Space Filling Curves for Efficient Contact Searching

2

2

The environment

The types of algorithms which are suited best for the different parts of contact handling (global search, local search, calculation of contact forces and displacements) strongly depend on the FE model, the type of application, and the measure of interest. We can distinguish between dynamic and (quasi-) static processes, large and small displacements, and explicit and implicit time integrations. It is important to know whether the measures of interest are more global or if solutions in the contact zones (like contact forces or local stress distribution) are of interest. And the timing requirements are of importance, too, i. e. how large is the (FE-) cost for one timestep and how many steps are performed. Contact correction algorithms can be divided into the two classes of Lagrange multiplier methods and penalty methods [2, 10]. The first ensure non-penetration by determining penetration correction forces and displacements. The method does not need any additional parameters and supports different friction models. If the contact situation is complex (several contacting bodies with sharp corners), the penetration detection and correction becomes quite difficult and the dependencies between neighboring parts of penetrating surfaces quickly get very complex, see e.g. [3, 7]. The penalty methods apply penalty forces to penetrating nodes and let the time integration correct penetrations. The penalty parameters are not easy to determine, but as there is no non-penetration condition, there are also no complex dependencies between contacting surfaces. In many applications of numerical simulation in computational mechanics, global measures are of importance, like for example the energy dissipation or global deformations in car crash. In such problems, penalty or pinball methods are well suited to resolve unphysical penetrations of moving surfaces. It is not necessary to correct penetrations in each step completely and the contact forces are usually not considered in detail. In contrast to these global questions, we are especially interested in the solution in the contact zone. The code we are working on is designed to answer questions in fastening and demolition technology. In dynamic problems like anchoring of nails in a steel support or modeling impact for demolition problems, the relevant effecting processes take place in or close to the contact zone. Thus, we have to determine stresses and wave propagations across contact zones at a high accuracy. Clearly, penalty methods are not well suited for such kinds of problems. Multi-body impacts at high velocities, large strains and fragmentation with newly generated surfaces including sharp corners increase the difficulties of ensuring non-penetration and determining physically consistent contact forces and stresses. To resolve wave propagations, our code uses an explicit time integration scheme. The contact forces are calculated each time step solving linear equation systems for adjacent master segments [1, 3, 8]. Several hundred thousand time steps are performed for typical fastening and demolition applications. As an advantage for the contact search, the maximum displacement any node can receive per step is known in advance. The displacement within the next time steps can be estimated using the current velocity of the FE nodes. In such an environment with complex contact situations and a very large number of timesteps an advanced contact search is essential. For the determination of contact between different bodies we use the following surface model. Each body’s surface is modeled by a closed polygon of surface segments. In the present formulation contact is always between a segment (master) and one or more nodes (slaves) moving to the material side of the segment.

3

Global search

For all global search algorithms we build a small space in each direction around a segment, called ”halo”. Only nodes within this halo may come in contact to the segment within the next k timesteps. These nodes are put into a local list and tested for contact against a segment each timestep. The size ε of the halo is calculated depending on the maximum speed of the nodes in the mesh. This technique reduces the frequency of the global search to every k timesteps.

3.1

Hierarchical ordering

The hierarchical ordering (HO) is some kind of intuitive algorithm constructing a tree-like data structure over the mesh’s surface. Starting with the segments as the leafs the mesh’s surface is grouped into larger units. For all tree nodes an axis-aligned bounding box is calculated to allow simple intersection testing. It is a necessary condition that the bounding boxes of two groups of segments intersect for their contents to have contact. Of course, further exact examination is necessary after that. To simplify matters we have used bounding boxes which are oriented parallel to the coordinate system where the FE mesh is embedded. The number of detailed contact tests can be further reduced by using sloped bounding boxes [4]. In contrast to Zhong and Nilsson [11] who introduced the Hierarchical Territory Algorithm (HITA), we use a binary tree to achieve a more general definition.

Using Space Filling Curves for Efficient Contact Searching

3.2

3

Linear position code

Another algorithm we have looked at is the linear position code (LPC) algorithm by Oldenburg and Nilsson [6]. It creates an artificial ordering of all nodes in the FE mesh. For that purpose the two-dimensional searching area is divided into a large number of small square boxes which are numbered line by line, e. g. from left to right and bottom to top. A position code (PC) is assigned to each node. It is the number of the box the node is placed in. Sorting the nodes with respect to their position codes allows to find nodes in adjacent boxes efficiently using binary and exponential search.

3.3

Space filling curve algorithm

The row-wise ordering implies one major disadvantage: Segments which are oriented vertically are more expensive than horizontal ones. To get around this drawback the row-wise ordering can be replaced by a space filling curve which visits all boxes in some kind of N-like order (Lebesgue curve). This space filling curve is defined in a recursive manner and preserves high locality. The space filling curve (SPC) algorithm divides the search area into quarters. These boxes are numbered depending on their position with the binary codes 00 (bottom left), 01 (top left), 10 (bottom right), and 11 (top right). The division is continued recursively up to a certain, pre-defined level, with b being the edge length of the smallest boxes. Each child box gets assigned a code which is the code of its parent box concatenated with 00, 01, 10, or 11 as defined above. This gives a unique key for each box mapping the Lebesgue curve into the searching area. Now a position code is assigned to each node. Again, it is the box number the node is placed in, and all nodes are sorted according to it. In order to update the position code of a node efficiently during the simulation two additional values Lx , Ly have to be stored for each node. These are the number of boxes of the lowest level, i. e. the smallest boxes, in x- and y-direction which lie left and underneath the node’s box. With this information the position code of a node can be updated efficiently. For a given node the new position code can be determined by testing the x, y-coordinate against Lx,y · b and (Lx,y + 1) · b. This shows whether the node has moved into an adjacent box since the last position code calculation. The new position code can be obtained from the old one by applying a bit-mask1 with one logical XOR-operation for each direction. For updating the halo information of a segment, i. e. building a list of all nodes in proximity, all boxes have to be found which are touched by the segment or the halo. Therefore a rectangle with distance ε is put around the segment’s endpoints. The position code of the boxes of the four corners can also be calculated with bit-wise XOR-operations. There are up to four ranges of position codes which cover the whole halo. Boxes with these codes have to be searched for nodes. By combining binary with exponential searching this can be done quickly.

4

Complexity of the PC algorithms

This section compares the complexity of both variants of the position code algorithm: linear and space filling curve. We have determined the number of comparisons in the average case for all three phases of the global contact search: initialization, list update, and candidate update. The analysis shows a complexity of O(N log N ) for the initialization of both PC variants. If l is the length of the longest segment, each global search requires O(N · (l · log N + l2 )) operations for LPC and only O(N · l2 ) operations for SPC. That means, that the costs per node are independent of the size of the mesh’s surface for the SPC algorithm. For the analysis we assume a scenario of N = n · n position code boxes each containing a single surface node. The maximum level of the space filling curve is Lmax = dlog ne − 1. The proof also holds if several nodes in each box are assumed while the number of nodes in a single box is bounded by a constant.

4.1

Initialization

For the calculation of the linear position code we need only a constant number of operations per surface node. The code within the space filling curve needs O(log n) comparisons. To allow efficient access to the code list we have to sort it which means O(log n) comparisons per node. 1 For

level L the bit-mask is (10)L+1 for horizontal movement and (01)L+1 for vertical movement. Each bit-mask has to be calculated only once at the beginning of the simulation.

Using Space Filling Curves for Efficient Contact Searching

4.2

4

List update

The update of the underlying data structure has to take into account all movements of nodes during the explicit time integration. We assume that the maximum movement of a node is smaller than the size of the position boxes. The following proofs can be adapted to larger velocities while the movement is bounded by a constant number of boxes. Lemma 4.1 The update of the position codes for the LPC needs O(N · log n) operations. Proof While the calculation of the new position code can be done in constant time, the resorting of the position code array is more expensive. Half of all nodes crossing a boundary will cross a horizontal one in average case. Thus, O(N ) nodes have to be moved n positions in the array. Finding the correct position needs O(log n) operations. Lemma 4.2 The update of the position code within the space filling curve can be done in O(1) in average case. Proof We need four comparisons to check, whether a node has left its box. Additionally, we need t(k) = k + 1 comparisons to check the level k of the crossed boundary. One half of the boundaries are of level 0, one quarter are of 1 level 1, and so on. Thus, the probability of crossing a boundary of level k is p(k) = 2k+1 . These considerations lead to an average number t¯ of comparisons of t¯ =

LX max

p(k) · t(k) ≤

k=0

∞ X

p(k) · t(k) =

k=0

∞ X k+1

k=0

2k+1

=

∞ X k = 2. 2k

k=1

The calculation of the new position code for a known boundary level can be done with a single XOR-operation. Lemma 4.3 Resorting the updated list of position codes can be done in O(1) per node in average case. Proof An insertion sort based on a balanced binary tree needs in average case c · log2 d operations2 to insert a key with distance d from the actual position [5]. A node crossing a boundary of level k has to be moved by less than Pk−1 Pk x d(k) = 3 · 4k entries, because between the old and the new box are 2 · x=1 4x (vertical boundary) resp. x=1 4 (horizontal boundary) other boxes on the path of the space filling curve. For the average number of comparisons we get with the probability of the level of any boundary t¯ ≤

LX max

p(k) · c · log2 d(k) =

k=0

4.3

LX max k=0

1 2k+1

∞ X  1 · c · log2 3 · 4k ≤ c · · 2k = c · 4. 2k k=1

Candidate update

We consider the number of operations needed to find all candidate nodes of a given segment with length l anywhere  in the given area. In average case, the axis aligned bounding box of the segment is less or equal than π2 · bl + 2 ¯ w). boxes in height and width (h, ¯ Starting from one of the segments nodes we have to find all nodes in boxes covered by the halo of the segment. In case of the linear position code, all boxes are numbered row by row, therefore we ¯ boxes each with distance less or equal n − w. have to find h ¯ Searching a key with distance d in a sorted array needs less than 2 · log d operations using exponential search. The overall complexity of finding the boxes is bounded    ¯ = by π2 · bl + 2 · 2 · log2 n − π2 · bl − 2 . The area of the segments bounding box can be approximated by a R π/2 1 1 2 l · cos α · l · sin α dα = π · l . There might be one more row and column of boxes which have to be examined, π/2 · 0 thus we perform a candidate check for lemma:

1 π

·

l2 b2

+4·

l b

boxes (resp. nodes). These considerations lead to the following

Lemma 4.4 The candidate update for the LPC needs O(l · log n + l2 ) operations per surface segment in average case. Lemma 4.5 The candidate update for SPC can be done in O(l2 ) per segment in average case. Proof At first, all nodes in neighboring boxes have to be found. This can be done in constant time in average case: We need 2 · log d operations to find a node with distance d using exponential search. Further analysis of this step follows the argumentation of lemma 4.3. The number of nodes which have to be√ checked is bounded by the smallest level i of the space filling curve which is larger than the segment size: log2 2·π 2 · bl + 1 . The number of nodes is  l 2 . limited by 4 · 4i ≤ 32 · b·π 2 Constant

c depends on the implementation.

Using Space Filling Curves for Efficient Contact Searching

5

Figure 1: Benchmark ”squares”

Figure 2: Benchmark ”rings”

80

400 HO LPC SPC

300 1000 comparisons

1000 comparisons

60

40

20

0 8x8

16x16

24x24 32x32 number of squares

40x40

48x48

Figure 3: Average number of comparisons for the global search phase for benchmark ”squares”

5.1

200

100

0

5

HO LPC SPC

8

16

24 32 number of rings

40

48

Figure 4: Average number of comparisons for the global search phase for benchmark ”rings”

Experimental results Benchmarks

For the experimental analysis we have developed a set of benchmarks with different characteristics to examine the performance of the three search algorithms. For this paper we have selected two of them with distinct characteristics for discussion. The examples are academic and relatively simple in shape but scalable in size to investigate the algorithms for various problem sizes. The size of the examples went up to 2 500 surfaces and 9 500 surface segments. To determine the efficiency of the algorithm we have counted the average number of comparisons during a global search. As one comparison can count the comparison of two integer values, e. g. two list indices, or the test of two point coordinates. The benchmark ”squares” (fig. 1) is a surrounding frame filled with single squares which are placed regularly in 4 to 48 rows and the same number of columns. In the beginning 25 % of them are randomly selected and moved in stochastical direction with equal velocity. The contact lines are short in this examples, i. e. 4 segments except for the wall, but numerous. The position changes of the elements are quite large since there is a lot of movement in this example. The benchmark ”rings” (fig. 2) consists of up to 48 concentric rings. The outer rings have slightly more elements than the inner ones. All rings get an initial velocity in different directions. The length of the contact segments and the length of the contact lines is varying throughout the mesh. The position change of the objects is obviously small due to the nested arrangement of the objects.

5.2

Results

For the benchmark ”squares” the LPC and the SPC algorithm behave quite similar (fig. 3). The reason for this is the uniform length of the contact segments. We have shown that both methods produce the same costs for this case. The HO algorithm gives not as good results because of the large displacements of the squares. This causes enlargements of

Using Space Filling Curves for Efficient Contact Searching

6

the bounding boxes of the hierarchical tree’s nodes which produce more overlapping and therefore more intersection tests. Taking into account that the problem size is increasing quadratically the step-up stays linear as expected from the analysis. The second selected scenario ”rings” shows the difference between the SPC and the LPC methods (fig. 4). The long vertical surface segments in the outer rings require more search and comparison operations for the LPC algorithm. This scenario also disclosures a major drawback of the HO approach. Since all objects are nested all contact areas intersect and need to be inspected further. Even the areas around few surface segments intersect due to the small distance between the rings.

6

Conclusion

Comparing the measured results we come to the conclusion that a general proposition about the best algorithm cannot be made. The selected meshes reflect the different properties of the methods and show their strength and weaknesses. The HO algorithm is well suited for simulations with contact in small parts of the mesh and where the contact areas are not overlapping to much. But in the case of large overlapping areas or nested objects this algorithm does not perform as good as the position code algorithms. The LPC algorithm has some disadvantages when long vertical segments occur in the mesh. This does not apply to the SPC algorithm which has no preference for any segment direction or mesh orientation. In most cases the Lebesgue curve shows higher locality than the linear numbering. Additionally, it limits the number of search operations to a maximum of four, independent from the length of the segment. The SPC algorithm has also shown good results for FE simulations of fastening and demolition problems and is recommended for similar two-dimensional real-world FE applications.

References [1] E. Anderheggen, D. Ekchian, K. Heiduschke, P. Bartelt. A contact algorithm for explicit dynamic FEM analysis. In M.H. Aliabadi and C.A. Brebbia, Contact Mechanics, Computational Techniques, Proc. 1st Int. Conf., Southampton, UK, 271–283, 1993. [2] T. Belytschko, M.O. Neal. Contact-impact by the pinball algorithm with penalty and Lagrangian methods. Intl. Journal for Numerical Methods in Engineering, 31:547–572, 1991. [3] G.T. Camacho, M.Ortiz. Adaptive Lagrangian modelling of ballistic penetration of metallic targets. Computer methods in applied mechanics and engineering, 142: 269–301, 1997. [4] Stefan Gottschalk, Ming C. Lin, and Dinesh Manocha. Obbtree: A hierarchical structure for rapid interference detection. In Proc. ACM Siggraph, 1996. [5] K. Mehlhorn. Data structures and algorithms, Vol. 1: Sorting and searching. Springer, Berlin, 1984. [6] M. Oldenburg and L. Nilsson. The position code algorithm for contact searching. Intl. Journal for Numerical Methods in Engineering, 37:359–386, 1994. [7] D.R.J. Owen, D. Peric, E.A. de Souza Neto, A.J.L. Crook, J.Yu, P.A: Klerck. Computational strategies for discrete systems and multi-fracturing materials. Proc. European Conf. on Computational Mechanics, Munich, 1999. [8] L. Taylor, D. Flanagan. PRONTO 2D: A two-dimensional transient solid dynamics program. Sandia Nat’l Labs, SAND86-0594, 1987. [9] S.P. Wang and E. Nakamachi. The inside-outside contact search algorithm for finite element analysis. Intl. Journal for Numerical Methods in Engineering, 40:3665–3685, 1997. [10] P. Wriggers. Finite element algorithms for contact problems. Archive of Computational Methods in Engineering, 2:1–49, 1995. [11] Z.H. Zhong and L. Nilsson. A contact searching algorithm for general contact problems. Comp. & Struct., 33(1):197–209, 1989.