Skip to content

Commit 2e40849

Browse files
authored
Merge pull request #20 from WIAS-PDELib/jf/runic
Jf/runic
2 parents 465a044 + 0d31cd6 commit 2e40849

21 files changed

+433
-433
lines changed

.JuliaFormatter.toml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.github/workflows/format_check.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ repos:
1919
rev: v2.2.4
2020
hooks:
2121
- id: codespell
22+
- repo: https://github.com/fredrikekre/runic-pre-commit
23+
rev: v1.0.0
24+
hooks:
25+
- id: runic

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://WIAS-PDELib.github.io/SimplexGridFactory.jl/stable)
33
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://WIAS-PDELib.github.io/SimplexGridFactory.jl/dev)
44
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
5+
[![code style: runic](https://img.shields.io/badge/code_style-%E1%9A%B1%E1%9A%A2%E1%9A%BE%E1%9B%81%E1%9A%B2-black)](https://github.com/fredrikekre/Runic.jl)
56

67

78
SimplexGridFactory

docs/make.jl

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
using Documenter, SimplexGridFactory, ExtendableGrids
22
import PlutoSliderServer
33
using GridVisualize, ExampleJuggler
4-
ENV["MPLBACKEND"]= "agg"
4+
ENV["MPLBACKEND"] = "agg"
55
import CairoMakie, PyPlot
66
ExampleJuggler.verbose!(true)
77

88

9-
109
###zzaccessing
1110

1211
function mkdocs()
1312
cleanexamples()
1413
exampledir = joinpath(@__DIR__, "..", "examples")
1514
notebookdir = joinpath(@__DIR__, "..", "notebooks")
16-
cairo_examples = @docscripts(exampledir,["examples2d.jl"], Plotter=CairoMakie)
17-
pyplot_examples = @docscripts(exampledir,["examples3d.jl"], Plotter=PyPlot)
18-
19-
generated_examples=[cairo_examples..., pyplot_examples...]
20-
notebook_examples = @docplutonotebooks(notebookdir, ["gridgenvis.jl","cylinder.jl"], iframe=true, iframe_height="2000px")
21-
22-
23-
makedocs(; sitename = "SimplexGridFactory.jl",
24-
modules = [SimplexGridFactory],
25-
doctest = false,
26-
clean = false,
27-
authors = "J. Fuhrmann, Ch. Merdon",
28-
repo = "https://github.com/WIAS-PDELib/SimplexGridFactory.jl",
29-
pages = [
30-
"Home" => "index.md",
31-
"Changes" => "changes.md",
32-
"API" => "api.md",
33-
"Examples" => generated_examples,
34-
"Notebooks" => notebook_examples,
35-
"Internals" => "internals.md",
36-
"allindex.md",
37-
])
38-
39-
cleanexamples()
15+
cairo_examples = @docscripts(exampledir, ["examples2d.jl"], Plotter = CairoMakie)
16+
pyplot_examples = @docscripts(exampledir, ["examples3d.jl"], Plotter = PyPlot)
17+
18+
generated_examples = [cairo_examples..., pyplot_examples...]
19+
notebook_examples = @docplutonotebooks(notebookdir, ["gridgenvis.jl", "cylinder.jl"], iframe = true, iframe_height = "2000px")
20+
21+
22+
makedocs(;
23+
sitename = "SimplexGridFactory.jl",
24+
modules = [SimplexGridFactory],
25+
doctest = false,
26+
clean = false,
27+
authors = "J. Fuhrmann, Ch. Merdon",
28+
repo = "https://github.com/WIAS-PDELib/SimplexGridFactory.jl",
29+
pages = [
30+
"Home" => "index.md",
31+
"Changes" => "changes.md",
32+
"API" => "api.md",
33+
"Examples" => generated_examples,
34+
"Notebooks" => notebook_examples,
35+
"Internals" => "internals.md",
36+
"allindex.md",
37+
]
38+
)
39+
40+
return cleanexamples()
4041

4142
end
4243

examples/examples2d.jl

Lines changed: 61 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function triangulation_of_domain()
4343
facet!(builder, p4, p5)
4444
facet!(builder, p5, p1)
4545

46-
builder
46+
return builder
4747
end
4848

4949
#
@@ -56,7 +56,7 @@ end
5656
# We miss:
5757
# - size control for the triangles
5858
# - differently marking of boundary parts
59-
#
59+
#
6060
function 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
8181
end
8282
#
8383
# ![](nicer_triangulation_of_domain.png)
@@ -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
121121
end
122122
#
123123
# ![](triangulation_of_domain_with_subregions.png)
@@ -129,13 +129,15 @@ end
129129
# the tedious and error prone counting connected
130130
# with this approach.
131131
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+
)
139141
end
140142
#
141143
# ![](direct_square.png)
@@ -176,26 +178,26 @@ function square_localref()
176178
end
177179
end
178180
options!(builder; unsuitable = unsuitable)
179-
builder
181+
return builder
180182
end
181183
#
182184
# ![](square_localref.png)
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
#
191193
function 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
246250
end
247251
#
248252
# ![](swiss_cheese_2d.png)
@@ -252,13 +256,13 @@ end
252256
# ## Remeshing another grid
253257
#
254258
# The `bregions!` method allows to use another grid as geometry description
255-
#
259+
#
256260
function 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)
262266
end
263267
#
264268
# ![](remesh_2d.png)
@@ -268,7 +272,7 @@ end
268272
#
269273
# The `bregions!` method allows to extract parts of the geometry description from
270274
# an already existing grid.
271-
#
275+
#
272276
function 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)
314318
end
315319
#
316320
# ![](glue_2d.png)
317321
#
318322

319323

320-
321324
# Plot generation
322325
using GridVisualize
323326
function 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
352355
end

0 commit comments

Comments
 (0)