This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Two-dimensional Mesh Generator in Generalized Coordinates Implemented in Python

Gustavo Taiji Naozuka, Saulo Martiello Mastelini
Departamento de Computação
Universidade Estadual de Londrina
gtnaozuka@gmail.com,saulomastelini@gmail.com

Eliandro Rodrigues Cirilo, Neyva Maria Lopes Romeiro, Paulo Laerte Natti
Departamento de Matemática
Universidade Estadual de Londrina
nromeiro@uel.br,ercirilo@uel.br,plnatti@uel.br

Abstract
Through mathematical models, it is possible to turn a problem of the physical domain to the computational domain. In this context, the paper presents a two-dimensional mesh generator in generalized coordinates, which uses the Parametric Linear Spline method and partial differential equations. The generator is automated and able to treat real complex domains. The code was implemented in Python, applying the Numpy and Matplotlib libraries to matrix manipulations and graphical plots, respectively. Applications are made for monoblock meshes (two-dimensional shape of a bottle) and multiblock meshes (geometry of Igapó I lake, Londrina, Paraná, Brazil).

keyword:Automated two-dimensional mesh generator, Parametric Linear Spline, generalized coordinates, Python language, applications.

1 Introduction

The modeling and simulation of natural phenomena using differential equations is an important tool for science. However, to represent physical structures, that is, the domain to be studied in a computational environment, the use of simpler data organization structures, such as matrices and vectors, tend not to be able to realistically represent the object of study. Thus, different techniques have been used for the representation of domains, such as structured and unstructured meshes, generalized or hybrid meshes, among other techniques, that have advantages and disadvantages in terms of flexibility and ability to represent objects under study (THOMPSON et al., 1977; THOMPSON et al., 1985; THOMPSONet al., 1998; MALISKA, 2004; CIRILO et al. 2006; KOOMULLIL et al, 2008; LAIPING et al., 2013; SAITA et al., 2017; BELINELLI et al, 2020).

In this work, we looked for a simplified way to build a structured mesh for a complex domain, which was possible through a change in the coordinate system. This process allowed to convert a complex domain into a set of easily manipulated data (MALISKA, 2004). Mathematically, any geometry, described in Cartesian system, can be transformed into a generalized system, allowing better adaptation in computational modeling (CIRILO et al. 2006; MALISKA, 2004; ROMEIRO et al., 2011; PARDO et al., 2012; SAITA et al., 2017; ROMEIRO et al., 2017; CIRILO et al., 2018).

In this context, this work describes the creation and implementation of a two-dimensional mesh generator using transformation metrics in generalized coordinates. This procedure generates a domain mapped for mathematical manipulations, which describes any physical object, from a finite set of points. The mesh generator is encoded in Python and uses the libraries numpy and matplotlib for manipulations and operations on matrices and graphical plots, respectively (CAI et al., 2005; SCIPY-NUMPY, 2020; SCIPY-MATPLOTLIB,2020).

The work is structured as shown below. Initially, transformation metrics are described in generalized coordinate theory. Then the mesh generator is developed. Finally, some examples of meshes obtained by the generator are presented.

2 Generalized Coordinate

For a computational methodology to be applied to a physical problem, it is necessary to discretize the domain of the problem, that is, to build a computational mesh that can represent the studied geometry and, thus, obtain the values of interest.

The discretization of the physical domain can be carried out according to a structured or unstructured mesh. Unstructured meshes are more adaptable than structured meshes, especially in problems with complex geometries (MALISKA, 2004; FORTUNA, 2012). However, the major disadvantage of unstructured meshes is the difficulty of ordering the elements, which implies a variation in the size of the diagonals of the coefficient matrix and the additional cost of using memory, making it difficult to apply numerical methods to obtain the solution of linear systems. Therefore, the domain discretization in this work will be performed using structured meshes.

As for the coordinate system, in general, the problem domain is discretized according to the Cartesian coordinate system because it is simpler. However, for problems with complex geometry, it is convenient to adopt another coordinate system, due to the fact that the Cartesian coordinate system leads to a poor adaptation of the border, since the physical domain does not always coincide with the domain of the Cartesian mesh. To solve the problem, the generalized coordinate system will be used. In generalized coordinates, the computational mesh coincides with the geometry of the problem and computational treatment becomes more appropriate. Other reasons that justify the use of generalized coordinates in the discretization of computational meshes are the simplicity in programming computational codes to solve complex problems and the ease in developing generic methodologies.

