0% found this document useful (0 votes)
22 views44 pages

Algorithms For Uniform Particle Initialization in Domains

This document proposes an improved algorithm for initializing uniformly distributed particles in domains with complex boundaries for use in smoothed particle hydrodynamics (SPH) simulations. The algorithm uses density gradient, repulsion force, and damping force to iteratively move particles until a uniform distribution is achieved both inside and on the surface of complex geometries. It generates sets of solid and fluid particles that accurately capture geometry while maintaining approximately constant particle density for SPH simulations of fluid flows past solid bodies. The source code implementing this algorithm is open source.

Uploaded by

li15029940164
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views44 pages

Algorithms For Uniform Particle Initialization in Domains

This document proposes an improved algorithm for initializing uniformly distributed particles in domains with complex boundaries for use in smoothed particle hydrodynamics (SPH) simulations. The algorithm uses density gradient, repulsion force, and damping force to iteratively move particles until a uniform distribution is achieved both inside and on the surface of complex geometries. It generates sets of solid and fluid particles that accurately capture geometry while maintaining approximately constant particle density for SPH simulations of fluid flows past solid bodies. The source code implementing this algorithm is open source.

Uploaded by

li15029940164
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

Algorithms for uniform particle initialization in domains

with complex boundaries


Pawan Negia,∗, Prabhu Ramachandrana
arXiv:1910.07898v3 [physics.comp-ph] 8 Jan 2021

a
Department of Aerospace Engineering, Indian Institute of Technology Bombay, Powai,
Mumbai 400076

Abstract
Accurate mesh-free simulation of fluid flows involving complex boundaries
requires that the boundaries be captured accurately in terms of particles.
In the context of incompressible/weakly-compressible fluid flow, the SPH
method is more accurate when the particle distribution is uniform. Hence,
for the time accurate simulation of flow in the presence of complex bound-
aries, one must have both an accurate boundary discretization as well as a
uniform distribution of particles to initialize the simulation. This process
of obtaining an initial uniform distribution of particles is called “particle
packing”. In this paper, various particle packing algorithms present in the
literature are implemented and compared. An improved SPH-based algo-
rithm is proposed which produces uniform particle distributions of both the
fluid and solid domains in two and three dimensions. Some challenging ge-
ometries are constructed to demonstrate the accuracy of the new algorithm.
The implementation of the algorithm is open source and the manuscript is
fully reproducible.
Keywords: Particle packing, complex geometry, pre-processing, smoothed
particle hydrodynamics

Program summary
Program title: SPHGeom


Corresponding author
Email addresses: [email protected] (Pawan Negi),
[email protected] (Prabhu Ramachandran)

Preprint submitted to Elsevier January 11, 2021


