Original software publication| Volume 14, 100376, November 01, 2022

# PolyMPS—An open source CFD solver based on Polygon walls in Moving Particle Semi-implicit (MPS) method

Open AccessPublished:July 14, 2022

## Highlights

• A C++ code for solving free-surface flow phenomena using the mesh-less moving particle semi-implicit (MPS) method.
• The MPS code includes weakly-compressible and incompressible flow approaches.
• Solid boundary walls can be modeled by particle or polygon walls.
• Efficient parallelization using the shared memory OpenMP API.

## Abstract

PolyMPS is a C++ code for numerical modeling of free-surface flow using the mesh-less moving particle semi-implicit (MPS) method from two different ways, namely, the incompressible and weakly-compressible approaches. Besides the conventional solid wall boundaries represented by discrete layers of wall and dummy (ghost) particles, boundary walls can be modeled by polygonal mesh of triangles, therefore providing flexibility to model the surface of three-dimensional complex-shaped bodies. The present code has a lightweight and efficient CPU implementation using OpenMP for research and practical applications, while providing reliable results.

## Keywords

Tabled 1
 Current code version 1.0 Permanent link to code/repository used for this code version https://github.com/SoftwareImpacts/SIMPAC-2022-96 Permanent link to Reproducible Capsule https://codeocean.com/capsule/5706048/tree/v1 Legal Code License MIT License Code versioning system used git Software code languages, tools, and services used C++, OpenMP Compilation requirements, operating environments & dependencies C++11, Eigen, libigl, JSON for Modern C++ If available Link to developer documentation/manual Support email for questions [email protected]

## 1. Introduction

Many numerical methods have been proposed in the context of computational fluid dynamics (CFD) to predict the hydrodynamic flow behavior in hydraulic, coastal, marine, and offshore problems, and grid or mesh-based methods, such as finite difference (FD), finite volume (FV) and finite element (FE), are generally applied for such problems. However, these methods suffer from some limitations, especially for free-surface flow problems characterized by large boundary deformations, fragmentation, merging, or moving interface, and numerical treatments like free surface tracking or re-meshing techniques are required, which increase the computational complexity. Due the easy implementation and flexibility, the mesh-less particle-based methods [
• Li S.
• Liu W.K.
Meshfree particle methods.
,
• Liu M.
• Liu G.-R.
Particle Methods for Multi-Scale and Multi-Physics.
] provide new perspectives for the modeling of free-surface flow. In these methods, all the physical domain is represented by a set of nodal points (particles), without additional mesh constraints.
In general, particle-based methods applied to free-surface flows can be categorized into two groups: weakly-compressible and incompressible projection-based methods [
• Luo M.
• Khayyer A.
• Lin P.
Particle methods in ocean and coastal engineering.
]. The former such as smoothed particle hydrodynamics (SPH) [
• Gingold R.A.
• Monaghan J.J.
Smoothed particle hydrodynamics: theory and application to non-spherical stars.
,
• Lucy L.B.
A numerical approach to the testing of the fission hypothesis.
] or weakly-compressible moving particle semi-implicit (WC-MPS) [
• Shakibaeinia A.
• Jin Y.-C.
A weakly compressible MPS method for modeling of open-boundary free-surface flow.
] methods solve an appropriate equation of state in a fully explicit form. The latter such as moving particle semi-implicit (MPS) [
• Koshizuka S.
• Oka Y.
Moving-particle semi-implicit method for fragmentation of incompressible fluid.
] or incompressible smoothed particle hydrodynamics (ISPH) [
• Cummins S.J.
• Rudman M.
An SPH projection method.
,
• Lo E.Y.
• Shao S.
Simulation of near-shore solitary wave mechanics by an incompressible SPH method.
] methods solve a pressure Poisson equation (PPE) through an application of the projection method [
• Harlow F.H.
• Welch J.E.
Numerical calculation of time-dependent viscous incompressible flow of fluid with free surface.
,
• Chorin A.J.
The numerical solution of the Navier-Stokes equations for an incompressible fluid.
,
• Temam R.
Sur l’approximation de la solution des équations de Navier-Stokes par la méthode des pas fractionnaires (II).
]. The incompressible projection-based methods are generally expected to provide higher accuracy in terms of hydrodynamic pressure calculation and volume conservation. On the other hand, the explicit weakly-compressible particle methods can be more simply parallelized on graphics processing units (GPUs), a cheap and portable alternative to large and expensive high-performance computing (HPC) clusters. Moreover, changes and new formulations are generally easier implemented on weakly-compressible codes.
In the conventional codes of particle-based methods, wall boundaries are modeled by discrete layers of wall particles. However, from a practical point of view, polygon wall models are more flexible to model the surface of three-dimensional (3D) arbitrary complex-shaped bodies than conventional particle-based representation.
In light of the above, PolyMPS is a lightweight and flexible code for research and practical 3D free-surface flow applications using the mesh-less moving particle semi-implicit (MPS) method with the incompressible and weakly-compressible approaches. Furthermore, solid walls can be modeled by polygonal mesh of triangles or represented by discrete layers of wall and dummy (ghost) particles.