In the following, some important concepts about generalized coordinate theory will be presented

2.1 Transformation Metrics

The Cartesian system (x,y)(x,y) is called the physical domain and the generalized system (ξ,η)(\xi,\eta) is called the transformed domain or computational domain.

The transformation from a non-trivial geometry described in a Cartesian coordinate system to a generalized coordinate system involves transformation metrics, or mathematical relations, that can accurately describe the transformed data.

The mapping of irregular or regular geometries written in Cartesian coordinates (x,y)(x,y), Fig. 1a, is performed numerically for regular geometries written in generalized coordinate system (ξ,η)(\xi,\eta), Fig. 1b.

Figura 1: Coordinate systems
Refer to caption
(a) Cartesian coordinate
Refer to caption
(b) Generalized coordinate

Source: The Authors

Since the transformed domain is regular, for convenience, unitary normalization of elementary volumes is assumed, that is, Δξ=Δη=1\Delta\xi=\Delta\eta=1. In this way, even if in the physical plane the coordinated lines assume arbitrary spacing, in the computational plane the dimensions are fixed to the unit.

To obtain the (ξ,η)(\xi,\eta) system, the following generating equations are used

ξ=ξ(x,y),\displaystyle\xi=\xi(x,y), (1)
η=η(x,y).\displaystyle\eta=\eta(x,y). (2)

The transformation metrics, based on differentials of the Eqs. (1) and (2), are

dξ=ξxdx+ξydy,\displaystyle d\xi=\xi_{x}dx+\xi_{y}dy, (3)
dη=ηxdx+ηydy,\displaystyle d\eta=\eta_{x}dx+\eta_{y}dy, (4)

or, in the matrix form

(dξdη)=(ξxξyηxηy)(dxdy),\left(\begin{array}[]{c}d\xi\\ d\eta\end{array}\right)=\left(\begin{array}[]{cc}\xi_{x}&\xi_{y}\\ \eta_{x}&\eta_{y}\end{array}\right)\left(\begin{array}[]{c}dx\\ dy\end{array}\right), (5)

which can also be written as

dt=Adf,d^{t}=Ad^{f}, (6)

where ξx\xi_{x}, ηx\eta_{x}, ξy\xi_{y}, and ηy\eta_{y} denoting partial derivatives, dtd^{t} and dfd^{f} represent, respectively, the differentials in the transformed and physical domain, while AA is the transformation matrix between the domains.

Starting from the assumption that it is possible to find a representation in a Cartesian coordinate system for a model described in generalized coordinates, then we admit the existence of the inverse of the equations Eqs. (1) and (2), so

x=x(ξ,η),\displaystyle x=x(\xi,\eta), (7)
y=y(ξ,η),\displaystyle y=y(\xi,\eta), (8)

and from differentials of Eqs. (7) and (8) we have

(dxdy)=(xξxηyξyη)(dξdη),\left(\begin{array}[]{c}dx\\ dy\end{array}\right)=\left(\begin{array}[]{cc}x_{\xi}&x_{\eta}\\ y_{\xi}&y_{\eta}\end{array}\right)\left(\begin{array}[]{c}d\xi\\ d\eta\end{array}\right), (9)

which can also be written as

df=Bdt,d^{f}=Bd^{t}, (10)

where xξx_{\xi}, xηx_{\eta}, yξy_{\xi}, and yηy_{\eta} denoting partial derivatives and BB is the transformation matrix between the physical and transformed domains.

Replacing Eq. (6) in Eq. (10), we get df=BAdfd^{f}=BAd^{f}, so that BA=IBA=I, or equivalent A=B1A=B^{-1}. Thus, the AA matrix becomes

(ξxξyηxηy)=(yηxξyηxηyξxηxξyηxηyξyξxξyηxηyξxξxξyηxηyξ),\left(\begin{array}[]{cc}\xi_{x}&\xi_{y}\\ \eta_{x}&\eta_{y}\end{array}\right)=\left(\begin{array}[]{cc}\frac{y_{\eta}}{x_{\xi}y_{\eta}-x_{\eta}y_{\xi}}&\frac{-x_{\eta}}{x_{\xi}y_{\eta}-x_{\eta}y_{\xi}}\\ \frac{-y_{\xi}}{x_{\xi}y_{\eta}-x_{\eta}y_{\xi}}&\frac{x_{\xi}}{x_{\xi}y_{\eta}-x_{\eta}y_{\xi}}\end{array}\right), (11)