Licensing provisions: BSD 3-Clause
Programming language: Python
External routines/libraries: PySPH (https://github.com/pypr/pysph),
matplotlib (https://pypi.org/project/matplotlib/), automan (https:
//pypi.org/project/automan/), ParaView(https://www.paraview.org/
download/).
Nature of problem: Particle methods require that complex geometry be rep-
resented accurately when discretized with particles. The particles should be
uniformly distributed inside, outside, and on the surface of the geometry. A
particle packing algorithm is proposed to achieve this. For a fluid flow past
a solid body, the code generates a set of solid particles inside and on the
surface surrounded by fluid particles such that the density is approximately
constant. These particles can be placed anywhere in the main simulation.
Solution method : An SPH-based algorithm is proposed where the number
density gradient, a repulsion force, and a damping force are used to move
particles. Particles are constrained near the boundary to move along the
surface. Particles are iteratively projected onto the boundary surface. Once
a desired distribution of particles is achieved, the particles are separated into
interior and exterior particles using the boundary information. This may be
used directly as an input for particle-based simulation.
Additional comments: The source code for this repository can be found at
https://gitlab.com/pypr/sph_geom.

1. Introduction
Smoothed Particle Hydrodynamics (SPH) is a mesh-free numerical method
used for the simulation of continuum mechanics problems. It was first pro-
posed by Gingold and Monaghan [1] and Lucy [2]. Unlike mesh-based meth-
ods, the SPH method discretizes the domain into particles that carry physical
properties. The SPH method has been employed to study a wide variety of
problems. A comprehensive list of schemes can be found in Liu and Liu [3],
Violeau [4], and Ye et al. [5].
The SPH method approximates functions and derivatives by using a con-
volution with a smooth kernel function
Z
f (x) = f (x̃)W (x − x̃, h)dx̃ + O(h2 ), (1)

where Ω is the domain, W (x − x̃, h) is a compact kernel function with prop-


erties described in [6] and h is the support radius of the kernel. The domain

2
is discretized into particles carrying the required properties. This integral is
then discretized as
X mj
f (x) ≈ f (xj )W (x − xj , h) , (2)
j
ρ j

m
where xj is the position of the j th particle and Vj = ρjj is the volume asso-
ciated with the particle with mass mj and density ρj . This approximation
is most accurate when the underlying particle distribution is uniform [7, 8].
For example, the particles could be placed on a uniform Cartesian mesh with
constant spacing. However, the SPH method is Lagrangian and the parti-
cles move with the local velocity field. Many recent developments in SPH
involve the use of Particle Shifting Techniques (PST)[9, 10, 11] which shift
the particles towards a uniform distribution. Thus, it is important to have a
uniform distribution of particles.
Consider the case of the two-dimensional flow past a simple non-Cartesian
solid shape like a circular cylinder. The fluid flow occurs outside of the
cylinder. In the SPH method, the fluid is discretized using (fluid) particles.
The circular cylinder is also discretized with (solid) particles. These solid
particles are not merely on the surface of the cylinder but also on its interior
for accuracy of the method. When the simulation starts, we require a uniform
distribution of both fluid and solid particles which capture the geometry
accurately. Clearly, one cannot use a Cartesian mesh of particles and still
describe the cylinder surface accurately.
We must therefore define the term “uniform” distribution of particles in
the context of the SPH method. This has been discussed by Colagrossi et al.
[12] and Litvinov et al. [13]. They explain that a non-uniform distribution
would generate a spurious force among the particles leading to a “resettle-
ment” of their spatial distribution.
As discussed in [12], for particles having the same mass and density, we
can estimate the non-uniformity using either,
X mj
Γi = W (xi − xj , h) , (3)
j
ρj

where xi refers to the ith particle or


X mj
∇Γi = ∇W (xi − xj , h) . (4)
j
ρj

3
where ∇W is the gradient of the kernel function with respect to xi . If Γi = 1
or ∇Γi = 0, then the particle distribution may be considered uniform. For
example, for particles placed on an infinite Cartesian mesh Γi ≈ 1, ∇Γi ≈ 0
for all particles. In this paper, particle distributions that satisfy this re-
quirement are referred to as uniform, homogeneous, or regular distributions
interchangeably. The term “particle packing” is used in the literature as the
process of generating such a homogeneous distribution of particles.
There are many higher-order SPH schemes like [14, 15, 16, 17] which em-
ploy corrected kernel functions such that Γi = 1 and ∇Γi = 0 by construction
regardless of the underlying particle distribution. In such cases it may be
argued that there is no requirement for a uniform/homogeneous distribution
of particles. However, these methods do not always ensure the conservation
of linear and angular momentum. On the other hand, the uncorrected ker-
nels when used with a suitable formulation do conserve linear and angular
momentum as discussed in [17]. Therefore, even with a higher-order SPH
method, it is usually desirable to have a reasonably uniform distribution of
fluid and solid particles to improve conservation [8].
Many problems involving complex geometries have been solved in the SPH
literature. For example, the flow around blades of mixing devices [18] and
industrial automotive problems [19]. In order to simulate such problems, the
initial particle distribution must capture important features of the geometry
accurately while maintaining a uniform spatial distribution.
There have been some earlier attempts to do this in the context of SPH.
Colagrossi et al. [12] devised a particle packing algorithm which uses the
kernel gradient to distribute the particles in two-dimensions around a solid
body such that the simulation starts smoothly. In order to generate the two-
dimensional solid, the method proposed by Marrone et al. [20] was employed.
The method constructs solid boundaries using piecewise linear curves (PLC).
These are translated along the normal and discretized into equispaced parti-
cles according to the desired particle spacing, ∆s, up to the required number
of layers. Xiao et al. [21] proposed an algorithm to divide the two-dimensional
domain of interest into square-shaped sub-domains. The sub-domains having
an area equal to the desired area (∆s2 ) are directly converted to particles.
Other particles near the boundary are given partial mass iteratively. None
of these approaches consider three-dimensional geometries. Domı́nguez et al.
[22] constructs geometries by clipping the grid with the boundary of the ge-
ometry, and this necessitates using a much higher resolution to capture the
features better. Akinci et al. [23] proposed a scheme to place particles over

4
triangles of length greater then the particle spacing. This approach provides
a good density distribution and has been employed to simulate flow for graph-
ics applications in three dimensions. In a different context, Jiang et al. [24]
used the SPH method for packing particles in order to sample blue noise.
This method focuses on packing the particles inside and on the surface of
the body. The method does not generate any particles outside the body. In
order to obtain a uniform particle distribution, a kernel gradient along with
a cohesive force proposed by Akinci et al. [23] is used. It balances the extra
force on the particles near the surface.
In this paper, the methods proposed by Colagrossi et al. [12] and Jiang
et al. [24] are implemented. The method of Jiang et al. [24] does not by
default generate particles in the exterior of the boundary. A modification
of the algorithm is proposed so that it generates the desired particles in
the interior and exterior. A novel SPH-based method to construct two and
three-dimensional geometries, at a given resolution, keeping the features of
the geometry as detailed possible, is proposed. The following nomenclature
is used henceforth to refer to the methods implemented:

• Standard : The geometry is created using the method proposed by Mar-


rone et al. [20] and particles are packed using the method proposed by
Colagrossi et al. [12]. It must be noted that the method proposed in
[20] is limited to two-dimensional geometries.

• Coupled : The interior (solid) and exterior (fluid) are created separately
using the method proposed by Jiang et al. [24]. Once these converge,
the interior and exterior interact using the method of [12].

• Hybrid : The proposed new method which combines features from the
above two approaches.

The hybrid method uses the kernel gradient to move the particles as
proposed by Colagrossi et al. [12] along with a strong repulsion force, which
comes into effect only when two particles are closer than the particle spacing.
The particles on the boundary are allowed to move over the surface only as
done in [24]. Particles that are not on the boundary, are allowed to move in
and out of the boundary surface. Particles are projected on the boundary
which introduces disorder causing the other particles to adjust accordingly.
It is important to note that the proposed algorithm can be applied in the
context of any general-purpose SPH framework. This makes the approach

5
relatively easy to integrate into SPH codes. The present implementation
uses the open-source PySPH framework [25, 26]. The particle distributions
generated using the above methods are compared for different geometries.
The accuracy of the proposed method is demonstrated by performing an
SPH function and derivative approximation for a known function.
The paper is divided into four sections. The next section briefly discusses
the SPH method. The section 3 describes the algorithms implemented in
detail. In section 4, different geometries are constructed using the algorithms
implemented. In the interest of reproducibility, the implementation of the
algorithms is open source and all the results are fully reproducible.

2. Smoothed particle hydrodynamics


As discussed in the introduction, the SPH method approximates a func-
tion using a smooth, compact kernel, W (x). Popular choices for the kernel
in the SPH community are the Gaussian [6], splines [27] and the family of
Wendland kernels [28]. In order to reproduce the given function with O(h2 )
accuracy, the kernel function must have
Z Z
W (x − x̃, h)dx̃ = 1, and ∇W (x − x̃, h)dx̃ = 0. (5)
Ω Ω

In the continuous approximation, all of these kernel satisfy these properties


[7]. In the SPH method, the domain is discretized using points each having
mass m and density ρ. The discrete approximation of the density ρ and its
gradient is given by
N
X N
X
ρi = mj Wij and ∇ρi = mj ∇Wij , (6)
j=1 j=1

where Wij = W (xi −xj , h), mj is the mass of ith particle and N is the number
of neighbors in the kernel support. We can see that if all particles have the
same density ρi = 1, then, eq. (6) becomes the same as eq. (3) and eq. (4).
We therefore assume that all particles have a unit density henceforth.
For a uniform distribution of particles, the value of Γi = 1 and ∇Γi = 0
accurate to the order O(h2 ). Furthermore, as discussed in Kiara et al. [8], the
kernel and its gradient can be corrected such that the condition in eq. (3) and
eq. (4) are satisfied even for a non-uniform distribution of particles. However,
using a corrected kernel introduces issues in momentum conservation when

6
the particles are non-uniform. Therefore, it is important to have a uniform
particle distribution.
In the weakly compressible SPH scheme, the dynamics of the fluid flow
is governed by

= −ρ∇ · u, (7)
dt
du ∇p
=− + ν∇2 u, (8)
dt ρ
p = p(ρ, ρ0 , c0 ) (9)

where ρ, ν, p, u are the density, kinematic viscosity, pressure and velocity


of a discrete fluid particle respectively. ρ0 and c0 are the reference density
and speed of sound. The derivatives can be approximated using various
forms cf. [4]. In a simulation with a solid body, for example the flow past a
cylinder, the solid particles are represented using classical dummy particles
[29]. The use of a rectangular lattice would comply with the condition in
eq. (6) however, the resulting boundary will be jagged. In order to produce
a body conforming initial particle distribution such that the conditions in
eq. (5) is satisfied, various particle packing algorithms are discussed in detail
in the next section. We note that once the packing algorithm completes
that there may be slight variations in the density of the order of around 2-
3%. Colagrossi et al. [12] propose that the particle masses be changed so as
to produce a constant density given the initial pressure field. This may be
performed after the packing algorithm is complete if desired.

3. Particle packing algorithms


In this section, the proposed hybrid algorithm followed by other algo-
rithms are discussed in detail.

3.1. Hybrid Algorithm


The schematic shown in fig. 1, depicts the different kinds of particles
used in the proposed algorithm. In this figure, we consider the case of a
cylinder surrounded by fluid. The dashed black line represents the surface
of the cylinder (boundary surface) which we wish to capture accurately. We
assume that this surface is discretized into a set of points called “boundary
nodes”. The different kinds of entities shown in the figure are,

7
Free particle

Frozen particle
Boundary surface

Boundary node

Boundary particle

Figure 1: Schematic of the initial distribution of particles and the different kinds of par-
ticles.

• Free particles: These are particles arranged initially in a rectangular


or hexagonal-packed pattern. Their motion is not constrained. These
are depicted as blue circles.

• Frozen particles: These are a set of fixed classical dummy particles


which surround the free particles in order to provide support to the
kernel. These are depicted as green circles.

• Boundary particles: These particles are constrained to move along the


“boundary surface” and are depicted as red circles.

• Boundary surface: The surface of the geometry that is discretized. It


is represented by a set of fixed points, called “boundary nodes” which
do not influence any other particles.

• Boundary node: These are points that discretize the boundary surface,
they also store the local surface normals of the boundary surface. These
are depicted as black dashes. We note that these are called nodes
because they do not exert any forces on particles and only serve to
provide information on the position and orientation of the boundary
surface.

8
During the algorithm, free particles (blue) may be converted to boundary
particles (red) if they are close to the boundary surface. Once the proposed
algorithm completes, the red boundary particles must conform to the bound-
ary represented by the dashed black line. The blue particles inside the dashed
boundary will be considered as solid (dummy) particles and those outside as
fluid particles.

Initialize particles Geometry specification

Initialize boundary
nodes

Compute acceleration

Move particles
Yes
Project free particles
on boundary surface
Initial
projection

Any particles No
projected?

No

Converged?

Yes

Find internal to simulation


Stop
points

Figure 2: Flowchart of the particle packing algorithm. The box outlined in dashed red
lines is the initial projection phase.

The overall flow of the algorithm is shown in fig. 2. The algorithm re-
quires two inputs, the geometry information, and the desired particle spacing.
These are to be provided by the user. Given the geometry surface, we first
estimate the number of particles that should lie on this surface, Ns , using

9
the desired spacing of particles and either the length in 2D or the surface
area in 3D.
Initially, the frozen particles are created on the periphery of the domain
as shown in fig. 1 and placed on a rectangular lattice. Free particles are then
placed inside this on a regular lattice. At this stage, no boundary particles
are identified. The boundary nodes are initialized using the information
provided by the user.
The acceleration on the free particles and any boundary particles (that
are identified later) is computed using a local density gradient, and a repul-
sive force. This corresponds to the green block in fig. 2. The particles are
moved using the computed accelerations. As the free particles move, they
are converted to boundary particles if they are close enough to the bound-
ary surface. They are then projected to the nearest point on the boundary
surface. These boundary particles are constrained to move only along the
boundary surface. The free particles are iteratively converted to boundary
particles until no free particle is sufficiently close to the boundary.
During the initial projection phase (denoted by the red dashed line in
the fig. 2), the particles are regularly projected onto the boundary surface.
This is done until the number of boundary particles have reached Ns and
remains there for a few consecutive iterations. The algorithm then proceeds
to settle the particles into a uniform distribution until the displacement of
the particles is less than a user-defined tolerance. This is denoted as the
“Converged” block in fig. 2. Once convergence is attained, the boundary and
free particles inside and outside the surface are packed as desired. Since the
boundary surface is known, free particles can be easily identified as solid and
fluid particles.
This packed collection of free and boundary particles may be placed into a
larger regular mesh of particles for a simulation. For example, see fig. 3 where
the dashed region is where the packed particles could be placed. The exterior
of this region (shown in green) can be represented as a regular mesh of the
same spacing. This approach is convenient to use in the context of fluid flow
past solid bodies as done for internal flows [30] and free surface flows [31]. The
algorithm described above is explained in detail in the subsequent sections.

3.1.1. Initialization of boundary nodes


The boundary nodes which represents the boundary surface are first ini-
tialized. In a two-dimensional domain, a set of points are required which
discretize the boundary curve. The boundary curve may be parametrized

10
Inlet Outlet

Figure 3: The preprocessed patch (dashed) of particles placed in the appropriate location
of a typical simulation. The blue particles denote the free particles identified as fluid
particles, the red represents the solid particles identified by the packing process. The
green particles are generated from a fixed mesh of points.

by λ, and points on the curve may be specified as x = C(λ) and λ ∈ [0, 1].
This curve is discretized such that xi = C(λi ). The spacing between points
must be such that |xi+1 − xi ))| < ∆s. The boundary node coordinates are
initialized using these points. The outward normals nx , ny for any node i are
calculated using
 
