A novel parallel algorithm for 3D modelling electromagnetic purification of water

The computational fluid dynamic research in this work has focused on the problem of full-scale three-dimensional modelling water purification processes by the electromagnetic method. Presently, this method of purification was used in the final stage of processing for the production of ultrapure water. In spite of many field experiments, detailed data on such processes can be obtained only by the mathematical modelling. This way allows us to take into account many aspects, for example: real three-dimensional geometry, physical structure of the purification system, heterogeneous composition of the impurities, etc. And also, the mathematical modelling helps to optimize many parameters in order to improve a design of the purification system. Within the framework of the modelling problem, one of the important aspects is the correct description of the three-dimensional flow inside a specific purification system. For this purpose, various mathematical models and numerical approaches are implemented. In this paper, the flow calculation was realized on basis of the Navier-Stokes equations.


Introduction
The most reliable way of studying hydrodynamic phenomena is the observation and analysis of real facts, i.e. physical experiment. However, the realization of such experiment is not always possible. For example, how to study the impact of the tsunami on a drilling platform? When a ship is building, its testing in real conditions also impossible to carry out at the design stage. In other cases, the experiments require significant resources and time. Nowadays, various numerical methods and algorithms for solving equations of the hydrodynamics and also modern computer technologies allow us to solve efficiently the complex hydrodynamic problems.
The water treatment is a process of making water suitable for its applications or returning its natural state. The required purification depends on the application. This process can involve science, engineering and business The treatment may include mechanical, physical, biological, and chemical methods.
The article discusses the problems of numerical simulation of the water purification from iron impurities. Methods of water treatment by the magnetic field are widely known and used in many industries.
In this work, the general effect of the magnetic field on water flowing through a non-metallic tube and containing iron ions and/or ions of iron salts is discussed.
To solve the problem, a magnetohydrodynamic model was formulated. It takes into account the direct influence of the magnetic induction on the flow of water. To simplify the description of the mathematical approach, we choose a case of isothermal Low Reynolds Number flow. Numerical solution of the Navier-Stokes equations was performed on triangular prismatic grids in according to the original exponential scheme. To accelerate the calculations, parallelization technologies are applied: the method of splitting domain, geometric parallelism and multithreaded programming. The developed computer code can be used on systems with central processors and/or with graphics accelerators. The performed computer calculations showed the effectiveness of the developed numerical method and the ability to solve problems of the hydrodynamics.
The magneto-hydrodynamic model describes mechanism of the magnetic treatment of a water flow based on the drift-diffusion approximation. The treatment was carried out in a flow tank with nonmagnetic walls. The hydrodynamic model has been supplemented with the electrostatic equations. The numerical realization is based on the methods of the theory of finite-difference schemes and on the original exponential schemes [9,12,13]. This paper has the following structure. In Section 2, we describe the hydrodynamic model and mathematical description of the problem. In Section 3, we introduce numerical method and some details of the numerical algorithm. Section 4 presents software and information about computing systems. In Section 5 we show and discuss results obtained with a novel parallel hydrodynamic algorithm. In Section 6, we sum up the

Hydrodynamic model
The hydrodynamic part of the general problem [9] is considered using an example of a simple geometry computational domain. For this aim, the flow of an aqueous stream with the impurities in a pipe of the circular cross-section is studies (Fig. 1). As the basic equations of motion, the Navier-Stokes equations for the incompressible fluid approximation for the isothermal case are applied [10]: Here -velocity vector of the water stream, u constant density of flow, -hydrodynamic pressure, p n -the gravity vector ( 0 g -acceleration of the gravity, g n -direction of the gravity),  -coefficient of dynamic viscosity, , and -gradient, divergence and Laplace operators in Cartesian coordinates (x, y ,z), -time, -fragment of a long pipe with diameter and length is with the border  , including the ends and the side surface.
The system (1), (2) we reduce to a dimensionless form by changing variables and functions: Here -maximum inlet pipe speed, -the ratio of the length of the pipe to its radius.  (2) does not change.
The initial and boundary conditions are written in dimensionless form. At the initial moment of time, we assume that the tube is filled with stationary liquid: After some time, the velocity at the entrance to the tube increases to a maximum value and has profile corresponding to the Poiseuille flow [10]: Here 0  -the rate of output of the input stream to the stationary mode. At the outlet of the pipe, free flow conditions are set: On the side surface of the pipe, the conditions for adhesion are set: In the future, we will consider flows that are practically independent of the gravity. Therefore, we set the parameter  equal to zero. We also need an equation for the pressure. It can be found from the stationary relation:

Numerical method
To solve the hydrodynamic problem, we used the finite volume method [11] on unstructured grids. As grid cells, prisms with a triangular base were implemented (An example of a prismatic grid is shown in Fig. 2). All the hydrodynamic parameters of the problem (velocity and pressure) were determined in the centers of the cells.
To solve equation (1 ') for 0   , the following explicit-implicit finite volume scheme was used: ,  -grid analogues of differential operators of gradient and Laplace [11]. The spatial approximation of the second and the third terms on the left-hand side of the discrete equation (10) was performed using exponential approximations proposed in [9,12,13].
The equation for the pressure approximated the standard way [11]: Here -grid analog of the divergence operator. div h

Fig. 2. Example of a prismatic mesh.
Equations (10) and (11) were solved successively by iterative methods according to the scheme of biconjugate gradients with diagonal operators of transition [14]. This circumstance allows us to continue parallelization of the numerical algorithm.

Parallel realization
Parallel realization of the proposed numerical algorithm was oriented on supercomputers or clusters with hybrid architecture. Such computer systems have several multicore central processors (CPUs) on each node, as well as several vector or graphics processors (VPUs or GPUs). Parallelization is performed on principles of geometric parallelism, splitting computational area into subdomains and uses algorithms for dynamic load balancing of the calculators. The developed hybrid code was executed on the basis of parallel programming technologies MPI, Open MP and CUDA.
The results of testing the program code are presented in the section 5.

Results and discussion
The first calculation was carried out using the example of the establishment of the Poiseuille flow. The purpose of the calculation is verifying numerical approach. For computing, dimensionless parameters were chosen: pipe length 6 L  , Reynolds number , number of grid cells Re 35  325090 C N  , time step is . The results of calculations for the established profiles of the longitudinal velocity and the pressure in the cross section Fig. 3. They coincide with the known analytical solution [10] with an accuracy about 0.01%. The initial grid (k=1) was used for testing parallelization on the CPU threads. The results of calculation for 100 time steps on one node of the K60 cluster are shown in Table 1. They illustrate the quite acceptable dependence of the acceleration and efficiency on number of the threads. The solution of the same problem on the start grid (the same 100 steps on time) on one NVidia Tesla V100 accelerator of the Sugon server takes 2.351 seconds. The used memory of the GPU is approximately 0.312 GB. The solution of the problem on the grid with the number k=2 requires memory of 2.496 GB and time of 49.928 seconds. The solution of the task on the grid with a number k=3 on one GPU is impossible because size of its RAM is exceeded (19.968 GB is required for this version). In this case, 2 graphic accelerators were implemented. The calculation time was 754.283 seconds. instead of the expected 400 seconds. Apparently, here a negative role was played by the data exchange through the CPU's RAM.
Testing the developed code in the simultaneous use mode of MPI and Open MP interfaces was carried out on K60 and K48 clusters. In the calculations, the grid with the number k = 3 was used. The results of the calculations are shown in Fig. 4. As it can be seen in the figures, the acceleration and efficiency of the parallelization on the K48 cluster is significantly higher than on the K60 cluster. However, the calculation time on the K48 cluster is 3-3.5 times more than the calculation time on the K60 cluster. To conclude this section, let us consider the dynamics of the establishment of a flow in a pipe. Initially the liquid in the tube is at rest and then during a certain time the transition mode is developed, as it is shown in Fig. 5 and Fig. 6. These pictures confirm that the presented code correctly describes the general picture of the flow.

Summary and conclusions
The paper considers the problem of computer modeling water stream contaminated by charged impurities of heavy metal. The complexity of the arising mathematical problem in this case is the need to consider the threedimensional real geometry of the system for the water electromagnetic purification. To solve this problem, a grid approach was proposed. It based on the finite volume method, unstructured grids and original exponential schemes for computing the flow parameters. The algorithm was illustrated by the example of the Poiseuille flow formation in a circular pipe. The unstructured grids consist of straight prisms with triangular bases. Parallel software implementation of the proposed approach was performed using a hybrid parallel technologies. These technologies combine MPI, Open MP and CUDA. They allow us to carry out calculations on central, vector and graphics processors. Verification and testing confirmed the operability and effectiveness of the developed approach. Further numerical experiments will be related to the solution of practical problems.