where J=(xξyηxηyξ)1J=(x_{\xi}y_{\eta}-x_{\eta}y_{\xi})^{-1} is called Jacobian of transformation (MALISKA, 2004).

2.2 Two-dimensional Mesh Generation

In this work, we opted for the use of elliptical partial differential equations (EPDE) as a method of generating two-dimensional meshes, since their solutions do not generate null Jacobian, and the lines ξ\xi or η\eta never intersect (THOMPSON, 1985; MALISKA, 2004). Thus, the governing equations for the generation of two-dimensional meshes in a domain, for example the domain illustrated in Fig. 2a, are

2ξ=P(ξ,η),\displaystyle\nabla^{2}\xi=P(\xi,\eta), (12)
2η=Q(ξ,η),\displaystyle\nabla^{2}\eta=Q(\xi,\eta), (13)

whose boundary conditions of the type Dirichlet are expressed by ξ=ξ1\xi=\xi_{1} in Γ1\Gamma_{1} (left border), ξ=ξN\xi=\xi_{N} in Γ3\Gamma_{3} (right border); η=η1\eta=\eta_{1} in Γ4\Gamma_{4} (lower border) and η=ηM\eta=\eta_{M} in Γ2\Gamma_{2} (upper border). In particular, in Fig. 2a were used N=10N=10 and M=5M=5 , where NN is the number of lines from ξ\xi and MM is the number of lines from η\eta.

Figura 2: Example of mesh in generalized coordinates
Refer to caption
(a) Predefined points
Refer to caption
(b) Mesh in generalized coordinates

Source: The Authors

Solving the equations (12) and (13), in relation to the (x,y)(x,y) coordinates, using the transformation metrics of the (ξ,η)(\xi,\eta) system, then the coordinated lines can be generated in the directions ξ\xi and η\eta, inside the computational mesh, Fig. 2b, as in any other geometry, through the equations

αxξξ+γxηη2βxξη+1J2(Pxξ+Qxη)=0,\displaystyle\alpha x_{\xi\xi}+\gamma x_{\eta\eta}-2\beta x_{\xi\eta}+\frac{1}{J^{2}}(Px_{\xi}+Qx_{\eta})=0, (14)
αyξξ+γyηη2βyξη+1J2(Pyξ+Qyη)=0,\displaystyle\alpha y_{\xi\xi}+\gamma y_{\eta\eta}-2\beta y_{\xi\eta}+\frac{1}{J^{2}}(Py_{\xi}+Qy_{\eta})=0, (15)

where xx and yy are the Cartesian coordinates of the physical domain, ξ\xi and η\eta are the generalized coordinates of the computational domain, PP and QQ are the source functions, JJ is the Jacobian of transformation, and

α=xη2+yη2,\displaystyle\alpha=x^{2}_{\eta}+y^{2}_{\eta}, (16)
β=xξxη+yξyη,\displaystyle\beta=x_{\xi}x_{\eta}+y_{\xi}y_{\eta}, (17)
γ=xξ2+yξ2.\displaystyle\gamma=x^{2}_{\xi}+y^{2}_{\xi}. (18)

The numerical solution of elliptical EDPs (14) and (15), subject to initial and boundary conditions, provide the lines ξ\xi and η\eta, which generate the computational mesh (DE BORTOLI, 2000, MALISKA, 2004; CIRILO et al., 2006; FORTUNA, 2012). For convenience, Eqs. (14) and (15) can be written using a generic ϕ\phi variable as

αϕξξ+γϕηηαβϕξη+1J2(Pϕξ+Qϕη)=0.\alpha\phi_{\xi\xi}+\gamma\phi_{\eta\eta}-\alpha\beta\phi_{\xi\eta}+\frac{1}{J^{2}}(P\phi_{\xi}+Q\phi_{\eta})=0. (19)

To approximate the derivatives in Eq. (19), the finite difference method is used. The mesh nodes are labeled by the cardinal points PP (center), EE (east), WW (west), NN (north), SS (south), NWNW (northwest ), SWSW (southwest), SESE (southeast) and NENE (northeast), as in Fig. 3.