yi+1 − yi yi − yi−1
nx,i = 0.5 +
di+1,i di,i−1
  (10)
xi+1 − xi xi − xi−1
ny,i = −0.5 +
di+1,i di,i−1

where di,j is the length of the segment joining node at (xi , yi ) and (xj , yj ).
The resulting normal is then normalized. The eq. (10) ensures that sharp
corners of the curve have smooth normals. For a three-dimensional case, a
triangulation of the surface with outward normals is necessary. The centroid
of each triangle and its normal is used to initialize the boundary nodes.
In SPH, the actual boundary surface is exactly in between solid and fluid
particles. Thus, both in two and three dimensions, given a particle spacing
of ∆s, the boundary nodes are shifted by ∆s/2 inside the actual boundary to

11
correctly implement the solid boundary conditions as discussed in Marrone
et al. [20]. In order to move the nodes inwards, the following translation is
performed on each boundary node given by,
∆s
x=x− n̂, (11)
2
where, x is the position of the node and n̂ is its unit normal pointing out-
wards. It must be noted that this is optional and one can provide a pre-shifted
surface and avoid eq. (11).

i+4 i+4

i+3 i+3
∆s/2
i+2
Corner-node i+2
i+4 i+4
i+3

i+2 i+1 i+1


i-1
i i i i
i-2 i+1
i-3 i-1 i-1
i-4 i-4
i-2 i-2

i-4 i-3 i-4 i-3

Figure 4: Shifting of the boundary near a sharp edged boundary. The boundary nodes
are depicted in red with normals. On the left is the boundary surface after the initial
shifting shown as black dashed lines. On the right is the final geometry after removal of
the intersecting edges which are shown as dashed red lines. The annular blue free particle
is the candidate to be placed on the corner and held fixed.

Care must be taken when there are sharp changes in the features of the
geometry. Consider an airfoil trailing edge in fig. 4 shown as a black line.
These sharp corners are marked as “corner nodes”, and in this case, it is the
ith node. When the nodes on this surface are shifted, the boundary surface
tends to self-intersect itself. This is shown by the red nodes connected using
a black dashed line. In order to remove the intersection of the boundary
surface near the corner node, the points i − 3 to i − 1 are replaced by the
points on the line joining i−4 and i with equal spacing shown by black points.
Similarly the points i + 1 to i + 3 are also replaced to lie along the line joining
points i and i + 4. This results in a non-intersecting surface as shown by the
red dashed line in the right side of fig. 4. Once the intersection is resolved,
the nearest free particle near the corner node (annular blue particle) is placed

12
on it and converted to a fixed boundary particle. The position of these fixed
boundary particles do not change in the entire simulation.
In the case of a three-dimensional object, one has to make sure that the
surface does not intersect after applying eq. (11) or use a pre-shifted surface
as an input.

3.1.2. Dynamics of the particles


In this section, the dynamics of particle regularization is discussed. Two
forces are applied on the particles and together these regularize the particle
distribution. The two forces are, a gradient due to particle disorder and a
pure inter-particle repulsive force.
In the presence of a constant pressure field, pb and no viscous effect, the
momentum equation (eq. (8)), becomes
du ∇(1 · pb ) pb ∇(1) + ∇(pb )
=− =− . (12)
dt ρ ρ
When the term, pb ∇(1), on the right hand side is discretized using the
SPH method, we obtain pb ∇Γ (see eq. (4)). This is non-zero when the parti-
cles are not uniform and hence particles exert a force on each other in order
to reach an equilibrium position. Using the SPH approximation, the above
equation is discretized as
dui X Vi Vj
ab,i = =− pb ∇Wij , (13)
dt j
m i

where Vi = mρii is the volume of the ith particle, ρi is the density, Wij is the
kernel function chosen for the SPH discretization. The summation is over
all the neighbors of ith particle. Since all SPH kernels satisfy eq. (5), any
suitable SPH kernel discussed in section 2 can be employed. In this paper,
the quintic spline kernel is used given by,
σ (3 − q)5 − 6(2 − q)5 + 15(1 − q)5
  
 for 0 ≤ q ≤ 1,
5 5

σ (3 − q) − 6(2 − q) for 1 < q ≤ 2,

W (q) = 5 (14)

 σ (3 − q) for 2 < q ≤ 3,

0 for q > 3,

where, σ = 1/(120h), 7/(478πh2 ), 1/(120πh3 ) in one, two and three-dimensions


respectively and q = |r|/h. In this algorithm, the value of pb is set to 1 in-
dependent of the resolution. In addition to this force, a repulsive force (RF)

13
similar to the gradient of the Lennard Jones potential (LJP) is used. The
new repulsion force potential (φRF ) is given by
 2 
c c
φRF = 12 kr − (15)
r3 r2

where kr is a constant. We set c = 2α∆s/3, where α is a scaling factor.


The gradient of eq. (15) gives us the force due to φRF . The force is kept
constant for r < ∆s/2 in order to avoid very large repulsion forces. The
SPH approximation of the acceleration due to eq. (15) can be written as
 P  2 
3c c

 j
 192 k e
r ij ∆s4 − ∆s3
rij ≤ ∆s/2
 2 
aRF,i = −∇φRF,i = P 3c 2c
4 − r3 ∆s/2 < rij ≤ α∆s (16)
 j 12 kr eij rij ij

0 rij > α∆s

