@@ -43,7 +43,7 @@ function triangulation_of_domain()
43
43
facet! (builder, p4, p5)
44
44
facet! (builder, p5, p1)
45
45
46
- builder
46
+ return builder
47
47
end
48
48
49
49
#
56
56
# We miss:
57
57
# - size control for the triangles
58
58
# - differently marking of boundary parts
59
- #
59
+ #
60
60
function nicer_triangulation_of_domain ()
61
61
builder = SimplexGridBuilder (; Generator = Triangulate)
62
62
@@ -77,7 +77,7 @@ function nicer_triangulation_of_domain()
77
77
78
78
options! (builder; maxvolume = 0.01 )
79
79
80
- builder
80
+ return builder
81
81
end
82
82
#
83
83
# 
@@ -117,7 +117,7 @@ function triangulation_of_domain_with_subregions()
117
117
maxvolume! (builder, 0.01 )
118
118
regionpoint! (builder, 0.2 , 0.2 )
119
119
120
- builder
120
+ return builder
121
121
end
122
122
#
123
123
# 
@@ -129,13 +129,15 @@ end
129
129
# the tedious and error prone counting connected
130
130
# with this approach.
131
131
function 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
+ )
139
141
end
140
142
#
141
143
# 
@@ -176,26 +178,26 @@ function square_localref()
176
178
end
177
179
end
178
180
options! (builder; unsuitable = unsuitable)
179
- builder
181
+ return builder
180
182
end
181
183
#
182
184
# 
183
185
#
184
186
185
187
# ## Domain with holes
186
188
# We can generate domains with holes.
187
- # This at once shall demonstrate how the chosen
189
+ # This at once shall demonstrate how the chosen
188
190
# API approach eases bookkeeping of features added to the
189
191
# geometry description
190
192
#
191
193
function swiss_cheese_2d ()
192
194
function circlehole! (builder, center, radius; n = 20 )
193
195
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 )
195
197
facet! (builder, points[i], points[i + 1 ])
196
198
end
197
199
facet! (builder, points[end ], points[1 ])
198
- holepoint! (builder, center)
200
+ return holepoint! (builder, center)
199
201
end
200
202
201
203
builder = SimplexGridBuilder (; Generator = Triangulate)
@@ -214,35 +216,37 @@ function swiss_cheese_2d()
214
216
facet! (builder, p3, p4)
215
217
facet! (builder, p4, p1)
216
218
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
+ ]'
237
241
238
242
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 ]
239
243
240
- for i = 1 : length (radii)
244
+ for i in 1 : length (radii)
241
245
facetregion! (builder, i + 1 )
242
246
circlehole! (builder, holes[:, i], radii[i])
243
247
end
244
248
245
- builder
249
+ return builder
246
250
end
247
251
#
248
252
# 
@@ -252,13 +256,13 @@ end
252
256
# ## Remeshing another grid
253
257
#
254
258
# The `bregions!` method allows to use another grid as geometry description
255
- #
259
+ #
256
260
function remesh_2d ()
257
261
b = SimplexGridBuilder (; Generator = Triangulate)
258
- X= 0 : 0.1 : 1
262
+ X = 0 : 0.1 : 1
259
263
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 )
262
266
end
263
267
#
264
268
# 
268
272
#
269
273
# The `bregions!` method allows to extract parts of the geometry description from
270
274
# an already existing grid.
271
- #
275
+ #
272
276
function glue_2d ()
273
277
b = SimplexGridBuilder (; Generator = Triangulate)
274
278
@@ -310,43 +314,42 @@ function glue_2d()
310
314
311
315
bregions! (b, grid1, 1 : 6 )
312
316
grid2 = simplexgrid (b; maxvolume = 0.6 )
313
- grid2 = glue (grid1, grid2)
317
+ return grid2 = glue (grid1, grid2)
314
318
end
315
319
#
316
320
# 
317
321
#
318
322
319
323
320
-
321
324
# Plot generation
322
325
using GridVisualize
323
326
function generateplots (picdir; Plotter = nothing )
324
- if isdefined (Plotter, :Makie )
327
+ return if isdefined (Plotter, :Makie )
325
328
size = (600 , 300 )
326
329
Plotter. activate! (; type = " png" , visible = false )
327
330
328
331
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
+
331
334
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
+
334
337
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)
336
339
337
340
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
+
340
343
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
+
343
346
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
+
346
349
p = gridplot (remesh_2d (); Plotter, size)
347
- Plotter. save (joinpath (picdir, " remesh_2d.png" ),p)
350
+ Plotter. save (joinpath (picdir, " remesh_2d.png" ), p)
348
351
349
352
p = gridplot (glue_2d (); Plotter, size)
350
- Plotter. save (joinpath (picdir, " glue_2d.png" ),p)
353
+ Plotter. save (joinpath (picdir, " glue_2d.png" ), p)
351
354
end
352
355
end
0 commit comments