## 2. Description

The moving particle semi-implicit (MPS) method was originally proposed for modeling incompressible free-surface flows [
• Koshizuka S.
• Oka Y.
Moving-particle semi-implicit method for fragmentation of incompressible fluid.
]. The MPS represents the continuum with a set of mobile particles (without any connectivity) over which the flow governing equations are solved. The particles containing a set of continuum material properties, interact with each other within a range (compact support) controlled by a weight function (also referred to as kernel function), and move in a Lagrangian system according to the particle interactions and external forces. Fluid particles move in a natural way so that free surface, fluid–fluid interfaces or moving boundaries do not need to be explicitly tracked. Moreover, as a mesh-less method, MPS can effectively avoid the mesh tangling and consequently re-meshing process is not required. In this way, MPS is very effective for the simulations of flows involving large deformation of free surfaces, fragmentation, and merging, or involving complex shaped multi-bodies, multi-phase flows, and multi-physic problems.
The pressure is typically computed using incompressible or weakly-compressible approaches. A predictor–corrector semi-implicit algorithm was originally adopted for the temporal integration of the governing equations in the incompressible MPS. Moreover, a linear pressure Poisson equation (PPE) system, formulated to keep the particle number density as a constraint condition of incompressibility, is solved to obtain the pressures [
• Koshizuka S.
• Oka Y.
Moving-particle semi-implicit method for fragmentation of incompressible fluid.
]. On the other hand, a fully explicit algorithm is adopted in the weakly-compressible approach, and the incompressibility is weakly enforced by particle number density deviation, which provides the pressure of the particles computed by an equation of state (EOS) [
• Shakibaeinia A.
• Jin Y.-C.
A weakly compressible MPS method for modeling of open-boundary free-surface flow.
].
PolyMPS stands for Polygon walls in Moving Particle Semi-implicit method. The numerical algorithms for the modeling of the fluid dynamics equations are based on weakly-compressible [
• Shakibaeinia A.
• Jin Y.-C.
A weakly compressible MPS method for modeling of open-boundary free-surface flow.
,
• Oochi M.
,
• Amaro Junior R.A.
• Gay Neto A.
• Cheng L.-Y.
Three-dimensional weakly compressible moving particle simulation coupled with geometrically nonlinear shell for hydro-elastic free-surface flows.
] and incompressible [
• Koshizuka S.
• Oka Y.
Moving-particle semi-implicit method for fragmentation of incompressible fluid.
,
• Tanaka M.
• Masunaga T.
Stabilization and smoothing of pressure in MPS method by quasi-compressibility.
,
• Cheng L.-Y.
• Junior R.A.A.
• Favero E.H.
Improving stability of moving particle semi-implicit method by source terms based on time-scale correction of particle-level impulses.
] MPS formulations. In addition to the particle-based wall modeling, solid boundaries can be represented by a triangulated surface using the explicitly represented polygon (ERP) wall boundary model [
• Mitsume N.
• Yoshimura S.
• Murotani K.
Explicitly represented polygon wall boundary model for the explicit MPS method.
] with free and no-slip boundary conditions. The detection of free-surface particles can be done by: PND + number of neighbors conditions [
• Lee B.-H.
• Park J.-C.
• Kim M.-H.
• Hwang S.-C.
Step-by-step improvement of MPS method in simulating violent free-surface motions and impact-loads.
], the neighborhood particles centroid deviation (NCPD) technique [
• Tsukamoto M.M.
• Cheng L.-Y.
• Motezuki F.K.
Fluid interface detection technique based on neighborhood particles centroid deviation (NPCD) for particle methods.
] or a scanning region [
• Tamai T.
• Koshizuka S.
Least squares moving particle semi-implicit method.
]. To improve the numerical stabilization, particle shifting [
• Lind S.J.
• Xu R.
• Stansby P.K.
• Rogers B.D.
Incompressible smoothed particle hydrodynamics for free-surface flows: A generalised diffusion-based algorithm for stability and validations for impulsive flows and propagating waves.
,
• Xu T.
• Jin Y.-C.
Improvements for accuracy and stability in a weakly-compressible particle method.
] and particle collision [
• Lee B.-H.
• Park J.-C.
• Kim M.-H.
• Hwang S.-C.
Step-by-step improvement of MPS method in simulating violent free-surface motions and impact-loads.
,
• Jandaghian M.
• Krimi A.
• Shakibaeinia A.
Enhanced weakly-compressible MPS method for immersed granular flows.
] models can be adopted. Furthermore, in PolyMPS it is possible to impose periodic boundary conditions in X, Y or Z axis.
In order to achieve a better performance over interpreted languages, PolyMPS is an framework implemented in the compiled language C++. Moreover, to minimize hard dependencies on external libraries during the code compilation, only header-only libraries, namely, Eigen, libigl, and JSON for Modern C++, are required, i.e., there is no need to compile these libraries separately. PolyMPS supports parallelization with hardware using the shared memory OpenMP approach.
A set of C++ source files need to be compiled to generate the PolyMPS binary. We provide a Makefile that can be used to compile the code, and that the user can modify to suit his needs. The source files have comments describing the MPS formulations and the algorithms.
Fig. 1 illustrates the workflow to carry out a computational fluid analysis with PolyMPS.
The input files used in PolyMPS are of three types: JSON, GRID and STL. The JSON (JavaScript Object Notation) is a textual data format that is completely language independent and can easily be read or written using any standard text editor. The JSON file contains all the names of files and folders, as well as the physical and numerical parameters of the simulation case. The GRID file has a structure like XYZ files with initial coordinates of the particles and numerical and physical parameters, such as material id, initial velocity and initial pressure. The STL file contains information of the unit normal and vertices of the triangles which approximate the solid walls by a unstructured triangulated surface. The user should specify these files according to the initial conditions of the problem.
The output consist of PVD and VTU files, both XML-based format. The PVD (ParaView Data) provides pointers to the collection of VTU files. The VTU files store the physical values numerically obtained for the particles at different instants of the simulation: output00000.vtu, output00001.vtu, output00002.vtu, $…$. These files can be loaded in the scientific visualization software ParaView.