where eij = xij /rij . Note that the acceleration is continuous at rij = ∆s/2.
We find that using a value of α = 0.95 works well for the algorithm.
It is clear from eq. (16) that this force is active only when particles come
closer than the desired particle spacing. This prevents particle pairing, which
may happen due to the use of some kernels like cubic spline for large time
steps [32]. In fig. 5, the comparison between the force due to LJP and RF is
shown. The LJP repulsion force increases rapidly compared to our suggested
repulsion force. This allows us to use a larger time step during integration.
Moreover, unlike the force due to LJP, the new force does not introduce
inter-particle attraction.
As discussed in [12], for stability, a damping force is used to reduce the
energy of the system. The acceleration due to damping for the ith particle is
given by
ad,i = −ζui (17)
where ζ is the damping constant and ui is the velocity of the ith . The value
of the damping constant ζ is discussed in section 3.1.6. Thus, the equation
governing the dynamics of the system is given by
du ∇pb
=− − ∇φRF − ζu (18)
dt ρ

The above equation can be converted into SPH form using eqs. (13), (16)
and (17). It must be noted that the combination of background pressure force

14
Figure 5: Force due to LJ potential and the gradient of eq. (15) as a function of distance,
r and α = 1.

and the repulsion force produces repulsion only when particles are disordered.
This can also be accomplished by using the particle shifting techniques (PST)
first proposed by [10].
On using eq. (18) the velocities and new positions are calculated using a
semi-implicit Euler integration given by,
ui (t + ∆t) = ui (t) + ∆tai (t)
(19)
ri (t + ∆t) = ri (t) + ∆t ui (t + ∆t)
In the case of boundary particles, the velocities are corrected to constrain
them to move along the surface (discussed in section 3.1.4). It should be
noted that the packing algorithm only ensures that particle distributions
are regular and therefore using a higher order integrator would not promise
better results.

15
The stability of the method in a two and three-dimensional domain for
finite perturbation under the action of forces described above is studied. A
domain of size 1 unit along each coordinate direction is considered. Particles
are placed with a spacing of ∆s = 0.05. Fixed particles are placed outside
this unit box suitably. The value of pb , ζ, kr and ∆t are set as discussed in
section 3.1.6. A single particle close to the center is perturbed by ∆s/2 in
each direction. The particles are moved using eq. (18) and eq. (19) for 15000
iterations. The stability of the following initial distribution of particles is
considered:

(a) Rectangular (b) Hexagonal

Figure 6: Different packing structures in 2D.

• hexagonal packing shown in fig. 6b with number density (N D) gradient.

• hexagonal packing shown in fig. 6b with N D + repulsion force (RF ).

• rectangular packing shown in fig. 6a with N D gradient.

• rectangular packing shown in fig. 6a with N D + RF .

The error in every iteration is evaluated using

L∞ (ρ − ρo ) = max({(ρi − ρo ), ∀i ∈ 1..N }) (20)

where N is the number of particles in the domain. In fig. 7a and fig. 7b


the L∞ (ρ − ρo ) is plotted with number of iterations for 2D and 3D domain
respectively with ρo = 1.0. It is evident from the figure that in 2D, all
the combinations perform well. In the case of the 3D domain, rectangular

16
lattices settle into an equilibrium configuration with a much larger density
difference. Therefore the rectangular lattice in 3D is an unstable equilibrium.
In contrast, the hexagonal packing in 3D is in a stable equilibrium.
This behavior in 3D can be understood from the total potential energy of
the particles. It can bePseen that eq. (3) for Γi is the potential energy of the
ith particle and hence i Γi is the total potential energy of the system. The
acceleration of a particle given in eq. (12) is the negative of the gradient of
its potential energy. We have numerically found that a small perturbation
of a particle at a given site reduces the total potential energy in the case
of the rectangular lattice whereas, the same perturbation results in higher
potential energy in the case of the hexagonal packing. This suggests that the
hexagonal packing is stable in 3D unlike the rectangular lattice. A careful
analysis on the stability is outside the scope of the present work. Due to the
stability of hexagonal packing shown in fig. 6b, it is used in all our test cases.

(a) 2D (b) 3D

Figure 7: Density convergence with a particle at center perturbed by ∆s/4.

3.1.3. Projecting free particles to the surface


Initially, the boundary particles are unlikely to conform to the bound-
ary surface. At t = 0 no particles are assigned as boundary particles. Free
particles are converted to boundary particles after every 50 iterations. This

17
Figure 8: Error in ∇Γi for domain with unit radius cylinder with different projection
frequency.

is called as the “projection frequency”. The projection frequency is a user-


defined parameter. Increasing this does not guarantee better results however
a very small value is not recommended. On running the proposed algorithm
with spacing ∆s = 0.1 around a unit radius 2D cylinder with varying pro-
jection frequency as shown in fig. 8, it was found that the after projection
frequency 20, the number density gradient do not change by a large value.
Thus, the value 50 is chosen heuristically.
If we consider a flat surface, an estimate for the number of particles that
can fill the surface is, Ns = As /∆s(d−1) where As is the area of the surface
and d is the dimension of the space in which the surface is embedded. In
order to perform projection, two different criteria are employed depending
upon whether the initial projection in fig. 2 is complete or not, as shown in
algorithm 1.
In the algorithm, the function FindParticlesNearBoundary finds all the
free particles that are less than a prescribed distance, maxdist, to a boundary
node. The distance is computed as follows, given a free particle p, we find
the boundary node b that is closest and compute the distance rpb · nb , where
rpb = rp −rb and nb is the normal at b. It is to be noted that the algorithm to

18
Algorithm 1: Pseudo-code for free particle projection.
Input: proj_freq, ds=∆s
Result: List of free particles to be projected
iteration = 0;
empty_count = 0;
while not converged do
...;
if iteration % proj_freq == 0 then
if empty_count < 4 then
p_list = FindParticlesNearBoundary(maxdist=0.5*ds);
if len(p_list) > 0 then
ConvertParticles();
empty_count = 0;
else
empty_count++;
end
else
p_list = FindParticlesNearBoundary(maxdist=0.65*ds);
ConvertParticles();
end
ProjectToBoundary();
...;
end
iteration++;
end

find the nearest boundary node uses the existing neighbors generated when
computing the accelerations discussed in section 3.1.2.
The empty_count variable stores the number of consecutive passes
for which the p_list was empty. The free particles having a distance
to the boundary node less than 0.5∆s are converted to boundary par-
ticles in ConvertParticles and projected to the boundary surface in
ProjectToBoundary. However, if the empty_count exceeds 3, the distance
threshold is increased to 0.65∆s. This threshold is increased to handle the

19
corner cases where free particle are just outside 0.5∆s distance1 . This iter-
ative conversion of free particles to boundary particles is necessary in order
to capture the surface accurately.

3.1.4. Kinematics of boundary particles

2 1

boundary node
3 ~u

4 boundary particle

5
Figure 9: Motion of boundary particle along the geometry.

As discussed earlier, the movement of the boundary particles are con-


strained along the boundary surface. Figure 9 illustrates the motion of a
boundary particle (in blue) along the geometry represented by nodes 1, 2, 3,
4, and 5. We note that even though the particle is a boundary particle, it is
only projected onto the surface every proj_freq time steps as discussed in
section 3.1.3 hence the boundary particle may not exactly lie on the boundary
as it moves.
The motion of the boundary particle is performed as follows. The bound-
ary node nearest to the boundary particles in the direction of the particle’s
velocity is identified. Consider a boundary particle p, and a boundary node
j, near p having position xp and xj respectively. The index of the nearest

1
This value was found based on numerical experiments. Too small a value like 0.55∆s
produces poor results in coarse resolutions and too large a value (0.75∆s) produced poor
distributions with finer resolutions.

20
node, J is determined by

J = arg min{rpj | j ∈ Np and xpj · up < 0} (21)


j

where, xpj = xp − xj , rpj = |xpj |, up is the velocity of the boundary particle


and Np is the set of neighboring nodes of p. In fig. 9, the node 2 satisfies the
conditions in eq. (21), and so J = 2. Using the nearest node index J, and the
boundary particle p, the direction of motion x̂r = −x̂pJ (where x̂ = x/|x|).
Thus, the boundary particle position is updated using the following equation

xm+1
p = xm m+1
p + (up · x̂m m
r )x̂r ∆t, (22)
where m is the time step.

3.1.5. Convergence criteria


For a perfectly packed distribution of particles, each particle should satisfy
the second condition in eq. (6) i.e. ∇ρi = 0. However, this would take a lot
of computational time. In case of geometries having irrational volumes like
the unit circle (V=π), one could never achieve a perfect convergence, given a
fixed resolution. Thus, similar to [24], the following criteria for convergence
is used
max(ui )∆t
< (23)
h
where,  = 10−4 is the tolerance for all our test cases, ui is the velocity
magnitude of ith particle, and the maximum is taken over all the particles.

