You are on page 1of 8

An approach to generate level set function from

STL file for fluid-structure interaction


computations

Son Tung Dang1 , Stein Tore Johansen1,2 , and Iskander Akhatov3


1
SINTEF Industry, S. P. Andersens veg 15B, 7031, Trondheim, Norway
2
Stein.T.Johansen@sintef.no
Department of Energy and Process Engineering, NTNU, 7041, Trondheim, Norway
3
Skolkovo Institute of Science and Technology, 121205, Moscow, Russia

Abstract. In this paper, we will present an approach to compute the


signed distance or level set function from the STL file format. Then
the level set is used to represent the surface of a given object inside
the computational domain. The continuity and Navier-Stokes equations
are solved numerically to study the fluid flows over the solid body. The
finite-volume method is applied to approximate all terms in the govern-
ing equations to conserve mass and momentum. The cutcell method is
employed to avoid recomputing the mesh points when the body moves
around. The transport equation for the level set function is solved ac-
cordingly to update the position of the object.

Keywords: Fluid-structure Interaction · Computational Fluid Dynam-


ics · Level-set Function · Cut-cell Method.

1 Introduction

In computational fluid dynamics, the accurate presentation of objects is crucial.


Gridding of complex objects may take a substantial time and may be a major lim-
itation in the application of CFD. Ansys Fluent [1] and PointWise [15] provide
various choices for geometry formats. However, both software are commercial
and expensive to purchase. Another software to create mesh is GSMH [7], which
is open-source. It also supports many different CAD file formats. Nevertheless,
most of these software are only used to create body-fitted meshes and the Carte-
sian mesh option is not available. In rectangular grid, instead of representing the
body surface by grid points, a scalar variable is employed to implicitly indicate
the outside of the object. There are two main variables widely used in the liter-
ature which are a volume of fluid [9] and a level set function or signed distance
field [13]. In the volume of fluid method, the volume fraction illustrates the ratio
between the part cut by the surface and the cell. The value vary from 0 to 1,
which implies empty to fully occupied cells. The level set method, on the hand,
is the signed distance which is positive outside the body and negative when the
grid point is internal. The surface will be implicitly specified by the zero level set
2 S.T. Dang et al.

value. Compared to the volume of fluid method, the level set is easier to compute
from CAD file formats. In graphic visualization, the signed distance field is gen-
erated from the .STL file using GPUs [14, 18, 2]. For fluid-structure interaction,
the distributed bounding box hierarchy has been applied to compute the level
set function from the CAD file, and then inserted into the Cartesian mesh [19,
8, 6]. Although this method can reduce the computing time for complex geome-
tries, it is difficult to implement and requires a complicated data structure. In
this study, we will present a simple method to calculate the level set function
from the .STL file. The method can be time-consuming for bodies with huge
numbers of surface elements. However, the calculation is performed only once,
at the initial stage. Therefore, this step only slightly affects to total time of the
computation. In order to compute the fluid flows over a structure, we applied
the finite volume method combined with the cut-cell approach to discretize the
governing equations [4, 5, 11, 16]

2 Equations and numerical methods


2.1 Level set function
Shortest distance The level set function is used to present the object surface.
The object is placed inside the computational domain through the .STL file
format. The .STL file is made from triangles which connect to each other. In
general, the information in the .STL file contains the normal vector of the faces
and the location all triangles vertices as follows,
facet normal nx ny nz
outer loop
vertex x1 y1 z1
vertex x2 y2 z2
vertex x3 y3 z3
end loop
end facet

The shortest distance can be achieved by two main cases


1. From the point to the triangle itself, the projected point p1 is the projection
of the point x1 onto an infinite straight plane in which the triangle is located.
when the point p1 is inside the triangle. The distance can be calculated by

dmin = d1 = |x1 − p1 | (1)

2. If the projected point p1 is outside of triangle the shortest distance can be


from the grid point to the edge or the vertex. First, we need to determine
the projected point from grid point to the edge (p2 ) and vertices (p3 ). The
distance from x2 and x3 to the edge or vertices are

d2 = |x2 − p2 |, (2)
Title Suppressed Due to Excessive Length 3

Fig. 1: The distance from a point to triangles surface

d3 = |x3 − p3 |. (3)
Then, the minimum length is determined by

dmin = min(d2 , d3 ) (4)

The sign value of distance In order to decide if the grid point is inside or
outside the object, we need to assign the sign value to the computed distance
from section 2.1. In our study, we used the ray casting method [17], which deter-
mines the sign by inserting a ray from the target point and counts the number
of intersections between the ray and the object. If this is an odd number the
point is inside the object. If the number of intersections is even it means that
the point is outside.

2.2 Governing equations and discretization

The continuity and Navier-Stokes equations describing incompressible fluid mo-