Figura 3: Index labeling
Refer to caption

Source: The Authors

Approximating the derivative terms of Eq. ( Ref eq27) by means of central differences, around PP, we obtain

α(ϕE2ϕP+ϕWΔξ2)+γ(ϕN2ϕP+ϕSΔη2)2β(ϕNEϕNW+ϕSWϕSE4ΔξΔη)+\displaystyle\alpha(\frac{\phi_{E}-2\phi_{P}+\phi_{W}}{\Delta\xi^{2}})+\gamma(\frac{\phi_{N}-2\phi_{P}+\phi_{S}}{\Delta\eta^{2}})-2\beta(\frac{\phi_{NE}-\phi_{NW}+\phi_{SW}-\phi_{SE}}{4\Delta\xi\Delta\eta})+
1J2(PϕEϕW2Δξ+QϕNϕS2Δη)=0,\displaystyle\frac{1}{J^{2}}(P\frac{\phi_{E}-\phi_{W}}{2\Delta\xi}+Q\frac{\phi_{N}-\phi_{S}}{2\Delta\eta})=0, (20)

and regrouping the terms

(2α2γ)ϕP+(α+P2J2)ϕE+(αP2J2)ϕW+(γ+Q2J2)ϕN+\displaystyle-(2\alpha-2\gamma)\phi_{P}+(\alpha+\frac{P}{2J^{2}})\phi_{E}+(\alpha-\frac{P}{2J^{2}})\phi_{W}+(\gamma+\frac{Q}{2J^{2}})\phi_{N}+
(γQ2J2)ϕSβ2ϕNE+β2ϕNWβ2ϕSW+β2ϕSE=0.\displaystyle(\gamma-\frac{Q}{2J^{2}})\phi_{S}-\frac{\beta}{2}\phi_{NE}+\frac{\beta}{2}\phi_{NW}-\frac{\beta}{2}\phi_{SW}+\frac{\beta}{2}\phi_{SE}=0. (21)

Thus, the numerical solution of the two-dimensional mesh generation equations, Eqs. (14) and (15), written according to the generic ϕ\phi variable, Eq. (21), is given by

ϕP=1AP(AEϕE+AWϕW+ANϕN+ASϕS+ANEϕNE+ASEϕSE+\displaystyle\phi_{P}=\frac{1}{A_{P}}(A_{E}\phi_{E}+A_{W}\phi_{W}+A_{N}\phi_{N}+A_{S}\phi_{S}+A_{NE}\phi_{NE}+A_{SE}\phi_{SE}+
ANWϕNW+ASWϕSW),\displaystyle A_{NW}\phi_{NW}+A_{SW}\phi_{SW}), (22)

where

AP=2α+2γ,AN=γ+Q2J2,ASE=β2,AE=α+P2J2,AS=γQ2J2,ANW=β2,AW=αP2J2,ANE=β2,ASW=β2,\displaystyle\begin{array}[]{lclcl}A_{P}=2\alpha+2\gamma,&&A_{N}=\gamma+\frac{Q}{2J^{2}},&&A_{SE}=\frac{\beta}{2},\\ \\ A_{E}=\alpha+\frac{P}{2J^{2}},&&A_{S}=\gamma-\frac{Q}{2J^{2}},&&A_{NW}=\frac{\beta}{2},\\ \\ A_{W}=\alpha-\frac{P}{2J^{2}},&&A_{NE}=-\frac{\beta}{2},&&A_{SW}=-\frac{\beta}{2},\end{array} (28)

with derivatives present in JJ approximated by central differences.

Next, the mesh generator in generalized coordinates is presented.

3 Mesh Generator in Generalized Coordinate

For the creation of an automated procedure for mapping a geometry in Cartesian coordinates, through a generalized coordinate system, we chose to use the programming language Python.

The reason for this choice is due to the fact that Python is a general, free, open, and multiplatform language, which can allow the creation of extensions of the developed application, such as, for example, a graphical interface module, among others.

Regarding performance, it is necessary to use extra libraries, specific to numerical computing applications, to achieve satisfactory results at run time. Because it is a scripting language, that is, interpreted, the performance of an application written in Python tends to be inferior when compared to a compiled language, as is the case of the Fortran language. In Python, the tools available for matrix manipulation and linear algebra are limited and not optimized for the type of application that was intended to be developed. However, because the adopted language is modular, it is possible to use routines and libraries in compiled languages, in order to optimize more complex operations, such as those used for domain transformations (CAI et al., 2005).