3.1.6. Determining the constants and time-step


It is important to choose the parameters ζ and kr appropriately. It can be
seen that the eq. (13) scales as O(pb ∆s−1 ) and eq. (16) scales as O(kr ∆s−2 ).
By requiring that these forces be of the same order, it can be seen
kr
= C∆s (24)
pb
where C is an arbitrary constant. To find a suitable value, a 2D lattice of
points is considered. A single particle is perturbed by ∆s/4 in each direction.
A similar procedure is applied on a 3D lattice. A value of C in the range
0.004 − 0.006 was found in order to ensure that the two forces are of the same
order.

21
In order to ensure stability, the damping constant has a form similar to
the one suggested by Colagrossi et al. [12] given by ζ = Cζ /∆s, where Cζ is
set in the range 0.2 − 0.5 resulting in an underdamped system.
The time step, ∆t is set as in Adami et al. [11] given by,
h
∆tpb = 0.1
p
s b
h (25)
∆tζ = 0.1
ζui
∆t = min(∆tpb , ∆tζ )

where ui is the velocity magnitude of the ith particle. We note that we have
used a pb = 1 for all our simulations.

3.1.7. Separating interior and exterior particles


At the end of the simulation, both interior (particles inside the boundary
surface) and exterior particles (particles outside the boundary surface) are
uniformly distributed. The interior particles along with the boundary parti-
cles are extracted and used as solid particles, while the rest of the particles
are used as fluid particles. In order to detect interior and exterior particles,
this simple SPH based procedure is adopted:
Step 1: Find the nearest boundary node j to free particle i. Let the normal
at the point j be n̂j .
Step 2: If xij · n̂j > 0 then the particle i is outside, otherwise it is inside.
Step 3: Step 1 − 2 are performed for all particles near the boundary surface.
For particles that are not near the boundary surface, the neighbors
of the given particle are checked. If a neighbor is an exterior particle,
then it too is an exterior particle, otherwise, it is an interior particle.
This works because all particles near a boundary are already marked.
This process provides a simple method of identification of the interior and
exterior particles. It must be noted this is done after the packing procedure
is completed. This procedure takes much less computational time compared
to the packing procedure.

3.1.8. Implementation
The algorithm is implemented using the open-source package PySPH [25].
The pseudo-code of the proposed hybrid method is shown in algorithm 2. The

22
nearest neighbor particle search (NNPS) algorithm implemented in PySPH
[25] is not a part of the current algorithm.
The algorithm first reads the input using ReadInput and initialize the
particles in CreateParticles as discussed in section 3.1.1. The constants
and time step are set in SetConstantAndTimeStep. The first iteration starts
with UpdateNeighbors where the neighbor list for every particle is created.
This is followed by acceleration computation in ComputeAccelerations and
integration in IntegrateParticles as discussed in section 3.1.2 and sec-
tion 3.1.4. Nearest free particles are converted and projected to the surface in
ProjectParticles as discussed in section 3.1.3. This procedure updates the
empty_count variable. The iterations continues until convergence condition is
true in CheckConvergence as discussed in section 3.1.5. Finally, the particles
are separated into internal and external particles in SeparateParticles as
discussed in section 3.1.7.

Algorithm 2: Hybrid particle packing algorithm.


Result: Coordinates of solids and fluids
ReadInput();
CreateParticles();
SetConstantAndTimeStep();
p_freq = 50;
iteration = 0;
empty_count = 0;
converged = False;
while not converged do
UpdateNeighbors();
ComputeAccelerations();
IntegrateParticles();
if iteration % p_freq == 0 then
empty_count = ProjectParticles(empty_count);
if empty_count > 4 then
converged = CheckConvergence();
end
end
iteration++;
end
SeparateParticles();

23
3.1.9. Obtaining faster convergence
The algorithm discussed above is the basic form, which adds particles
slowly to the boundary. In case when the boundary surface is smooth and
does not have sharp changes (as discussed in section 3.1.1), the following
approaches can be taken to speed up the packing process:
• Using surface point prediction: When the boundary is smooth one may
project 0.9Ns immediately at the start. This perturbs the distribution
of the particles significantly. If required more particles are projected to
the boundary while settling the system to an equilibrium.
• Filter layers near the boundary surface: Conforming particles to the
boundary surface requires that only some of the particles be moved.
Thus, one could filter the free particles near the boundary surface and
freeze the other particles.
• Reduce projection frequency: One can reduce it slowly once the initial
projection is complete.
• Reduce the convergence tolerance: One can potentially reduce the toler-
ance to increase the performance of the algorithm, although this would
reduce the quality of the distribution of particles.
Doing these can potentially reduce the computations by up to a factor of
two. However, we have not performed any of these in the results presented
here.

3.2. Standard Packing


In this method, the interior of a 2D object is constructed by using the
method proposed by Marrone et al. [20]. The object boundary is represented
by a piecewise linear curve (PLC) with normals to the boundary pointing
out of the solid. The first layer of the interior is generated by moving the
PLC points into the body along the normal by ∆s/2 where ∆s is the particle
spacing. The new PLC is discretized into particles such that each particle is
approximately ∆s distance apart along the PLC. The newly added PLC is
moved further into the body along the normal by ∆s and discretized again.
This procedure is repeated until the desired number of layers of solid particles
are generated. It must be noted that this works only for 2D objects.
Once the dummy layers representing the solid body is created, fluid parti-
cles are placed around the solid particles. The method proposed by Colagrossi

24
et al. [12] is used to pack particles around the fixed solid particles. In order
to initialize the particle position, a grid of evenly distributed particles is con-
sidered and only the particles outside (defined by the direction of normal)
the boundary surface represented by the PLC are retained. The particles
are packed using the number density gradient. It must be noted that since
only the number density gradient is used as a repulsion force amongst the
particles, they are prone to clumping [33, 34]. The particles are subjected to
a damping force to dissipate the energy of the system. Hence the force on
any particle is governed by
du ∇pb
=− − ζu, (26)
dt ρ
The value of pb and ζ is set directly as described in section 3.1.6. The same
SPH discretization is used as done in equation eq. (13) and eq. (17). The
convergence criteria remain the same as discussed in section 3.1.5.

Algorithm 3: Standard particle packing algorithm.


Result: Coordinates of solids and fluids
ReadInput();
CreateParticles();
SetConstantAndTimeStep();
converged = False;
iteration = 0;
while not converged do
UpdateNeighbors();
ComputeAccelerations();
IntegrateParticles();
converged = CheckConvergence();
iteration++;
end

In algorithm 3 the standard packing is described in detail. The ReadInput


functions reads the points describing the geometry. All the particles are ini-
tialized and the dummy particles are created using method proposed by Mar-
rone et al. [20] in CreateParticles. The SetConstantAndTimeStep function
sets the constants and time step as discussed in section 3.1.6. The iteration
starts with creation of neighbor lists for every particle in UpdateNeighbors.

25
Then, accelerations are computed in ComputeAccelerations using eq. (26)
and integrated in IntegrateParticles using eq. (19). The iteration continues
until the criteria described in section 3.1.5 is satisfied in CheckConvergence.

3.3. Coupled packing


Jiang et al. [24] proposed a packing algorithm for solid objects both in
2D and 3D in order to sample blue noise. The steps involved are described
in algorithm 4. A repulsion force which is similar to the one used in [12] is
used along with damping. However a symmetric form of SPH discretization
is used given by
 
X 1 1
ab,i = −mi pb mj + 2 ∇i Wij , (27)
j
ρ2i ρj

where Wij is the cubic spline kernel function. This is computed in


ComputeAccelerations along with an additional force discussed later. In
the present implementation, a constant background pressure, pb is used. In
the original method pb = η(ρ − ρo ) where η is a constant. On computing the
acceleration, all the particles are integrated in IntegrateParticles.
Since the particles near the surface lack supporting particles, a large force
acts upon them. In order to keep the particles inside a confined region, the
particles nearer than 0.05∆s are converted to boundary particles. These
are integrated similarly as in the case of the hybrid method described in
section 3.1.2. The boundary particles are projected back to the surface in
every iteration in ProjectParticles as done in the original method.

