@@ -43,7 +43,7 @@ function triangulation_of_domain()
4343 facet! (builder, p4, p5)
4444 facet! (builder, p5, p1)
4545
46- builder
46+ return builder
4747end
4848
4949#
5656# We miss:
5757# - size control for the triangles
5858# - differently marking of boundary parts
59- #
59+ #
6060function nicer_triangulation_of_domain ()
6161 builder = SimplexGridBuilder (; Generator = Triangulate)
6262
@@ -77,7 +77,7 @@ function nicer_triangulation_of_domain()
7777
7878 options! (builder; maxvolume = 0.01 )
7979
80- builder
80+ return builder
8181end
8282#
8383# 
@@ -117,7 +117,7 @@ function triangulation_of_domain_with_subregions()
117117 maxvolume! (builder, 0.01 )
118118 regionpoint! (builder, 0.2 , 0.2 )
119119
120- builder
120+ return builder
121121end
122122#
123123# 
@@ -129,13 +129,15 @@ end
129129# the tedious and error prone counting connected
130130# with this approach.
131131function direct_square (Generator = Triangulate)
132- simplexgrid (Generator;
133- points = [0 0 ; 0 1 ; 1 1 ; 1 0 ]' ,
134- bfaces = [1 2 ; 2 3 ; 3 4 ; 4 1 ]' ,
135- bfaceregions = [1 , 2 , 3 , 4 ],
136- regionpoints = [0.5 0.5 ;]' ,
137- regionnumbers = [1 ],
138- regionvolumes = [0.01 ])
132+ return simplexgrid (
133+ Generator;
134+ points = [0 0 ; 0 1 ; 1 1 ; 1 0 ]' ,
135+ bfaces = [1 2 ; 2 3 ; 3 4 ; 4 1 ]' ,
136+ bfaceregions = [1 , 2 , 3 , 4 ],
137+ regionpoints = [0.5 0.5 ;]' ,
138+ regionnumbers = [1 ],
139+ regionvolumes = [0.01 ]
140+ )
139141end
140142#
141143# 
@@ -176,26 +178,26 @@ function square_localref()
176178 end
177179 end
178180 options! (builder; unsuitable = unsuitable)
179- builder
181+ return builder
180182end
181183#
182184# 
183185#
184186
185187# ## Domain with holes
186188# We can generate domains with holes.
187- # This at once shall demonstrate how the chosen
189+ # This at once shall demonstrate how the chosen
188190# API approach eases bookkeeping of features added to the
189191# geometry description
190192#
191193function swiss_cheese_2d ()
192194 function circlehole! (builder, center, radius; n = 20 )
193195 points = [point! (builder, center[1 ] + radius * sin (t), center[2 ] + radius * cos (t)) for t in range (0 , 2 π; length = n)]
194- for i = 1 : (n - 1 )
196+ for i in 1 : (n - 1 )
195197 facet! (builder, points[i], points[i + 1 ])
196198 end
197199 facet! (builder, points[end ], points[1 ])
198- holepoint! (builder, center)
200+ return holepoint! (builder, center)
199201 end
200202
201203 builder = SimplexGridBuilder (; Generator = Triangulate)
@@ -214,35 +216,37 @@ function swiss_cheese_2d()
214216 facet! (builder, p3, p4)
215217 facet! (builder, p4, p1)
216218
217- holes = [8.0 4.0 ;
218- 1.0 2.0 ;
219- 8.0 9.0 ;
220- 3.0 4.0 ;
221- 4.0 6.0 ;
222- 7.0 9.0 ;
223- 4.0 7.0 ;
224- 7.0 5.0 ;
225- 2.0 1.0 ;
226- 4.0 1.0 ;
227- 4.0 8.0 ;
228- 2.0 8.0 ;
229- 3.0 6.0 ;
230- 4.0 9.0 ;
231- 9.0 1.0 ;
232- 9.0 1.0 ;
233- 6.0 9.0 ;
234- 8.0 9.0 ;
235- 3.0 5.0 ;
236- 1.0 4.0 ]'
219+ holes = [
220+ 8.0 4.0 ;
221+ 1.0 2.0 ;
222+ 8.0 9.0 ;
223+ 3.0 4.0 ;
224+ 4.0 6.0 ;
225+ 7.0 9.0 ;
226+ 4.0 7.0 ;
227+ 7.0 5.0 ;
228+ 2.0 1.0 ;
229+ 4.0 1.0 ;
230+ 4.0 8.0 ;
231+ 2.0 8.0 ;
232+ 3.0 6.0 ;
233+ 4.0 9.0 ;
234+ 9.0 1.0 ;
235+ 9.0 1.0 ;
236+ 6.0 9.0 ;
237+ 8.0 9.0 ;
238+ 3.0 5.0 ;
239+ 1.0 4.0
240+ ]'
237241
238242 radii = [0.15 , 0.15 , 0.1 , 0.35 , 0.2 , 0.3 , 0.1 , 0.4 , 0.1 , 0.4 , 0.4 , 0.15 , 0.2 , 0.2 , 0.2 , 0.35 , 0.15 , 0.25 , 0.15 , 0.25 ]
239243
240- for i = 1 : length (radii)
244+ for i in 1 : length (radii)
241245 facetregion! (builder, i + 1 )
242246 circlehole! (builder, holes[:, i], radii[i])
243247 end
244248
245- builder
249+ return builder
246250end
247251#
248252# 
@@ -252,13 +256,13 @@ end
252256# ## Remeshing another grid
253257#
254258# The `bregions!` method allows to use another grid as geometry description
255- #
259+ #
256260function remesh_2d ()
257261 b = SimplexGridBuilder (; Generator = Triangulate)
258- X= 0 : 0.1 : 1
262+ X = 0 : 0.1 : 1
259263 grid1 = simplexgrid (X, X)
260- bregions! (b,grid1)
261- simplexgrid (b,maxvolume= 0.01 )
264+ bregions! (b, grid1)
265+ return simplexgrid (b, maxvolume = 0.01 )
262266end
263267#
264268# 
268272#
269273# The `bregions!` method allows to extract parts of the geometry description from
270274# an already existing grid.
271- #
275+ #
272276function glue_2d ()
273277 b = SimplexGridBuilder (; Generator = Triangulate)
274278
@@ -310,43 +314,42 @@ function glue_2d()
310314
311315 bregions! (b, grid1, 1 : 6 )
312316 grid2 = simplexgrid (b; maxvolume = 0.6 )
313- grid2 = glue (grid1, grid2)
317+ return grid2 = glue (grid1, grid2)
314318end
315319#
316320# 
317321#
318322
319323
320-
321324# Plot generation
322325using GridVisualize
323326function generateplots (picdir; Plotter = nothing )
324- if isdefined (Plotter, :Makie )
327+ return if isdefined (Plotter, :Makie )
325328 size = (600 , 300 )
326329 Plotter. activate! (; type = " png" , visible = false )
327330
328331 p = builderplot (triangulation_of_domain (); Plotter, size)
329- Plotter. save (joinpath (picdir, " triangulation_of_domain.png" ),p)
330-
332+ Plotter. save (joinpath (picdir, " triangulation_of_domain.png" ), p)
333+
331334 p = builderplot (nicer_triangulation_of_domain (); Plotter, size)
332- Plotter. save (joinpath (picdir, " nicer_triangulation_of_domain.png" ),p)
333-
335+ Plotter. save (joinpath (picdir, " nicer_triangulation_of_domain.png" ), p)
336+
334337 p = builderplot (triangulation_of_domain_with_subregions (); Plotter, size)
335- Plotter. save (joinpath (picdir, " triangulation_of_domain_with_subregions.png" ),p)
338+ Plotter. save (joinpath (picdir, " triangulation_of_domain_with_subregions.png" ), p)
336339
337340 p = builderplot (square_localref (); Plotter, size)
338- Plotter. save (joinpath (picdir, " square_localref.png" ),p)
339-
341+ Plotter. save (joinpath (picdir, " square_localref.png" ), p)
342+
340343 p = gridplot (direct_square (); Plotter, size)
341- Plotter. save (joinpath (picdir, " direct_square.png" ),p)
342-
344+ Plotter. save (joinpath (picdir, " direct_square.png" ), p)
345+
343346 p = builderplot (swiss_cheese_2d (); Plotter, size)
344- Plotter. save (joinpath (picdir, " swiss_cheese_2d.png" ),p)
345-
347+ Plotter. save (joinpath (picdir, " swiss_cheese_2d.png" ), p)
348+
346349 p = gridplot (remesh_2d (); Plotter, size)
347- Plotter. save (joinpath (picdir, " remesh_2d.png" ),p)
350+ Plotter. save (joinpath (picdir, " remesh_2d.png" ), p)
348351
349352 p = gridplot (glue_2d (); Plotter, size)
350- Plotter. save (joinpath (picdir, " glue_2d.png" ),p)
353+ Plotter. save (joinpath (picdir, " glue_2d.png" ), p)
351354 end
352355end
0 commit comments