Volume 23, Issue 4 e202300268
RESEARCH ARTICLE
Open Access

Fast contact detection for ellipsoids using optimization approaches

Ricardo Rebel

Corresponding Author

Ricardo Rebel

Institut für Strömungsmechanik, Technische Universität Dresden, Dresden, Germany

Correspondence

Ricardo Rebel, Institut für Strömungsmechanik, Technische Universität Dresden, George-Bähr-Straße 3c, 01062 Dresden, Germany.

Email: [email protected]

Search for more papers by this author
Jochen Fröhlich

Jochen Fröhlich

Institut für Strömungsmechanik, Technische Universität Dresden, Dresden, Germany

Search for more papers by this author
First published: 10 October 2023

Abstract

The paper is concerned with fast and robust contact detection methods for arbitrary ellipsoids. An iterative procedure, namely the Levenberg-Marquardt method, based on the common normal concept for parametric ellipsoids, is employed together with an implementation of the widely used GJK algorithm for comparison. The performance and accuracy of both are analysed and compared to each other on the basis of two test sets, each containing a total of 70 000 pairs of prolates or oblates. Emphasis is placed on the specific error measure relating the iterative solution to the exact one, which was chosen to be the maximum angle between the normal vector and the distance vector between two ellipsoids. The results indicate increased performance when using the Levenberg-Marquardt method over the GJK algorithm with no loss of accuracy.

1 INTRODUCTION

The transport of particles in fluid flow plays an extensive role in both industrial [1] and environmental [2] processes. Spatially resolved simulations of particle-laden flows, considering the interactions between the particles and the fluid as well as among the particles themselves, allow the physics underlying these processes to be studied. Recent simulations of this kind considering sediment transport with ellipsoidal particles indicate a significant influence of the particle shape on the characteristics of the flow [3] as well as on the motion of the particles themselves [4]. These findings were obtained using direct numerical simulations of a channel flow with different ellipsoidal shapes, with the phase-resolved particles being coupled to the fluid using the immersed boundary method (IBM) [5]. While the IBM was employed for fluid-particle coupling, the inter-particle forces were computed using an impulse-based collision model [6] that relies on the knowledge of the points of contact, which were determined using an iterative procedure. It accounts for both, forces created by direct contact between the particle surfaces, as well as lubrication forces. In fact, the latter are highly relevant in such a situation and require the distance between the particle surfaces to be known, even if these do not touch, as this is the input for the lubrication model. A similar approach shall be used in future simulations as well, with a substantially larger number of particles. Hence, an efficient and robust contact detection method for ellipsoids has to be available.

Contact detection methods for ellipsoids can be classified by the definition of the contact points and by the their surface descriptions. Regarding the contact point, either the common normal concept or the geometric potential concept can be applied [7]. The former aims to minimise the Euclidean distance between the two ellipsoids, while the latter minimises the geometric potential. These approaches can be combined with either an implicit or a parametric surface description to generate root-finding or optimisation problems of varying dimension and complexity [8]. It is understood that such a contact detection is employed in cases where particle surfaces are in direct contact, as well as for the situation that the surfaces are still apart but close. In this case the method has to determine the shortest distance between the surfaces, as well as two points, one on each surface, constituting the anchor of the segment realising the closest distance. These points are called contact points here. Ellipsoids are strictly convex, so that a unique set of contact points exists.

It has to be recognised that the multiphase-flow community of researchers has long employed relatively simple algorithms for contact detection, while in the computer graphics community other methods are being used. One of the algorithms widespread in the latter is the Gilbert-Johnson-Keerthi (GJK) algorithm [9]. While generally devised for piecewise linear surfaces it has recently been applied to analytically defined ellipsoids with promising results [10]. For this reason it has been implemented during the present study as well in the same computational framework, so as to allow a comparison of execution times.

In the present contribution, the common normal concept together with a parametric surface description is discussed, with the GJK algorithm as a reference. The methods are tested and compared on large sets of prolate and oblate ellipsoids, providing essential insights into the performance and accuracy of both.

2 METHOD

2.1 Statement of contact problem