## 3. Impact overview

Motivated by the challenging coupling between mesh-less particle-based along with mesh-based methods, and practical hydraulic and geotechnical engineering problems, PolyMPS has been used in several works [
• Amaro Junior R.A.
• Gay Neto A.
• Cheng L.-Y.
Three-dimensional weakly compressible moving particle simulation coupled with geometrically nonlinear shell for hydro-elastic free-surface flows.
,
• Pereira L.S.
• Amaro Junior R.
• Cheng L.-Y.
The influence of wall boundary modeling on the unphysical frictional loss inside horizontal main drain.
,

R. Amaro, L. Pereira, L. Cheng, A. Shakibaeinia, Polygon Wall Boundary Model in Particle-Based Method: Application to Brumadinho Tailings Dam Failure, in: 25th ABCM International Congress of Mechanical Engineering, 2019, p. 10.

]. Aiming to illustrate the applicability of PolyMPS, numerical simulations obtained from a variety of physical phenomena are shown in Fig. 2. In the first example, a front wave impacts on the downstream wall and generates a vertical run-up jet. In the second one, after the collapsing column of the fluid, the periodic open boundaries at the lateral limits allow the wavefront encounter that resulting in a vertical jet. Finally, the third example shows a flooded area due to a tailings dam collapse.
To the best of our knowledge, there is no available a free MPS code that includes weakly-compressible and incompressible flows, as well as particle and polygon walls. In this way, PolyMPS has high potential to be used by the broad scientific community of fluid mechanics.

## 4. Future improvements of the software