Algorithm 4: Packing algorithm by Jiang et al. [24].


Input: particles, max_iter
Result: Packed particles
iteration = 0;
while not converged and iteration < max_iter do
UpdateNeighbors(particles);
ComputeAccelerations();
IntegrateParticles();
ProjectParticles();
iteration++;
end

26
If one were to only use eq. (27), it would result in more number of par-
ticles pushed towards the boundary. In order to counteract the force on the
particles near the boundary, Jiang et al. [24] used a cohesion force proposed
by Akinci et al. [35]. The acceleration due to this force in SPH form is given
by X
ac,i = −mi γ mj kij Cij n̂ij (28)
j

where kij = 2ρo /(ρi + ρj ), n̂ij = xij /rij and Cij is the spline kernel in [35]
given by 
(1 − q)3 q 3 0.5 < q < 1
32  3 3 1
C(q) = 2(1 − q) q − 64
0 < q < 0.5 (29)
πhd 
0 otherwise

Domain 1 External
Domain 2
boundary boundary

Domain 2
Domain 1 Interface
boundary

Figure 10: Schematic for the coupled packing algorithm. The external region is marked
as domain 2 and the internal region is marked as domain 1.

Jiang et al. [24] have not specified a way to choose the value of the con-
stants in eq. (27) and eq. (28). The values of γ = 20, pb = 10 and h = ∆s
are heuristically chosen for all the simulations.
It must be noted that there is no exterior defined in [24]. In this work,
the exterior is also packed in the same manner as the interior by moving the
boundary surface by ∆s/2 and −∆s/2 for exterior and interior respectively.
In fig. 10, the interior domain (domain 1) is enclosed within a thick dashed
line and the exterior is within a thin dashed line (domain 2). Each domain is
represented with a different pattern. Domain 2 having an external boundary
has frozen particles outside it. The solid line represents the boundary surface.

27
Algorithm 5: Coupled particle packing algorithm.
Result: Coordinates of solids and fluids
ReadInput();
DivideDomain();
CreateParticles();
SetConstantAndTimeStep();
Algorithm4(domain1, 5000);
Algorithm4(domain2, 5000);
iteration = 0;
converged = False;
while not converged do
UpdateNeighbors(domain1 + domain2);
ComputeAccelerations();
IntegrateParticles();
converged = CheckConvergence();
iteration++;
end
SeparateParticles();

The particles are packed in two different passes as described in algorithm


5. First, the geometry data is read in ReadInput followed by particle ini-
tialization in CreateParticles. The free particles are divided into domain 1
and domain 2 depending upon their location in DivideDomain. For particles
that are lying in between the two dashed boundaries of domain 1 and 2, the
following is done. If a particle is in the exterior region (outside the boundary
surface) it is moved along the normal by a distance ∆s into domain 2. Sim-
ilarly, particles between the boundary surface and the domain 1 boundary
are moved into domain 1.
In the first pass, domains 1 and 2 are solved separately using the algorithm
4. In this case, each domain is unaware of the other. The boundary particle
projection is performed onto the dashed lines of the respective boundaries.
The particles in both the domains are moved for a predetermined number of
iterations at which point the particles reach equilibrium2 . This ensures that

2
The predetermined iterations is chosen as 5000 currently based on the test cases
considered.

28
all particles are sorted as either interior or exterior and have an interface
which they cannot cross i.e. the dashed lines.
In the second pass, when the projection is complete, the particles on
the interior surface i.e. the thick dashed line are constrained to move
along it. All other particles are allowed to freely move using eq. (27) in
ComputeAccelerations and IntegrateParticles. The iteration continues un-
til the convergence criteria in CheckConvergence as discussed in section 3.1.5
is satisfied. The presence of exterior particles eliminates the need for the co-
hesion force and is not added once domains 1 and 2 start interacting. Using
this approach, a uniform distribution is obtained both inside and outside the
surface. It is noted that the original implementation was used to sample blue
noise and does not require external particles.
The proposed algorithms are implemented in the open-source SPH frame-
work, PySPH [25]. The present implementation is open source and freely
available with this manuscript at https://gitlab.com/pypr/sph_geom. All
the results shown in the next section are fully reproducible using a simple
automation framework [36].

4. Results and discussion


In this section, all the algorithms discussed above are compared. The al-
gorithms are first compared for a circular cylinder and a Z shaped wall in two
dimensions. The standard method is limited to two-dimensional domains.
Hence, in three-dimensions, only the coupled and the hybrid method are
compared for an ellipsoid. We also show the particle distribution for a sym-
metric airfoil and an arbitrarily shaped geometry using the hybrid method
at different resolutions. In the end, we demonstrate the hybrid algorithm for
a complex-shaped Stanford bunny.

4.1. Circular cylinder


The flow of an incompressible fluid past a cylinder is a well-known bench-
mark problem. In order to obtain a good comparative study, one desires to
remove the effect of the surface irregularities due to the underlying method
of geometry creation. In this test case, the circular cylinder constructed us-
ing all the approaches discussed in section 3 are compared. A cylinder of
diameter D = 2m is considered. In fig. 11, the geometry with particle spac-
ing ∆s = 0.1 made using different methods is shown. It is clear that the
hybrid method produces a uniform particle distribution. In the case of the

29
Figure 11: Solid (Red) and fluid (Blue) particles for a circular cylinder for ∆s = 0.1.

Figure 12: Density distribution of the packed particles for the circular cylinder geometry
for ∆s = 0.1.

30
(a) Function (b) Derivative

Figure 13: L2 error for SPH approximation of function and its derivative for the circular
cylinder geometry.

coupled method, a large number of particles near the wall surface is seen.
The standard method seems to have uniform particles owing to its construc-
tion. In order to investigate this further, the density distribution is plotted as
shown in fig. 12. The density distribution is obtained using the well-known
summation density. Clearly, the coupled method shows high density near
the surface and the standard method shows a low density on the solid since
∆s particle distance is assumed over a curved surface. The total density
variation is 8%, 16%, and 2% for the standard, coupled and hybrid meth-
ods respectively. Thus, it is clear that the proposed hybrid method shows
excellent distribution with a maximum variation of 2%.
The improvement is studied quantitatively by interpolating a C∞ function
over the packed particles given by

f (x, y, z) = sin(x2 + y 2 + z 2 ). (30)

The function and its derivative is approximated using


X mj
< f (x) >= f (xj )Wij (31)
j
ρj

31
and X mj
< fx (x) >= f (xj )Wij,x (32)
j
ρj
respectively. The L2 error in the approximation is evaluated using
qP
2
j (f (x) − fo (x))
L2 (f − fo ) = (33)
N
where, fo is the SPH function approximation on a regular mesh of points.
The value of the function is set as per the position of each particle as f (xi ).
This is then interpolated onto a regular mesh using eqs. (31) and (32). The
same is done for the regular points themselves to obtain the reference fo
value at each point. The value of h is varied in order to get convergence. A
value of h/∆s = 1.0 is taken for ∆s = 0.1 and linearly varied to h/∆s = 1.5
for ∆s = 0.02. The quintic spline kernel is used for the interpolation. When
comparing the derivatives, only the x derivative is considered. In fig. 13a and
fig. 13b, L2 (f − fo ) and L2 (f 0 − fo0 ) are shown. In these plots the errors near
the center of the cylinder are not evaluated as they do not affect the flow
and the standard method performs poorly in this region. This change allows
for a fair comparison. Hence, the L2 norm is evaluated only over the points
where r > 0.45 D. It is clear that the hybrid method shows a significant
order of magnitude improvement compared to both coupled and standard
methods. The coupled method is slightly better than the standard method.
The standard method shows large error due to the way in which the surface
is represented.

4.2. Zig-Zag Wall