For the creation of the mesh generator, the following libraries were used:

  • Numpy - library dedicated to matrix and algebraic operations in general (SCIPY-NUMPY, 2020);

  • Matplotlib - library used to generate graphs and manipulate data in graphical form (SCIPY-MATPLOTLIB, 2020).

The additional modules employed are also free for use.

3.1 Description of the Algorithm Developed

For the definition and creation of a geometry mapped in generalized coordinates, it starts from a initial set of points that describe the border, that is, the physical contour. In this work, the Parametric Linear Spline method was chosen to interpolate the set of border points under study. Parametric Linear Spline equations (BURDEN et al., 2015) are

six(t)=xi1tittiti1+xitti1titi1,s^{x}_{i}(t)=x_{i-1}\frac{t_{i}-t}{t_{i}-t_{i-1}}+x_{i}\frac{t-t_{i-1}}{t_{i}-t_{i-1}}, (29)
siy(t)=yi1tittiti1+yitti1titi1,s^{y}_{i}(t)=y_{i-1}\frac{t_{i}-t}{t_{i}-t_{i-1}}+y_{i}\frac{t-t_{i-1}}{t_{i}-t_{i-1}}, (30)

t[ti1,ti]\forall t\in[t_{i-1},t_{i}], where ss interpolating spline curve and tt is the interpolated variable.

Having obtained the interpolating lines of the border, Eqs. (29) and (30), the number of partitions desired for each border must be defined.

Then, points of the Splines curves are selected, which define the new border of the approximate geometry. To do this, an approach is used to position the points by weighted average of the components of the border, ie

xij=pxΓ1Γ3(x0j+iΔj1xξ)+pxΓ2Γ4(xi0+jΔi1xη),x_{ij}=p^{\Gamma_{1}\Gamma_{3}}_{x}(x_{0j}+i\Delta^{x\xi}_{j-1})+p^{\Gamma_{2}\Gamma_{4}}_{x}(x_{i0}+j\Delta^{x\eta}_{i-1}), (31)
yij=pyΓ1Γ3(y0j+iΔj1yξ)+pyΓ2Γ4(yi0+jΔi1yη),y_{ij}=p^{\Gamma_{1}\Gamma_{3}}_{y}(y_{0j}+i\Delta^{y\xi}_{j-1})+p^{\Gamma_{2}\Gamma_{4}}_{y}(y_{i0}+j\Delta^{y\eta}_{i-1}), (32)

where Δjxξ=xξjx0jξ\Delta^{x\xi}_{j}=\frac{x_{\xi j}-x_{0j}}{\xi}, Δixη=xiηxi0η\Delta^{x\eta}_{i}=\frac{x_{i\eta}-x_{i0}}{\eta}, Δjyξ=yξjy0jξ\Delta^{y\xi}_{j}=\frac{y_{\xi j}-y_{0j}}{\xi}, Δiyη=yiηyi0η\Delta^{y\eta}_{i}=\frac{y_{i\eta}-y_{i0}}{\eta}, i=1,,ξi=1,...,\xi e j=1,,ηj=1,...,\eta.

The values of pxΓ1Γ3p^{\Gamma_{1}\Gamma_{3}}_{x}, pxΓ2Γ4p^{\Gamma_{2}\Gamma_{4}}_{x}, pyΓ1Γ3p^{\Gamma_{1}\Gamma_{3}}_{y}, and pyΓ2Γ4p^{\Gamma_{2}\Gamma_{4}}_{y} indicate the weights on the left/right borders in xx, top/bottom in xx, left/right in yy and top/bottom in yy , respectively. The percentage weights in Eqs. (31) and (32) can better adjust the distribution of points in the domain, avoiding concentrations of points. In this way, the arrangement of the internal points is influenced by the edges.

Finally, on the set of ordered pairs, the resolution of the equation (22) is applied.

In summary, the implemented algorithm can be illustrated in this way:

Step 1. Reading the input data: Read the number of partitions from the physical and transformed planes, the weights for calculating the weighted average and the border points.

