└── README.md
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | [](https://pypi.org/project/meshzoo/)
6 | [](https://pypi.org/project/meshzoo/)
7 | [](https://github.com/nschloe/meshzoo)
8 | [](https://pepy.tech/project/meshzoo)
9 |
10 |
11 |
12 | [](https://discord.gg/PBCCvwHqpv)
13 |
14 | When generating meshes for FEM/FVM computations, sometimes your geometry is so simple
15 | that you don't need a complex mesh generator (like
16 | [pygmsh](https://github.com/meshpro/pygmsh/),
17 | [MeshPy](https://github.com/inducer/meshpy),
18 | [mshr](https://bitbucket.org/fenics-project/mshr),
19 | [pygalmesh](https://github.com/meshpro/pygalmesh/),
20 | [dmsh](https://github.com/meshpro/dmsh/)),
21 | but something simple and fast that makes use of the structure of the domain. Enter
22 | meshzoo.
23 |
24 | ### Installation
25 |
26 | Install meshzoo [from PyPI](https://pypi.org/project/meshzoo/) with
27 |
28 | ```
29 | pip install meshzoo
30 | ```
31 |
32 | ### How to get a license
33 |
34 | Licenses for personal and academic use can be purchased
35 | [here](https://buy.stripe.com/5kA3eV8t8af83iE9AE).
36 | You'll receive a confirmation email with a license key.
37 | Install the key with
38 |
39 | ```
40 | plm add
41 | ```
42 |
43 | on your machine and you're good to go.
44 |
45 | For commercial use, please contact support@mondaytech.com.
46 |
47 | ### Examples
48 |
49 | #### Triangle
50 |
51 |
52 |
53 | ```python
54 | import meshzoo
55 |
56 | bary, cells = meshzoo.triangle(8)
57 |
58 | # corners = np.array(
59 | # [
60 | # [0.0, -0.5 * numpy.sqrt(3.0), +0.5 * numpy.sqrt(3.0)],
61 | # [1.0, -0.5, -0.5],
62 | # ]
63 | # )
64 | # points = np.dot(corners, bary).T
65 |
66 | # Process the mesh, e.g., write it to a file using meshio
67 | # meshio.write_points_cells("triangle.vtk", points, {"triangle": cells})
68 | ```
69 |
70 | #### Rectangle
71 |
72 |
73 |
74 |  |
75 |  |
76 |
77 |
78 |
79 | ```python
80 | import meshzoo
81 | import numpy as np
82 |
83 | points, cells = meshzoo.rectangle_tri(
84 | np.linspace(0.0, 1.0, 11),
85 | np.linspace(0.0, 1.0, 11),
86 | variant="zigzag", # or "up", "down", "center"
87 | )
88 |
89 | points, cells = meshzoo.rectangle_quad(
90 | np.linspace(0.0, 1.0, 11),
91 | np.linspace(0.0, 1.0, 11),
92 | cell_type="quad4", # or "quad8", "quad9"
93 | )
94 | ```
95 |
96 | #### Regular polygon
97 |
98 | |
|
|
|
99 | | :---------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------: |
100 | | `meshzoo.ngon(4, 8)` | `meshzoo.ngon(6, 8)` | `meshzoo.ngon(9, 8)` |
101 |
102 | ```python
103 | import meshzoo
104 |
105 | points, cells = meshzoo.ngon(5, 11)
106 | ```
107 |
108 | #### Disk
109 |
110 | |
|
|
|
111 | | :---------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------: |
112 | | `meshzoo.disk(4, 8)` | `meshzoo.disk(6, 8)` | `meshzoo.disk(9, 8)` |
113 |
114 | The disk meshes are inflations of regular polygons.
115 |
116 | ```python
117 | import meshzoo
118 |
119 | points, cells = meshzoo.disk(6, 11)
120 |
121 | points, cells = meshzoo.disk_quad(10, cell_type="quad4") # or "quad8", "quad9"
122 | ```
123 |
124 | #### Möbius strip
125 |
126 |
127 |
128 | ```python
129 | import meshzoo
130 |
131 | points, cells = meshzoo.moebius(num_twists=1, nl=60, nw=11)
132 | ```
133 |
134 | #### Sphere (surface)
135 |
136 | |
|
|
137 | | :--------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------: |
138 |
139 | ```python
140 | import meshzoo
141 |
142 | points, cells = meshzoo.uv_sphere(num_points_per_circle=20, num_circles=10, radius=1.0)
143 | points, tri, quad = meshzoo.geo_sphere(
144 | num_points_per_circle=20, num_circles=10, radius=1.0
145 | )
146 | ```
147 |
148 | Spheres can also be generated by refining the faces of [platonic
149 | solids](https://en.wikipedia.org/wiki/Platonic_solid) and then "inflating" them. meshzoo
150 | implements a few of them. The sphere generated from the icosahedron has the
151 | highest-quality (most equilateral) triangles.
152 |
153 | All cells are oriented such that its normals point outwards.
154 |
155 | |
|
|
|
156 | | :-----------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------: |
157 | | `meshzoo.tetra_sphere(10)` | `meshzoo.octa_sphere(10)` | `meshzoo.icosa_sphere(10)` |
158 |
159 | #### Ball (solid)
160 |
161 | |
|
|
162 | | :---------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------: |
163 |
164 | ```python
165 | import meshzoo
166 |
167 | points, cells = meshzoo.ball_tetra(10)
168 | points, cells = meshzoo.ball_hexa(10)
169 | ```
170 |
171 | #### Tube
172 |
173 |
174 |
175 | ```python
176 | import meshzoo
177 |
178 | points, cells = meshzoo.tube(length=1.0, radius=1.0, n=30)
179 | ```
180 |
181 | #### Cube
182 |
183 | |
|
|
184 | | :---------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------: |
185 |
186 | ```python
187 | import meshzoo
188 | import numpy as np
189 |
190 | points, cells = meshzoo.cube_tetra(
191 | np.linspace(0.0, 1.0, 11), np.linspace(0.0, 1.0, 11), np.linspace(0.0, 1.0, 11)
192 | )
193 | points, cells = meshzoo.cube_hexa(
194 | np.linspace(0.0, 1.0, 11), np.linspace(0.0, 1.0, 11), np.linspace(0.0, 1.0, 11)
195 | )
196 | ```
197 |
--------------------------------------------------------------------------------