The zig-zag wall is one of the test cases proposed by Marrone et al. [20]
used to demonstrate the δ-SPH method. They employ the standard packing
algorithm in order to generate a solid body and pack the fluid particles
around. In this test case, particles are packed using all the algorithms and
compared. The zig-zag wall is an excellent test case for packing since it has
both concave and convex sharp edges. In order to generate a solid using the
standard method, the corner nodes are moved along the angle bisector and
uniform points are generated using these points as endpoints. In the other
algorithms, these sharp points are referred as corner nodes and the method
discussed in section 3.1.2 is employed to automatically restrict the motion of
these points.

32
Figure 14: Solids (Red) and fluids (Blue) for the zig-zag wall for ∆s = 0.05.

Figure 15: Density distribution for the zig-zag wall for ∆s = 0.05.

In fig. 14, the solid and fluid particles packed with ∆s = 0.05 using
different algorithms are shown. It is difficult to conclude which of these is
better. However on looking at the density distribution computed using the
summation density as shown in fig. 15 one can clearly see that the proposed
method has much less deviation from the desired density. In the case of
the coupled method, higher density is observed at the concave corner. This
occurs since the particles from both sides push towards the interface at the
first pass of the coupled algorithm as discussed in section 3.3. The standard
method shows an uneven variation of density near the sharp edges which is
not desirable. The total density variation is 10%, 30% and 3% for standard,
coupled and hybrid methods respectively. It clearly shows that the hybrid

33
(a) Function Approximation (b) Derivative Approximation

Figure 16: L2 error for SPH approximation of function and its derivative for the zig-zag
wall.

method shows very small density variations compared to other methods.


A similar analysis over the zig-zag wall is performed as done in the case
of the cylinder. In order to remove the effect of the interior of the solid in
the standard case, the errors are computed only up to a distance of ∆s inside
the wall. In fig. 16a and fig. 16b, L2 norm for the error in function and its
derivative SPH approximation is plotted respectively. Clearly, the proposed
method performs very well as compared with the other methods.

4.3. Packing at different resolutions


In this example, the hybrid algorithm is applied on an arbitrary shaped
body. The packing at different particle spacings are shown in fig. 17. The
particle spacings chosen are 0.05, 0.075, and 0.1. The particles are placed at
∆x/2 distance away from the boundary. Clearly, the density distribution is
close to the desired value of 1.0. The particles conform to the body surface
and has a total variation of density of 2.5%, 2% and 3% for particle spacing
0.1 and 0.075 and 0.05 respectively. This shows that the proposed algorithm
is applicable to complex two-dimensional geometries.

34
Figure 17: Density distribution at different resolutions for an arbitrary shaped object.

4.4. Effect of convergence tolerance on the quality


In this test case, we show that the proposed algorithm can achieve a
high-quality particle distribution for a given tolerance. A symmetric airfoil,
NACA0015 is considered. The end-point at the trailing edge is chosen as a
corner node. Particle packing is performed using the proposed hybrid method
for the spacing ∆s = 0.02.
In table 1, the number of iterations required for convergence and the L∞
error in the density for different values of the tolerance required for conver-
gence are tabulated. It is evident from the table that the L∞ error decreases
with the decrease in the tolerance however, the number of iteration required
increases significantly. In the fig. 18, we show the high-quality particle dis-
tribution achieved using a lower value of tolerance,  = 2.5 × 10−5 in the
convergence criteria. It shows that the proposed method can achieve a high-
quality particle distribution provided a sufficiently low tolerance is used.

35
Tolerance Iterations L∞ (ρi )
2.5e-05 19641 0.011
5.0e-05 6291 0.019
1.0e-04 1191 0.028

Table 1: The table shows the effect of the change in tolerance for convergence on the
number of iterations and the L∞ error in the density.

Figure 18: The density distribution for a symmetric airfoil with particle spacing, ∆s = 0.02
and convergence tolerance,  = 2.5e−5 .

4.5. Particle Packing in 3D


One of the advantages of the proposed algorithm is that it can be easily
extended to a three-dimensional object unlike the standard method. In order
to compare the packing in 3D, particles are packed for a simple ellipsoid. The
ellipsoid has semi-major axis dimensions, a = 1.0, b = 0.5 and z = 0.75 along
x, y and z axis respectively. In fig. 19a and fig. 19b, the packed particles
over the surface of the sphere for hybrid and coupled method are shown
respectively. The color of the particles show the density distribution. In
order to show that the particles conform to the surface, the surface is pulled
along the normal by ∆s/2. It is clear that the hybrid method attains a good
distribution of particles resulting in a density distribution very close to ρo =
1.0. The particle distribution using the coupled method has density near the

36
(a) Hybrid (b) Coupled

Figure 19: Density distribution on the surface of the ellipsoid for ∆s = 0.1.

(a) Function approximation (b) Derivative approximation

Figure 20: L2 error for SPH approximation of function and its derivative for the ellipsoid.

lower range of the scale. This is due to the fact that unlike the hybrid method,
the coupled method does not project the required number of particles on the
surface. In order to perform a quantitative analysis, again the comparison of
the function and derivative approximation used earlier is adopted. In fig. 20a
and fig. 20b, L2 error in SPH approximation of function and its derivative is
plotted respectively. As can be seen, the proposed method produces much

37
lower errors at lower resolutions.

Figure 21: Different views showing particles (colored with density values) over the Stanford
bunny.

In order to show the capability of the algorithm, the proposed algorithm


is also applied to the Stanford bunny geometry, as done by Jiang et al.
[24]. The geometry surface required must have outward normals, and the
mesh is corrected using a mesh manipulation tool. A particle spacing of
0.02 is chosen. In this case, the intention is to show how well the geometry
is captured, so the surface is not shifted inside. In fig. 19b, the particle
distribution over the surface of the bunny is shown. The results show the
applicability of the proposed algorithm to arbitrary shaped 3D objects. After
pre-processing the 3D object can be placed anywhere in the domain, with
the surrounding particles.

38
5. Conclusions
This paper proposes an improved particle packing algorithm for the sim-
ulation of flows involving complex geometries in two and three dimensions.
Three different methods for packing particles around an arbitrary shaped ob-
ject are implemented and compared. The standard method which is proposed
by Colagrossi et al. [12] along with the solid object construction proposed
by Marrone et al. [20]. A modified version of that proposed by Jiang et al.
[24] which handles both the interior and exterior of the body. A new method
that combines the best features of these methods is proposed. The proposed
method provides an excellent density distribution as a result of evenly dis-
tributed particles. The method is applicable to both 2D and 3D domains.
Unlike the coupled method, no estimation of particles inside and outside is
required. Several benchmark cases are shown which highlight the accuracy
of the proposed algorithm in two and three dimensions. An open-source
implementation of the manuscript is provided and the manuscript is fully
reproducible.
The SPH method is being applied to a wide variety of problem domains
involving complex geometries. While mesh-free particle methods do not re-
quire a mesh, one must still capture the boundaries accurately. However,
there are not many tools to create good quality initial particle distributions.
This is necessary for accurate simulation of incompressible fluid flows with
the SPH. The proposed method is largely automatic and offers researchers
the ability to easily discretize complex geometries using particles in two and
three dimensions. Since the proposed algorithm is based on the SPH, it
should be easy to incorporate into an SPH solver. The code is also open
source and hence researchers could also choose to use our implementation.
In the future, we would like to make it easier to use and integrate with
the main PySPH package. We have only demonstrated our implementation
on the CPU. However, PySPH supports execution on a GPU and we propose
to make the necessary modifications for efficient execution on the GPU. The
method currently works best for a fixed resolution. In the future it would be
useful to explore this in the context of adaptive resolution.

39
References
References
1. Gingold, R.A., Monaghan, J.J.. Smoothed particle hydrodynam-
ics: Theory and application to non-spherical stars. Monthly Notices of
the Royal Astronomical Society 1977;181:375–389. doi:10.1093/mnras/
181.3.375.

2. Lucy, L.B.. A numerical approach to testing the fission hypothesis. The


Astronomical Journal 1977;82(12):1013–1024. doi:10.1086/112164.

3. Liu, M.B., Liu, G.R.. Smoothed Particle Hydrodynamics (SPH): an


Overview and Recent Developments. Archives of Computational Meth-
ods in Engineering 2010;17(1):25–76. URL: http://link.springer.
com/10.1007/s11831-010-9040-7. doi:10.1007/s11831-010-9040-7.