Step 2. Border interpolation: Define the border using the Parametric Linear Spline method and the border points previously read.

Step 3. Calculate the points of the Spline lines, using the weighted average formulas, and define the new border points.

Step 4. Application of transformation metrics: On the generated data, apply the transformation metrics to obtain the interior mesh curves.

The next two sections are intended to exemplify and test the algorithm. In the first applications, monoblock meshes are built (3 applications). Following a multiblock mesh is obtained. The multiblock technique consists of dividing the physical domain into parts and, on each of the parts, applying the generation of meshes in generalized coordinates. Such a procedure allows to better capture the complexity of the geometry compared to the strategy employed on a single block (CIRILO, 2006; PARDO et al., 2012, SAITA et al., 2017).

3.2 Monoblock Mesh Generation

As a first application of the mesh generation algorithm, the set of input data presented in Table 1 was used. The weighted values for Γj\Gamma_{j}, j=j= 1 and 3 are omitted, since they are known for complementarity, that is, pxΓ1Γ3+pxΓ2Γ4=1p^{\Gamma_{1}\Gamma_{3}}_{x}+p^{\Gamma_{2}\Gamma_{4}}_{x}=1 e pyΓ1Γ3+pyΓ2Γ4=1p^{\Gamma_{1}\Gamma_{3}}_{y}+p^{\Gamma_{2}\Gamma_{4}}_{y}=1.

Tabela 1: Input data of a Rectangular Geometry with Cutout
Number of partitions (dfd^{f}) Number of partitions (dtd^{t}) Weighted average
Input data Refinement 1 Refinement 2 Weights (pΓ2Γ4p^{\Gamma_{2}\Gamma_{4}})
xyx\quad\quad y ξη\xi\quad\quad\eta ξη\xi\quad\quad\eta xyx\quad\quad y
10410\quad\quad 4 15615\quad\quad 6 301230\quad\quad 12 0.91.00.9\quad\quad 1.0

Given the set of predefined points, Fig. 4a, the number of partitions and the weights at the borders, Table 1, then the border geometry is obtained by Parametric Spline Linear interpolation. In sequence, the algorithm calculates the new border points, using the given refinement. In this way, the algorithm starts to solve the transformation metrics, finally generating the mesh in generalized coordinates. Figs. 4b and 4c present the meshes in generalized coordinates, according to the refinements described in Table 1.

Figura 4: Rectangular Geometry with Cutout
Refer to caption
(a) Predefined points
Refer to caption
(b) Refinement 1
Refer to caption
(c) Refinement 2

Source: The Authors

As a second application, a mesh in a doubly-connected domain was generated. The set of input data is shown in Table 2.

Tabela 2: Input data of a Doubly-Connected Geometry
Number of partitions (dfd^{f}) Number of partitions (dtd^{t}) Weighted average
Input data Refinement 1 Refinement 2 Weights (pΓ1Γ3p^{\Gamma_{1}\Gamma_{3}})
xyx\quad\quad y ξη\xi\quad\quad\eta ξη\xi\quad\quad\eta xyx\quad\quad y
20420\quad\quad 4 30630\quad\quad 6 40840\quad\quad 8 0.050.00.05\quad\quad 0.0

In this application, the left/right border corresponds to the line segment that joins the two circles, while the upper/lower border corresponds to the two circles, as shown in Fig 5a. From the set of points given in Fig. 5a and the input data in Table 2, the algorithm constructs the meshes shown in Figs. 5b and 5c, according to the refinements described in Table 2.

Figura 5: Doubly-Connected Geometry
Refer to caption
(a) Predefined points
Refer to caption
(b) Refinement 1
Refer to caption
(c) Refinement 2

Source: The Authors

The latest generation of monoblock mesh is shaped like a bottle, as illustrated in Fig. 6. The set of input data is explained in Table 3.

Tabela 3: Input data of a Bottle Geometry
Number of partitions (dfd^{f}) Number of partitions (dtd^{t}) Weighted average
Input data Refinement 1 Refinement 2 Weights (pΓ1Γ3p^{\Gamma_{1}\Gamma_{3}})
xyx\quad\quad y ξη\xi\quad\quad\eta ξη\xi\quad\quad\eta xyx\quad\quad y
4104\quad\quad 10 6156\quad\quad 15 123012\quad\quad 30 1.00.51.0\quad\quad 0.5