To determine the contact points for a large number of ellipsoids, individual pairs are considered separately. Such a pair may lead to three possible scenarios: Either a real distance occurs between their surfaces (gap), or they touch at exactly one point (perfect contact), or they penetrate each other (intersection). For the purposes of this study, only the first case is investigated. This, however, entails a certain difficulty. If the contact pair has no actual contact point, a virtual contact point must be specified. The virtual contact points are, thus, defined as the points that would most likely touch each other, as described in the introduction. The problem of finding the points of contact is, therefore, embedded into the problem of finding the points urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0001 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0002 on the surfaces of two ellipsoids urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0003 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0004 the distance urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0005 of which is minimal. This requirement can be formulated in terms of the constrained optimization problem as
urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0006(1)
Here, urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0007 is the vector connecting the two points and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0008 is the objective function to be minimized. The two constraints ensure that the points are located on the surfaces of the respective ellipsoids. To fulfill these conditions, the parametric surface description for ellipsoids urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0009 is introduced, with urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0010 referring to one of the two ellipsoids. This allows transforming the constrained optimization problem into an unconstrained one, that is
urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0011(2)
where the four angles urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0012 are summarized by the vector urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0013. A necessary condition for an optimal solution to (2) is a vanishing gradient of the objective function. This yields
urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0014(3)
where the gradient urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0015 comprises the derivatives of the two points urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0016 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0017, and the scalar product of each of them with the distance vector urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0018 must vanish. This states that the tangent vectors
urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0019(4)
are perpendicular to the distance vector at the exact points of contact. This fact identifies the present approach as a common normal method, meaning that the global solution to (2) is chosen based on the direction of the two surface normal vectors
urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0020(5)
This is illustrated in Figure 1 for the two ellipsoids urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0021 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0022.
Details are in the caption following the image
Two neighboring ellipsoids urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0023 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0024 together with the exact contact points in the context of the common normal concept. Both contact points have to share the same normal vector, apart from orientation, resulting in the requirement that each normal vector has to be co-linear to the distance vector.
The requirement that the distance urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0025, indeed, assumes a minimum and not a maximum can be rephrased into restrictions on the direction of the vector d with respect to the normal vectors n1 and n2 at the two contact points that is
image(6)

2.2 Solution procedure

Due to its non-linear nature, problem (2) has to be solved by an iterative approach. Starting at an initial guess urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0027, successive positions urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0028 are determined, using the step urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0029 to decrease f. For the present study, this was achieved by employing the Levenberg-Marquardt algorithm [11], resulting in
urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0030(7)
which requires to solve a system of equations. This can be interpreted as a combination of the steepest descent and the Gauss-Newton method based on the blending parameter urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0031. The latter is updated in every step based on the model quality, which relates the actual change in the objective function urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0032 to the predicted change. The initial condition of the iterations is obtained from connecting the centers of the two ellipsoids and taking the intersection points of the two ellipsoids and the vector connecting their centers.

2.3 Convergence criterion

An important issue to be addressed here is the choice of the convergence criterion. It is used to terminate the iterative solution procedure if in some step n the computed distance urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0033 between the two ellipsoids is sufficiently close to the exact distance urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0034, such that urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0035. Since urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0036 is not known for an arbitrary arrangement of two ellipsoids, the difference must be estimated. This estimation is realized using quantities which are readily given in each iteration of the solution procedure. Considering condition (6), the maximum angle between one of the two normal vectors and the distance vector urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0037 was chosen as the convergence criterion, such that the solution procedure is terminated if
urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0038(8)
with urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0039, and the final iteration called N.
Here, two possibilities for computing the angle urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0040 are considered. One is based on the scalar product
urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0041(9)
The other is based on the vector product
urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0042(10)
The criterion is, thus, closely related to the gradient of the objective function (6), where both the normal vectors are required to be parallel to the distance vector at the exact contact points, meaning that urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0043.

The two possible implementations were evaluated in terms of their accuracy. For this reason, a test setup was constructed, as shown in Figure 2, and the relative error for the two implementations analysed for decreasing angles θ. To make the test more difficult, the parameter k was introduced making one of the vectors very short in all tests reported, with urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0044. It turned out, however, that the results did not change when urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0045 was employed.

Details are in the caption following the image
Test setup to evaluate the error in the calculation of the angle θ between two unit vectors urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0046 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0047 with the length of the former multiplied by k.

The diagram in Figure 3 shows a linear increase in the relative error for decreasing angle when using (9). With (10), quadratic behaviour is observed. For very small angles, the relative error might be considered too large for being used in a complex multiphase computation. It is therefore necessary to assess whether this effect has an actual impact on the overall performance and accuracy of the contact detection method.

Details are in the caption following the image
Relative error for decreasing exact angle urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0048, where urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0049 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0050 refer to the vector product and the scalar product computation, respectively.

3 SETUP

To evaluate the accuracy of the method in a large-scale simulation, a framework inspired by [12] was employed that allows the construction of pairs of ellipsoids with exactly known contact points. This was used to create seven test groups, referring to seven different dimensionless distances urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0051, each containing a total of 104 pairs of ellipsoids. The sphericity urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0052 according to Krumbein [13] of the ellipsoids was fixed at urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0053 to agree with the simulations of Jain et al. [3]. This leads to two cases, a case of oblate ellipsoids and a case of prolate ellipsoids. For each individual pair, the mean equivalent diameter urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0054 and the ratio of equivalent diameters urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0055 were drawn from a logarithmic uniform distribution. Then the three semi-axes urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0056 of the two ellipsoids were constructed based on Ψ, urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0057, urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0058, resulting in ellipsoids of different size and shape. In addition to the computed distance urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0059 and the contact points urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0060 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0061 after the final iteration, different error measures were determined to evaluate the accuracy of the procedure. Since the contact points are exactly known by construction, it is straightforward to compare these exact quantities with the solutions of the iterative procedure. The following measures were determined:
urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0062(11)
which is the relative error in distance, the relative error in the position of the contact points on the two ellipsoids in their local coordinate systems, and the ratio of the two median execution times, respectively. For the latter, the own implementation of the GJK algorithm adapted to ellipsoids by Girault et al. [10] was used as a reference. Implementing both algorithms in the very same framework provides optimal conditions for assessment.