4. Violeau, D.. Fluid mechanics and the SPH method: theory and ap-
plications. 1st ed ed.; Oxford University Press; 2012. ISBN 978-0-19-
965552-6. OCLC: ocn776772541.

5. Ye, T., Pan, D., Huang, C., Liu, M.. Smoothed particle hydrodynam-
ics (SPH) for complex fluid flows: Recent developments in methodology
and applications. Physics of Fluids 2019;31(1):011301.

6. Monaghan, J.J.. Smoothed Particle Hydrodynamics. Reports on


Progress in Physics 2005;68:1703–1759.

7. Basa, M., Quinlan, N.J., Lastiwka, M.. Robustness and accuracy of


SPH formulations for viscous flow. International Journal for Numerical
Methods in Fluids 2009;60:1127–1148.

8. Kiara, A., Hendrickson, K., Yue, D.K.. SPH for incompressible free-
surface flows. Part I: Error analysis of the basic assumptions. Computers
& Fluids 2013;86:611–624. URL: https://linkinghub.elsevier.com/
retrieve/pii/S0045793013002181. doi:10.1016/j.compfluid.2013.
05.023.

9. Lind, S., Xu, R., Stansby, P., Rogers, B.. Incompressible smoothed
particle hydrodynamics for free-surface flows: A generalised diffusion-
based algorithm for stability and validations for impulsive flows and

40
propagating waves. Journal of Computational Physics 2012;231(4):1499
– 1523. doi:10.1016/j.jcp.2011.10.027.

10. Xu, R., Stansby, P., Laurence, D.. Accuracy and stability in in-
compressible SPH (ISPH) based on the projection method and a new
approach. Journal of computational Physics 2009;228(18):6703–6725.
doi:https://doi.org/10.1016/j.jcp.2009.05.032.

11. Adami, S., Hu, X., Adams, N.. A transport-velocity formulation for
smoothed particle hydrodynamics. Journal of Computational Physics
2013;241:292–307. doi:10.1016/j.jcp.2013.01.043.

12. Colagrossi, A., Bouscasse, B., Antuono, M., Marrone, S.. Parti-
cle packing algorithm for SPH schemes. Computer Physics Communi-
cations 2012;183(8):1641–1653. doi:https://doi.org/10.1016/j.cpc.
2012.02.032.

13. Litvinov, S., Hu, X., Adams, N.. Towards consistence


and convergence of conservative SPH approximations. Jour-
nal of Computational Physics 2015;301:394–401. URL: https:
//linkinghub.elsevier.com/retrieve/pii/S0021999115005690.
doi:10.1016/j.jcp.2015.08.041.

14. Dilts, G.A.. Moving-least-squares-particle hydrodynamics I: Consis-


tency and stability. International Journal for Numerical Methods in
Engineering 1999;44(8):1115–1155.

15. Dilts, G.A.. Moving least-squares particle hydrodynamics II: conser-


vation and boundaries. International Journal for numerical methods in
engineering 2000;48(10):1503–1524.

16. Bonet, J., Lok, T.S.. Variational and momentum preservation aspects
of smooth particle hydrodynamic formulations. Computer Methods in
Applied Mechanics and Engineering 1999;180(1):97 – 115. doi:10.1016/
S0045-7825(99)00051-1.

17. Frontiere, N., Raskin, C.D., Owen, J.M.. CRKSPH - a conservative


reproducing kernel smoothed particle hydrodynamics scheme. Journal
of Computational Physics 2017;332(1):160–209. doi:10.1016/j.jcp.
2016.12.004.

41
18. Eitzlmayr, A., Koscher, G., Khinast, J.. A novel method for mod-
eling of complex wall geometries in smoothed particle hydrodynamics.
Computer physics communications 2014;185(10):2436–2448.
19. Chiron, L., De Leffe, M., Oger, G., Le Touzé, D.. Fast and accurate
SPH modelling of 3d complex wall boundaries in viscous and non viscous
flows. Computer Physics Communications 2019;234:93–111.
20. Marrone, S., Antuono, M., Colagrossi, A., Colicchio, G., Le Touzé, D.,
Graziani, G.. δ-SPH model for simulating violent impact flows. Com-
puter Methods in Applied Mechanics and Engineering 2011;200:1526–
1542. doi:10.1016/j.cma.2010.12.016.
21. Xiao, Y., Dong, H., Zhan, H., Gu, Y.. A new particle generation
method for arbitrary 2D geometries in SPH modeling. International
Journal of Computational Methods 2017;14(03):1750023. doi:https://
doi.org/10.1142/S0219876217500232.
22. Domı́nguez, J., Crespo, A., Barreiro, A., Gómez-Gesteira, M.,
Mayrhofer, A.. Development of a new pre-processing tool for SPH mod-
els with complex geometries. In: 6th International SPHERIC workshop.
2011:117–124.
23. Akinci, N., Cornelis, J., Akinci, G., Teschner, M.. Coupling elastic
solids with smoothed particle hydrodynamics fluids. Computer Anima-
tion and Virtual Worlds 2013;24(3-4):195–203. doi:https://doi.org/
10.1002/cav.1499.
24. Jiang, M., Zhou, Y., Wang, R., Southern, R., Zhang, J.J.. Blue noise
sampling using an SPH-based method. ACM Transactions on Graph-
ics (TOG) 2015;34(6):1–11. doi:https://doi.org/10.1145/2816795.
2818102.
25. Ramachandran, P., Puri, K., Bhosale, A., Dinesh, A., Muta, A., Negi,
P., Govind, R., Sanka, S., Pandey, P., Kaushik, C., et al. PySPH: a
Python-based framework for smoothed particle hydrodynamics. arXiv
preprint arXiv:190904504 2019;URL: https://arxiv.org/abs/1909.
04504.
26. Ramachandran, P.. PySPH: a reproducible and high-performance
framework for smoothed particle hydrodynamics. In: Benthall, S.,

42
Rostrup, S., eds. Proceedings of the 15th Python in Science Conference.
2016:127 – 135.

27. Monaghan, J.J.. Simulating free surface flows with SPH. Journal of
Computational Physics 1994;110:399–406.

28. Wendland, H.. Piecewise polynomial, positive definite and compactly


supported radial functions of minimal degree. Advances in computational
Mathematics 1995;4(1):389–396.

29. Adami, S., Hu, X., Adams, N.. A generalized wall boundary condition
for smoothed particle hydrodynamics. Journal of Computational Physics
2012;231(21):7057–7075. doi:10.1016/j.jcp.2012.05.005.

30. Negi, P., Ramachandran, P., Haftu, A.. An improved non-


reflecting outlet boundary condition for weakly-compressible SPH. Com-
puter Methods in Applied Mechanics and Engineering 2020;367:113119.
doi:https://doi.org/10.1016/j.cma.2020.113119.

31. Tafuni, A., Domı́nguez, J., Vacondio, R., Crespo, A.J.C.. A ver-
satile algorithm for the treatment of of open boundary conditions in
smoothed particle hydrodynamics GPU models. Computer methods in
applied mechanical engineering 2018;342:604–624. doi:10.1016/j.cma.
2018.08.004.

32. Dehnen, W., Aly, H.. Improving convergence in smoothed particle


hydrodynamics simulations without pairing instability. Monthly Notices
of the Royal Astronomical Society 2012;425(2):1068–1082. doi:10.1111/
j.1365-2966.2012.21439.x.

33. Swegle, J., Hicks, D., Attaway, S.. Smoothed particle hydrodynamics
stability analysis. Journal of computational physics 1995;116(1):123–
134. doi:https://doi.org/10.1006/jcph.1995.1010.

34. Morris, J.P.. A study of the stability properties of sph.


arXiv preprint astro-ph/9503124 1995;URL: https://arxiv.org/abs/
astro-ph/9503124.

35. Akinci, N., Akinci, G., Teschner, M.. Versatile surface tension
and adhesion for SPH fluids. ACM Transactions on Graphics (TOG)
2013;32(6):1–8. doi:https://doi.org/10.1145/2508363.2508395.

43
36. Ramachandran, P.. automan: A python-based automation frame-
work for numerical computing. Computing in Science & Engineering
2018;20(5):81–97. doi:10.1109/MCSE.2018.05329818.

44

You might also like