As next steps and future improvements, we can mention:
• Extension of the code to modeling non-Newtonian fluids [
• Jandaghian M.
• Krimi A.
• Shakibaeinia A.
Enhanced weakly-compressible MPS method for immersed granular flows.
].
• Coupling with open-source FE solver, then providing a free numerical platform to simulate highly non-linear hydro-elastic problems.
• Implementation of parallel solver by using a massively parallel code [
• Fernandes D.T.
• Cheng L.-Y.
• Favero E.H.
• Nishimoto K.
A domain decomposition strategy for hybrid parallelization of moving particle semi-implicit (MPS) method for computer cluster.
] and many-core combined with GPU architectures [
• Gou W.
• Zhang S.
• Zheng Y.
Implementation of the moving particle semi-implicit method for free-surface flows on GPU clusters.
], capable of handling practical large-scale problems.
• Boundary walls represented by a scalar field with discrete signed distance functions (SDF) [

D. Koschier, J. Bender, Density maps for improved SPH boundary handling, in: Proceedings of the ACM SIGGRAPH/Eurographics Symposium on Computer Animation, 2017, pp. 1–10.

], aiming to improve the efficiency in calculate the distances between the particles and mesh.
• Accuracy improvement of the polygon wall formalism by adopting numerical boundary integrations [
• 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.
], semi-analytical boundary integrations [
• Kostorz W.
• Esmail-Yakas A.
Semi-analytical smoothed-particle hydrodynamics correction factors for polynomial kernels and piecewise-planar boundaries.
] or analytical volume integrations [
• Matsunaga T.
• Yuhashi N.
• Shibata K.
• Koshizuka S.
A wall boundary treatment using analytical volume integrations in a particle method.
].
• Inclusion of multi-resolution techniques (see Table 1 in [
• Bellezi C.A.
• Cheng L.-Y.
• Amaro Jr. R.A.
• Tsukamoto M.M.
Border mapping multi-resolution (BMMR) technique for incompressible projection-based particle methods.
]) should also be evaluated with respect to adaptivity and versatility of our code.

## CRediT authorship contribution statement

Rubens Augusto Amaro Junior: Conceptualization, Methodology, Software, Validation, Formal analysis, Writing – original draft, Visualization. Liang-Yee Cheng: Conceptualization, Methodology, Writing – review & editing, Supervision, Funding acquisition.

## Declaration of Competing Interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

## Acknowledgments

The authors would like to thank the Coordenação de Aperfeiçoamento de Pessoal de Nível Superior - Brasil (CAPES) - Finance Code 001. We are grateful to Seiichi Koshizuka, Kazuya Shibata, Masahiro Kondo and Takuya Matsunaga for providing, together with their MPS Book [
• Koshizuka S.
• Shibata K.
• Kondo M.
• Matsunaga T.
Moving particle semi-implicit method: a meshfree particle method for fluid dynamics.
], a basic MPS code upon which the current improvements and several features were implemented.

## References