4 RESULTS

4.1 Prolate-prolate contact

The results for the medians of the measures (11) for the pairs of prolates are shown in Figure 4, 5 and 6 together with an evaluation of the robustness in Figure 7. In some of the figures only a single curve can be discerned, since continuous and broken lines strictly overlap.

Details are in the caption following the image
Median error in distance for prolates with urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0063 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0064, urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0065 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0066, ◯ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0067, △ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0068 and  urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0069 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0070.
Details are in the caption following the image
Median error of the contact points for prolates with urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0071 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0072, urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0073 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0074, ◯ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0075, △ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0076 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0077 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0078.
Details are in the caption following the image
Median relative computation time for prolates with urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0079 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0080, urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0081 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0082, ◯ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0083, △ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0084 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0085 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0086.
Details are in the caption following the image
Number of failed computations for prolates with urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0087 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0088, urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0089 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0090, ◯ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0091, △ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0092 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0093 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0094.

The findings justify the utilization of the angle urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0095 as the error measure for the iterative procedure, which can be observed in Figure 4 and 5. In the calculations performed, the medians of the maximum angles correspond to both the error in the distance urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0096 and the error in the contact points urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0097. Moreover, urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0098 decreases monotonically as the distance urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0099 increases, while urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0100 remains approximately constant. This is due to the definition of urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0101 , given in (11). In addition, Figure 6 reveals that the Levenberg-Marquardt algorithm converges significantly faster than the GJK algorithm for small distances urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0102, while the opposite behavior is observed for distances urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0103. Such cases, however, are not of interest, since the distances are too large to be needed in a true simulation with ellipsoids of this sphericity. The robustness of the Levenberg-Marquardt algorithm is illustrated in Figure 7. It is in accordance to the evaluation of the computation time since it reveals a guaranteed convergence for distances urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0104. Finally, the algorithm failed to converge in 9 out of 10000 cases for which urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0105 , corresponding to a percentage of 0.09%. If this should occur in an application appropriate measures can be taken, such as an under-relaxation of the increment, etc.

4.2 Oblate-oblate contact

The results for the medians of the measures (11) for the oblates are presented in the same way as the results of the prolates. This is shown in Figure 8, 9 and 10 together with the assessment of the robustness in Figure 11.

Details are in the caption following the image
Median error in distance for oblates with urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0106 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0107, urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0108 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0109, ◯ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0110, △ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0111 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0112 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0113.
Details are in the caption following the image
Median error in the contact points for oblates with urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0114 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0115, urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0116 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0117, ◯ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0118, △ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0119 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0120 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0121.
Details are in the caption following the image
Median relative computation time for oblates with urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0122 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0123, urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0124 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0125, ◯ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0126, △ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0127 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0128 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0129.
Details are in the caption following the image
Number of failed computations for oblates with urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0130 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0131, urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0132 urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0133, ◯ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0134, △ urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0135 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0136 and urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0137.

A very similar pattern to the above case can be observed as well, with the Levenberg-Marquardt algorithm failing to converge to the contact points in only 4 cases for urn:x-wiley:16177061:media:pamm202300268:pamm202300268-math-0138. These cases can be addressed as indicated above. Hence, it can be concluded that the medians of the relative performance and accuracy of the algorithms are independent of the specific configuration of the ellipsoids with the given shapes, for the given sphericity.

5 CONCLUSIONS

Two contact detection methods, namely a parametric common normal concept solved with the Levenberg-Marquardt algorithm as well as the GJK algorithm, have been employed. Two test sets, each containing a total of 70 000 pairs of prolates or oblates, respectively, were constructed with varying distance, orientation and volume. These were used to compare the two contact detection methods in terms of performance and accuracy.

The Levenberg-Marquardt algorithm converged to the contact points in over 99.9% of the test cases.

The results indicate increased performance of the Levenberg-Marquardt algorithm over the GJK algorithm. The accuracy exhibits no significant differences, since the same convergence criterion was used for both algorithms and the iterations pursued until this criterion was met. The computation time, however, was shorter by a factor of 3 to 6 for distances around and below a tenth of the mean equivalent diameter. For larger distances the algorithm is still faster than GJK, until the order of magnitude of the equivalent diameter is reached, a situation not of interest in a multiphase flow simulation, since lubrication forces, for example, vanish at such a distance. The present results are being extended to further cases and further algorithms in ongoing work.

ACKNOWLEDGMENTS

The authors thank the Center for Information Services and High Performance Computing (ZIH), TU Dresden, Germany, for providing the computational resources and support. RR gratefully acknowledges the scholarship provided by the Free State of Saxony, No. L-202214 as well as the financial support from the TU Dresden Graduate Academy, financed by federal and state funds.

Open access funding enabled and organized by Projekt DEAL.

      The full text of this article hosted at iucr.org is unavailable due to technical difficulties.