Using the set of predefined points, Fig. 6a, and the input data in Table 3, the meshes in generalized coordinates are generated, as shown in Fig. 6b and Fig. 6c, according to the refinements described in Table 3.

Figura 6: Bottle Geometry
Refer to caption
(a) Predefined points
Refer to caption
(b) Refinement 1
Refer to caption
(c) Refinement 2

Source: The Authors

automated mesh generator In the applications presented for monoblock meshes, the automated mesh generator precisely built the geometry in the physical domain.

3.3 Multiblock Mesh Generation

In order to show a more complex application, points from the contour of Lake Igapó I, located in Londrina, Paraná, Brazil, were collected. The points were obtained from satellite images offered by the Google Earth software (GOOGLE, 2020). The generated mesh has the same scale as the physical domain.

Unlike previous applications, in addition to generating the monoblock meshes (now called monobloc sub-meshes), in this application the sub-meshes must be connected. The multiblock mesh algorithm uses the monoblock mesh generator as a subroutine of the multiblock algorithm.

In summary, the multiblock algorithm can be illustrated in this way:

Step 1. Loop condition: If there is a monoblock input file being passed as an argument, perform step 2. Otherwise, perform step 4.

Step 2. Monoblock mesh generation: Use the data present in the input file to generate the monoblock mesh.

Step 3. Plot the monoblock mesh: Use the results of the monoblock mesh generator algorithm to plot the monoblock mesh, and return to step 1.

Step 4. Plot the multiblock mesh: Show all monoblock meshes generated in a single multiblock mesh.

For the geometry of Lago Igapo, it is considered that it consists of three blocks, Lake Igapó I (main block) and its two tributaries (two other blocks). The set of predefined points are given in Fig. 7a. The input data are presented in Table 4. As for the weighted average, the percentage weights (pΓ1Γ3p^{\Gamma_{1}\Gamma_{3}} e pΓ2Γ4p^{\Gamma_{2}\Gamma_{4}}), in xx and yy, were all chosen as 0.50.5.

Tabela 4: Input data of Igapó I Lake
Monoblock Number of partitions (dfd^{f}) Number of partitions (dtd^{t})
Name Input data Refinement 1 Refinement 2
Principal xyx\quad\quad y ξη\xi\quad\quad\eta ξη\xi\quad\quad\eta
6706\quad\quad 70 6706\quad\quad 70 1214012\quad\quad 140
Tributary 1 xyx\quad\quad y ξη\xi\quad\quad\eta ξη\xi\quad\quad\eta
10210\quad\quad 2 10210\quad\quad 2 20420\quad\quad 4
Tributary 2 xyx\quad\quad y ξη\xi\quad\quad\eta ξη\xi\quad\quad\eta
858\quad\quad 5 858\quad\quad 5 281028\quad\quad 10

After executing the multiblock mesh algorithm, the meshes were obtained in generalized coordinates as shown in Figs. 7b and 7c, according to the refinements of Table 4.

Figura 7: Igapó I Lake Geometry
Refer to caption
(a) Predefined points
Refer to caption
(b) Refinement 1
Refer to caption
(c) Refinement 2

Source: The Authors

Again, the automated mesh generator accurately represented the physical domain of Igapó I lake, located in Londrina, Paraná, Brazil.

4 Final Considerations

In this work, using the generalized coordinate method, a mesh generator in Python was created and implemented. This automated mesh generator allowed the reproduction of complex geometries with several mesh refinements, as shown by the applications presented.

Specifically, as original contributions to this work, we highlight two aspects:

1- Parameterized Linear Spline. The use of the Parameterized Linear Spline method to obtain points at the border of the physical domain, given predefined points, allows the construction of the internal mesh in generalized coordinate, with the desired refinement, in a simple and fast way.

2- Python language. The Python programming language and the libraries used make it possible to optimize the algorithm, to facilitate the visualization of the meshes, and the portability of the application in different software architectures, such as Linux and Windows.


Referências


BELINELLI, E.O.; NATTI, P.L.; ROMEIRO, N.M.L.; CIRILO, E.R.; FANTIN, L.H.; OLIVEIRA, K.B.; CANTERI, M.G.; NATTI, E.R.T. Geração de malha para descrever a dispersão da ferrugem da soja no Paraná. In: Júlio Cesar Ribeiro. (Org.). Ciências Exatas e da Terra: Conhecimentos Estratégicos para o Desenvolvimento do País. 1ed.: Atena Editora, 2020, v. , p. 225-239.