tions are given as follows,
∇ · u = 0, (5)
∂ρu
+ ∇ · (ρuu) = −∇p + µ∇2 u + ρg, (6)
∂t
where, u(u, v, w) is the velocity vector. ρ is the phase density, p is the pres-
sure, µ is dynamic viscosity and g is gravitational acceleration. In our work, the
staggered grid is used for whole computations. The arrangement is applied for
velocities and scalar fields. In addition, we use the finite volume method (FVM)
to discretize the governing equations. For a cell at which both fluid and solid
are present, as in Fig.2, the velocities locates at the face centre of the fluid con-
trol volume, while the pressure locates at original cell centre. Appy FVM for
4 S.T. Dang et al.

continuity and momentum equations, Eqs. 5 and 6 can be rewritten as


X
u · nf Af + uw · nF,w Aw = 0, (7)
Af

∂ X X
V (αf ρu) = −αf V (∇p+ρg)+ µ∇u · nf Af +τ w ·nf,w Aw − ρuu · nf Af ,
∂t
Af Af
(8)
where, Af is fluid surface area, Af,w is wall area, nf is the normal vector at the
fluid surface, nF,w is the normal vector pointing to fluid field at the wall, uw is
the wall velocity, V is the volume of the cell, αf is the fluid volume fraction in
the cell and τ w is the wall shear stress tensor. The wall shear stress is computed
based on the distance from velocity position to the solid wall (∆h), as follows,
u − uw
τw = µ . (9)
∆h
The details of discretization are given in the work of Dang et al. [5]

Fig. 2: The cell contains both fluid and solid. The interface between two phases
is marked with red colour.

3 Numerical results
3.1 Level set function for a ship
In this test, we focus on generating the level set function from a .STL file.
The object is a vessel which is created by Fussion 360. Figure 3a shows the
ship structure with simple design. Figure 3b shows the surfaces of the ship as
being assembled from triangles. The size of the ship is 332 × 168 × 600 mm.
Computing the level set function for the whole computational domain will be
Title Suppressed Due to Excessive Length 5

time-consuming. Therefore, we only perform the computation for local points


which are close to the surface. Firstly, we will loop through all triangles and de-
termine the cell containing a triangle. After that, we will create a box which will
contain the triangle plus buffer space. We assign the Band W idth as the number
of grid point inside the the buffer space. In our work, we set Band W idth = 4.
We will perform the computation for the level set function for all grid points
inside the box. Then, we will compare all values to chose the smallest distance.
Note that the normal vector of a triangle giving by the .STL file is not correct.
Therefore, it is important to recompute the normal based on the location of
triangles vertices. Figure 4 shows the level set contour obtained when we used
the ray casting method to determine the sign value. In general, the method can
compute the level set accurately.

(a) (b)

Fig. 3: The shape of ship (a) and the triangular wire-frame representing the
surface of the object (b).

3.2 Flow past a sphere


This test is used to validate our numerical method for 3D fluid-structure inter-
action. Figure 5 shows the simulation domain and numerical mesh. In this study,
we use the simplistic structure which is a sphere. The body is placed 20D from
the inlet and 40D from the outlet, where D is spherical diameter. We create the
sphere by CAD software and export it in .STL format. Then we import the file
into our code and generate the level set function which is an implicit representa-
tion of the object surface. In order to restrict the effect of boundary condition to
our results, slip walls are placed symmetrically at all sides of the computational
domain. A non-uniform mesh of 121 × 81 × 81 points is used in our simulation.
The grid is refined in the vicinity of the sphere with 20Cells/D such that we can
capture the physical phenomena around the object accurately. Figure 6 shows
our computed drag coefficient and compared with theoretical data [3] and other
numerical results [12, 10]. A good agreement between our method and previous
studies can be observed from this figure.
6 S.T. Dang et al.

Fig. 4: The zero contour level set represents the ship surface. The sign distance
is computed based on the ray casting method

Fig. 5: The computational domain (a) and the computational mesh (b) for the
flow over sphere test.

4 Conclusion

In this study, we presented the numerical method for computing the level set
function as well as solving fluid governing equations. The ray casting method is
implemented to correct the signed distance at specific region of the computa-
tional domain. Several tests were performed to validate our methods. In general,
the numerical method produced good outputs compared to other works in liter-
ature. In the future, we will perform more complex tests to check the robustness
of our method.
Title Suppressed Due to Excessive Length 7

Fig. 6: The drag coefficients for various Reynolds numbers

Acknowledgement
We would like to thank the Norwegian Research Council to fund our research
through the ICELOAD project (project number 308780, “Enabling prediction
of ice loads on structures in the Arctic”), and the Russian Foundation for Basic
Research for funding through grant number 20-58-20004.