• Li S.
• Liu W.K.
Meshfree particle methods.
Springer Science & Business Media, 2007
• Liu M.
• Liu G.-R.
Particle Methods for Multi-Scale and Multi-Physics.
World Scientific, 2015
• Luo M.
• Khayyer A.
• Lin P.
Particle methods in ocean and coastal engineering.
Appl. Ocean Res. 2021; 114102734
• Gingold R.A.
• Monaghan J.J.
Smoothed particle hydrodynamics: theory and application to non-spherical stars.
Mon. Not. R. Astron. Soc. 1977; 181: 375-389
• Lucy L.B.
A numerical approach to the testing of the fission hypothesis.
Astron. J. 1977; 82: 1013-1024
• Shakibaeinia A.
• Jin Y.-C.
A weakly compressible MPS method for modeling of open-boundary free-surface flow.
Internat. J. Numer. Methods Fluids. 2010; 63: 1208-1232
• Koshizuka S.
• Oka Y.
Moving-particle semi-implicit method for fragmentation of incompressible fluid.
Nucl. Sci. Eng. 1996; 123: 421-434
• Cummins S.J.
• Rudman M.
An SPH projection method.
J. Comput. Phys. 1999; 152: 584-607
• Lo E.Y.
• Shao S.
Simulation of near-shore solitary wave mechanics by an incompressible SPH method.
Appl. Ocean Res. 2002; 24: 275-286
• Harlow F.H.
• Welch J.E.
Numerical calculation of time-dependent viscous incompressible flow of fluid with free surface.
Phys. Fluids. 1965; 8: 2182-2189
• Chorin A.J.
The numerical solution of the Navier-Stokes equations for an incompressible fluid.
Bull. Amer. Math. Soc. 1967; 73: 928-931
• Temam R.
Sur l’approximation de la solution des équations de Navier-Stokes par la méthode des pas fractionnaires (II).
Arch. Ration. Mech. Anal. 1969; 33: 377-385
• Oochi M.
Trans. Jpn. Soc. Comput. Eng. Sci. 2010;
• Amaro Junior R.A.
• Gay Neto A.
• Cheng L.-Y.
Three-dimensional weakly compressible moving particle simulation coupled with geometrically nonlinear shell for hydro-elastic free-surface flows.
Internat. J. Numer. Methods Fluids. 2022;
• Tanaka M.
• Masunaga T.
Stabilization and smoothing of pressure in MPS method by quasi-compressibility.
J. Comput. Phys. 2010; 229: 4279-4290
• Cheng L.-Y.
• Junior R.A.A.
• Favero E.H.
Improving stability of moving particle semi-implicit method by source terms based on time-scale correction of particle-level impulses.
Eng. Anal. Bound. Elem. 2021; 131: 118-145
• Mitsume N.
• Yoshimura S.
• Murotani K.
Explicitly represented polygon wall boundary model for the explicit MPS method.
Comput. Part. Mech. 2015; 2: 73-89
• Lee B.-H.
• Park J.-C.
• Kim M.-H.
• Hwang S.-C.
Step-by-step improvement of MPS method in simulating violent free-surface motions and impact-loads.
Comput. Methods Appl. Mech. Engrg. 2011; 200: 1113-1125
• Tsukamoto M.M.
• Cheng L.-Y.
• Motezuki F.K.
Fluid interface detection technique based on neighborhood particles centroid deviation (NPCD) for particle methods.
Internat. J. Numer. Methods Fluids. 2016; 82: 148-168
• Tamai T.
• Koshizuka S.
Least squares moving particle semi-implicit method.
Comput. Part. Mech. 2014; 1: 277-305
• Lind S.J.
• Xu R.
• Stansby P.K.
• Rogers B.D.
Incompressible smoothed particle hydrodynamics for free-surface flows: A generalised diffusion-based algorithm for stability and validations for impulsive flows and propagating waves.
J. Comput. Phys. 2012; 231: 1499-1523
• Xu T.
• Jin Y.-C.
Improvements for accuracy and stability in a weakly-compressible particle method.
Comput. & Fluids. 2016; 137: 1-14
• Jandaghian M.
• Krimi A.
• Shakibaeinia A.
Enhanced weakly-compressible MPS method for immersed granular flows.
• Pereira L.S.
• Amaro Junior R.
• Cheng L.-Y.
The influence of wall boundary modeling on the unphysical frictional loss inside horizontal main drain.
in: International Conference on Computing in Civil and Building Engineering. Springer, 2020: 1262-1275
1. R. Amaro, L. Pereira, L. Cheng, A. Shakibaeinia, Polygon Wall Boundary Model in Particle-Based Method: Application to Brumadinho Tailings Dam Failure, in: 25th ABCM International Congress of Mechanical Engineering, 2019, p. 10.

• Fernandes D.T.
• Cheng L.-Y.
• Favero E.H.
• Nishimoto K.
A domain decomposition strategy for hybrid parallelization of moving particle semi-implicit (MPS) method for computer cluster.
Cluster Comput. 2015; 18: 1363-1377
• Gou W.
• Zhang S.
• Zheng Y.
Implementation of the moving particle semi-implicit method for free-surface flows on GPU clusters.
Comput. Phys. Comm. 2019; 244: 13-24
2. D. Koschier, J. Bender, Density maps for improved SPH boundary handling, in: Proceedings of the ACM SIGGRAPH/Eurographics Symposium on Computer Animation, 2017, pp. 1–10.

• 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.
Comput. Phys. Comm. 2019; 234: 93-111
• Kostorz W.
• Esmail-Yakas A.
Semi-analytical smoothed-particle hydrodynamics correction factors for polynomial kernels and piecewise-planar boundaries.
Internat. J. Numer. Methods Engrg. 2021; 122: 7271-7305
• Matsunaga T.
• Yuhashi N.
• Shibata K.
• Koshizuka S.
A wall boundary treatment using analytical volume integrations in a particle method.
Internat. J. Numer. Methods Engrg. 2020; 121: 4101-4133
• Bellezi C.A.
• Cheng L.-Y.
• Amaro Jr. R.A.
• Tsukamoto M.M.
Border mapping multi-resolution (BMMR) technique for incompressible projection-based particle methods.
Comput. Methods Appl. Mech. Engrg. 2022; 396115013
• Koshizuka S.
• Shibata K.
• Kondo M.
• Matsunaga T.
Moving particle semi-implicit method: a meshfree particle method for fluid dynamics.