BURDEN, R.L., FAIRES, J.D., BURDEN, A.M. Numerical Analysis. Boston: Cengage Learning, 2015.

CAI, X., LANGTANGEN, H. P., MOE, H. On the performance of the Python programming language for serial and parallel scientific computations. Scientific Programming, vol. 13, n. 1, pp. 31-56, 2005.

CIRILO, E.R.; DE BORTOLI, A.L. Cubic splines for trachea and bronchial tubes grid generation. Semina: Exact and Technological Sciences, v. 27, p.147-155, 2006.

CIRILO, E. R. ; BARBA, A. N. D. ; NATTI, P. L. ; ROMEIRO, N. M. L. . A numerical model based on the curvilinear coordinate system for the MAC method simplified. SEMINA. CIÊNCIAS EXATAS E TECNOLÓGICAS (ONLINE), v. 39, p. 87, 2018.

DE BORTOLI, A. L. Introdução à dinâmica de fluidos computacional. Porto Alegre: Editora da UFRG, 2000.

FORTUNA, A.O. Computational techniques for fluid dynamics: Basic concepts and applications. São Paulo: EDUSP, 2012.

GOOGLE. Google Earth. Disponível em: <https://www.google.com/earth/>. Acessed in oct. 2020.

KOOMULLIL, R.; SONI B.; SINGH R. A comprehensive generalized mesh system for CFD applications. Mathematics and Computers in Simulation, vol. 78, pp. 605-617, 2008.

LAIPING, Z.; ZHONG, Z.; XINGHUA, C., XITHAMES, H. A 3D hybrid grid generation technique and a multigrid/parallel algorithm based on anisotropic agglomeration approach. Chinese Journal of Aeronautics, vol. 26, n.1, pp. 47-62, 2013.

MALISKA, C. R. Transferência de calor e mecânica dos fluidos computacional. São Paulo: LTC, 2004.

PARDO, S.R.; NATTI, P.L.; ROMEIRO, N.M.L.; CIRILO, E.R. A transport modeling of the carbon-nitrogen cycle at Igapó I Lake-Londrina, Paraná State, Brazil. Acta Scientiarum. Technology, v. 34, p. 217-226, 2012.

ROMEIRO, N.L.M.; CASTRO, R.G.S.; CIRILO, E.R.; NATTI, P.L. Local calibration of coliforms parameters of water quality problem at Igapó I Lake - Londrina, Paraná, Brazil. Ecological Modelling, v. 222, p. 1888-1896, 2011.

ROMEIRO, N.L.M.; MANGILI, F.B.; COSTANZI, R.N.; CIRILO, E.R.; NATTI, P.L. Numerical simulation of BOD5 dynamics in Igapó I lake, Londrina, Paraná, Brazil: Experimental measurement and mathematical modeling. Semina: Exact and Technological Sciences, v. 38, p. 50-58, 2017.

SAITA, T.M.; NATTI, P.L.; CIRILO, E.R.; ROMEIRO, N.L.M.; CANDEZANO, M.A.C.; ACUNA, R.A.B.; MORENO, L.C.G. Simulação numérica da dinâmica de coliformes fecais no lago Luruaco, Colômbia. Trends in Applied and Computational Mathematics, v. 18, p. 435-447, 2017.

SCIPY-NUMPY. In <http://www.numpy.org/>. Acessed in oct. 2020.

SCIPY-MATPLOTLIB. In <http://matplotlib.org/>. Acessed in oct. 2020.

THOMPSON, J. F.; THAMES, F. C.; MASTIN, C. W. TOMCAT - A Code for Numerical Generation of Boundary Fitted Curvilinear Coordinate Systems on Fields Containing Any Number of Arbitrary Two-Dimensional Bodies. Journal of Computational Physics, vol. 24, pp. 274-302, 1977.

THOMPSON, J. F.; WARSI, Z. U. A.; MASTIN, C. W. Numerical grid generation: foundations and applications. New York: Elsevier Science Publishing, 1985.

THOMPSON, J.F.; SONI, B.K.; WEATHERILL, N.P. Handbook of Grid Generation. Florida: CRC Press, 1998.