References
1. ANSYS. https://www.ansys.com/ (2018)
2. Fast distance fields for fluid dynamics mesh generation on graphics hard-
ware. Communications in Computational Physics 26(3), 654–680 (2019).
https://doi.org/https://doi.org/10.4208/cicp.OA-2018-013
3. Clift, R., Grace, J.R., Weber, M.E.: Bubbles, Drops, and Particles. Academic Press,
New York (1978)
4. Dang, S.T., Johansen, S.T., Meese, E.A.: A Cartesian Cut-Cell Method, Based
on Formal Volume Averaging of Mass, Momentum Equations. SINTEF akademisk
forlag (2017)
5. Dang, S.T., Meese, E.A., Morud, J.C., Johansen, S.T.: Numerical Approach
for Generic Three-Phases Flow Based on Cut-cell and Ghost Fluid Meth-
ods. International Journal for Numerical Methods in Fluids 0(ja) (Jun 2019).
https://doi.org/10.1002/fld.4758
6. DesJardin, P.E., Bojko, B.T., McGurn, M.T.: Initialization of high-order ac-
curacy immersed interface cfd solvers using complex cad geometry. Interna-
tional Journal for Numerical Methods in Engineering 109(4), 487–513 (2017).
https://doi.org/https://doi.org/10.1002/nme.5294
7. Geuzaine, C., Remacle, J.F.: Gmsh: A 3-d finite element mesh
generator with built-in pre- and post-processing facilities. Inter-
national Journal for Numerical Methods in Engineering 79(11),
1309–1331 (2009). https://doi.org/https://doi.org/10.1002/nme.2579,
https://onlinelibrary.wiley.com/doi/abs/10.1002/nme.2579
8 S.T. Dang et al.

8. Günther, C., Meinke, M., Schröder, W.: A flexible level-set ap-


proach for tracking multiple interacting interfaces in embed-
ded boundary methods. Computers & Fluids 102, 182–202
(2014). https://doi.org/https://doi.org/10.1016/j.compfluid.2014.06.023,
https://www.sciencedirect.com/science/article/pii/S004579301400262X
9. Hirt, C.W., Nichols, B.D.: Volume of fluid (VOF) method for the dynamics
of free boundaries. Journal of Computational Physics 39(1), 201 – 225 (1981).
https://doi.org/https://doi.org/10.1016/0021-9991(81)90145-5
10. Johnson, T.A., Patel, V.C.: Flow past a sphere up to a Reynolds
number of 300. Journal of Fluid Mechanics 378, 19–70 (Jan 1999).
https://doi.org/10.1017/S0022112098003206
11. Kirkpatrick, M., Armfield, S., Kent, J.: A representation of curved boundaries
for the solution of the Navier–Stokes equations on a staggered three-dimensional
Cartesian grid. Journal of Computational Physics 184(1), 1–36 (Jan 2003).
https://doi.org/10.1016/S0021-9991(02)00013-X
12. Mittal, R., Dong, H., Bozkurttas, M., Najjar, F.M., Vargas, A., von Loebbecke,
A.: A versatile sharp interface immersed boundary method for incompressible flows
with complex boundaries. Journal of Computational Physics 227(10), 4825–4852
(May 2008). https://doi.org/10.1016/j.jcp.2008.01.028
13. Osher, S., Sethian, J.A.: Fronts propagating with curvature-dependent speed: Algo-
rithms based on Hamilton-Jacobi formulations. Journal of Computational Physics
79(1), 12–49 (Nov 1988). https://doi.org/10.1016/0021-9991(88)90002-2
14. Park, T., Lee, S., Kim, J., Kim, C.: Cuda-based signed distance field
calculation for adaptive grids. In: 2010 10th IEEE International Con-
ference on Computer and Information Technology. pp. 1202–1206 (2010).
https://doi.org/10.1109/CIT.2010.217
15. Pointwise: Pointwise (2020), http://www.pointwise.com/
16. Schneiders, L., Günther, C., Meinke, M., Schröder, W.: An efficient con-
servative cut-cell method for rigid bodies interacting with viscous com-
pressible flows. Journal of Computational Physics 311, 62–86 (Apr 2016).
https://doi.org/10.1016/j.jcp.2016.01.026
17. Shu, R., Liu, A.: A fast ray casting algorithm using adaptive isotriangular subdivi-
sion. In: Proceedings of the 2nd Conference on Visualization ’91. p. 232–238. VIS
’91, IEEE Computer Society Press, Washington, DC, USA (1991)
18. Sigg, C., Peikert, R., Gross, M.: Signed distance transform using graph-
ics hardware. In: IEEE Visualization, 2003. VIS 2003. pp. 83–90 (2003).
https://doi.org/10.1109/VISUAL.2003.1250358
19. Wang, K., Grétarsson, J., Main, A., Farhat, C.: Computational algorithms for
tracking dynamic fluid–structure interfaces in embedded boundary methods. In-
ternational Journal for Numerical Methods in Fluids 70(4), 515–535 (2012).
https://doi.org/https://doi.org/10.1002/fld.3659

You might also like