@@ -36,7 +36,12 @@ import pygalmesh
3636points = numpy.array([[0.0 , 0.0 ], [1.0 , 0.0 ], [1.0 , 1.0 ], [0.0 , 1.0 ]])
3737constraints = [[0 , 1 ], [1 , 2 ], [2 , 3 ], [3 , 0 ]]
3838
39- mesh = pygalmesh.generate_2d(points, constraints, edge_size = 1.0e-1 , num_lloyd_steps = 10 )
39+ mesh = pygalmesh.generate_2d(
40+ points,
41+ constraints,
42+ max_edge_size = 1.0e-1 ,
43+ num_lloyd_steps = 10 ,
44+ )
4045# mesh.points, mesh.cells
4146```
4247The quality of the mesh isn't very good, but can be improved with
@@ -49,7 +54,7 @@ The quality of the mesh isn't very good, but can be improved with
4954import pygalmesh
5055
5156s = pygalmesh.Ball([0 , 0 , 0 ], 1.0 )
52- mesh = pygalmesh.generate_mesh(s, cell_size = 0.2 )
57+ mesh = pygalmesh.generate_mesh(s, max_cell_circumradius = 0.2 )
5358
5459# mesh.points, mesh.cells, ...
5560```
@@ -65,7 +70,7 @@ The mesh generation comes with many more options, described
6570<!-- exdown-skip-->
6671``` python
6772mesh = pygalmesh.generate_mesh(
68- s, cell_size = 0.2 , edge_size = 0.1 , odt = True , lloyd = True , verbose = False
73+ s, max_cell_circumradius = 0.2 , odt = True , lloyd = True , verbose = False
6974)
7075```
7176
@@ -80,7 +85,11 @@ import pygalmesh
8085s0 = pygalmesh.Tetrahedron(
8186 [0.0 , 0.0 , 0.0 ], [1.0 , 0.0 , 0.0 ], [0.0 , 1.0 , 0.0 ], [0.0 , 0.0 , 1.0 ]
8287)
83- mesh = pygalmesh.generate_mesh(s0, cell_size = 0.1 , edge_size = 0.1 )
88+ mesh = pygalmesh.generate_mesh(
89+ s0,
90+ max_cell_circumradius = 0.1 ,
91+ max_edge_size_at_feature_edges = 0.1 ,
92+ )
8493```
8594
8695#### Domain combinations
@@ -111,8 +120,8 @@ u = pygalmesh.Difference(s0, s1)
111120
112121# add circle
113122a = numpy.sqrt(radius ** 2 - displacement ** 2 )
114- edge_size = 0.15
115- n = int (2 * numpy.pi * a / edge_size )
123+ max_edge_size_at_feature_edges = 0.15
124+ n = int (2 * numpy.pi * a / max_edge_size_at_feature_edges )
116125circ = [
117126 [0.0 , a * numpy.cos(i * 2 * numpy.pi / n), a * numpy.sin(i * 2 * numpy.pi / n)]
118127 for i in range (n)
@@ -122,15 +131,16 @@ circ.append(circ[0])
122131mesh = pygalmesh.generate_mesh(
123132 u,
124133 feature_edges = [circ],
125- cell_size = 0.15 ,
126- edge_size = edge_size ,
127- facet_angle = 25 ,
128- facet_size = 0.15 ,
129- cell_radius_edge_ratio = 2.0 ,
134+ max_cell_circumradius = 0.15 ,
135+ max_edge_size_at_feature_edges = max_edge_size_at_feature_edges ,
136+ min_facet_angle = 25 ,
137+ max_radius_surface_delaunay_ball = 0.15 ,
138+ max_circumradius_edge_ratio = 2.0 ,
130139)
131140```
132- Note that the length of the polygon legs are kept in sync with the ` edge_size ` of the
133- mesh generation. This makes sure that it fits in nicely with the rest of the mesh.
141+ Note that the length of the polygon legs are kept in sync with
142+ ` max_edge_size_at_feature_edges ` of the mesh generation. This makes sure that it fits in
143+ nicely with the rest of the mesh.
134144
135145#### Domain deformations
136146<img src =" https://nschloe.github.io/pygalmesh/egg.png " width =" 30% " >
@@ -141,7 +151,7 @@ import pygalmesh
141151
142152s = pygalmesh.Stretch(pygalmesh.Ball([0 , 0 , 0 ], 1.0 ), [1.0 , 2.0 , 0.0 ])
143153
144- mesh = pygalmesh.generate_mesh(s, cell_size = 0.1 )
154+ mesh = pygalmesh.generate_mesh(s, max_cell_circumradius = 0.1 )
145155```
146156
147157#### Extrusion of 2D polygons
@@ -153,10 +163,18 @@ alongside!
153163import pygalmesh
154164
155165p = pygalmesh.Polygon2D([[- 0.5 , - 0.3 ], [0.5 , - 0.3 ], [0.0 , 0.5 ]])
156- edge_size = 0.1
157- domain = pygalmesh.Extrude(p, [0.0 , 0.0 , 1.0 ], 0.5 * 3.14159265359 , edge_size)
166+ max_edge_size_at_feature_edges = 0.1
167+ domain = pygalmesh.Extrude(
168+ p,
169+ [0.0 , 0.0 , 1.0 ],
170+ 0.5 * 3.14159265359 ,
171+ max_edge_size_at_feature_edges,
172+ )
158173mesh = pygalmesh.generate_mesh(
159- domain, cell_size = 0.1 , edge_size = edge_size, verbose = False
174+ domain,
175+ max_cell_circumradius = 0.1 ,
176+ max_edge_size_at_feature_edges = max_edge_size_at_feature_edges,
177+ verbose = False ,
160178)
161179```
162180Feature edges are automatically preserved here, which is why an edge length needs to be
@@ -171,10 +189,13 @@ body.
171189import pygalmesh
172190
173191p = pygalmesh.Polygon2D([[0.5 , - 0.3 ], [1.5 , - 0.3 ], [1.0 , 0.5 ]])
174- edge_size = 0.1
175- domain = pygalmesh.RingExtrude(p, edge_size )
192+ max_edge_size_at_feature_edges = 0.1
193+ domain = pygalmesh.RingExtrude(p, max_edge_size_at_feature_edges )
176194mesh = pygalmesh.generate_mesh(
177- domain, cell_size = 0.1 , edge_size = edge_size, verbose = False
195+ domain,
196+ max_cell_circumradius = 0.1 ,
197+ max_edge_size_at_feature_edges = max_edge_size_at_feature_edges,
198+ verbose = False ,
178199)
179200```
180201
@@ -204,7 +225,7 @@ class Heart(pygalmesh.DomainBase):
204225
205226
206227d = Heart()
207- mesh = pygalmesh.generate_mesh(d, cell_size = 0.1 )
228+ mesh = pygalmesh.generate_mesh(d, max_cell_circumradius = 0.1 )
208229```
209230Note that you need to specify the square of a bounding sphere radius, used as an input
210231to CGAL's mesh generator.
@@ -213,33 +234,37 @@ to CGAL's mesh generator.
213234#### Local refinement
214235<img src =" https://nschloe.github.io/pygalmesh/ball-local-refinement.png " width =" 30% " >
215236
216- Use ` generate_mesh ` with a function (regular or lambda) as ` cell_size ` . The same goes
217- for ` edge_size ` , ` facet_size ` , and ` facet_distance ` .
237+ Use ` generate_mesh ` with a function (regular or lambda) as ` max_cell_circumradius ` . The
238+ same goes for ` max_edge_size_at_feature_edges ` , ` max_radius_surface_delaunay_ball ` , and
239+ ` max_facet_distance ` .
218240``` python
219241import numpy
220242import pygalmesh
221243
222244mesh = pygalmesh.generate_mesh(
223245 pygalmesh.Ball([0.0 , 0.0 , 0.0 ], 1.0 ),
224- facet_angle = 30 ,
225- facet_size = 0.1 ,
226- facet_distance = 0.025 ,
227- cell_radius_edge_ratio = 2 ,
228- cell_size = lambda x : abs (numpy.sqrt(numpy.dot(x, x)) - 0.5 ) / 5 + 0.025 ,
246+ min_facet_angle = 30.0 ,
247+ max_radius_surface_delaunay_ball = 0.1 ,
248+ max_facet_distance = 0.025 ,
249+ max_circumradius_edge_ratio = 2.0 ,
250+ max_cell_circumradius = lambda x : abs (numpy.sqrt(numpy.dot(x, x)) - 0.5 ) / 5 + 0.025 ,
229251)
230252```
231253
232254#### Surface meshes
233255
234256If you're only after the surface of a body, pygalmesh has ` generate_surface_mesh ` for
235- you. It offers fewer options (obviously, ` cell_size ` is gone), but otherwise works the
236- same way:
257+ you. It offers fewer options (obviously, ` max_cell_circumradius ` is gone), but otherwise
258+ works the same way:
237259``` python
238260import pygalmesh
239261
240262s = pygalmesh.Ball([0 , 0 , 0 ], 1.0 )
241263mesh = pygalmesh.generate_surface_mesh(
242- s, angle_bound = 30 , radius_bound = 0.1 , distance_bound = 0.1
264+ s,
265+ min_facet_angle = 30.0 ,
266+ max_radius_surface_delaunay_ball = 0.1 ,
267+ max_facet_distance = 0.1 ,
243268)
244269```
245270Refer to [ CGAL's
@@ -272,11 +297,11 @@ class Schwarz(pygalmesh.DomainBase):
272297mesh = pygalmesh.generate_periodic_mesh(
273298 Schwarz(),
274299 [0 , 0 , 0 , 1 , 1 , 1 ],
275- cell_size = 0.05 ,
276- facet_angle = 30 ,
277- facet_size = 0.05 ,
278- facet_distance = 0.025 ,
279- cell_radius_edge_ratio = 2.0 ,
300+ max_cell_circumradius = 0.05 ,
301+ min_facet_angle = 30 ,
302+ max_radius_surface_delaunay_ball = 0.05 ,
303+ max_facet_distance = 0.025 ,
304+ max_circumradius_edge_ratio = 2.0 ,
280305 number_of_copies_in_output = 4 ,
281306 # odt=True,
282307 # lloyd=True,
@@ -302,10 +327,10 @@ import pygalmesh
302327
303328mesh = pygalmesh.generate_volume_mesh_from_surface_mesh(
304329 " elephant.vtu" ,
305- facet_angle = 25.0 ,
306- facet_size = 0.15 ,
307- facet_distance = 0.008 ,
308- cell_radius_edge_ratio = 3.0 ,
330+ min_facet_angle = 25.0 ,
331+ max_radius_surface_delaunay_ball = 0.15 ,
332+ max_facet_distance = 0.008 ,
333+ max_circumradius_edge_ratio = 3.0 ,
309334 verbose = False ,
310335)
311336```
@@ -326,7 +351,7 @@ import pygalmesh
326351
327352mesh = pygalmesh.generate_from_inr(
328353 " skull_2.9.inr" ,
329- cell_size = 5.0 ,
354+ max_cell_circumradius = 5.0 ,
330355 verbose = False ,
331356)
332357```
@@ -357,7 +382,9 @@ with open("MergedPhantom.DAT", "rb") as fid:
357382
358383vol = vol.reshape((Nx, Ny, Nz))
359384
360- mesh = pygalmesh.generate_from_array(vol, h, facet_distance = 0.2 , cell_size = 1.0 )
385+ mesh = pygalmesh.generate_from_array(
386+ vol, h, max_facet_distance = 0.2 , max_cell_circumradius = 1.0
387+ )
361388mesh.write(" breast.vtk" )
362389```
363390
@@ -368,7 +395,10 @@ tissue (label `5`), and *2 mm* for all other tissues (`default`).
368395<!-- exdown-skip-->
369396``` python
370397mesh = pygalmesh.generate_from_array(
371- vol, h, facet_distance = 0.2 , cell_size = {" default" : 2.0 , 4 : 1.0 , 5 : 0.5 }
398+ vol,
399+ h,
400+ max_facet_distance = 0.2 ,
401+ max_cell_circumradius = {" default" : 2.0 , 4 : 1.0 , 5 : 0.5 },
372402)
373403mesh.write(" breast_adapted.vtk" )
374404```
@@ -391,10 +421,10 @@ import pygalmesh
391421
392422mesh = pygalmesh.remesh_surface(
393423 " lion-head.off" ,
394- edge_size = 0.025 ,
395- facet_angle = 25 ,
396- facet_size = 0.1 ,
397- facet_distance = 0.001 ,
424+ max_edge_size_at_feature_edges = 0.025 ,
425+ min_facet_angle = 25 ,
426+ max_radius_surface_delaunay_ball = 0.1 ,
427+ max_facet_distance = 0.001 ,
398428 verbose = False ,
399429)
400430```
0 commit comments