diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml
deleted file mode 100644
index 419b55a..0000000
--- a/.JuliaFormatter.toml
+++ /dev/null
@@ -1,7 +0,0 @@
-style = "sciml"
-pipe_to_function_call=false
-always_for_in = false
-separate_kwargs_with_semicolon = true
-margin = 132
-yas_style_nesting=true
-ignore = "examples/PlutoGridFactory.jl"
diff --git a/.github/workflows/format_check.yml b/.github/workflows/format_check.yml
deleted file mode 100644
index 70b4396..0000000
--- a/.github/workflows/format_check.yml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-name: format-check
-
-on:
- push:
- branches:
- - 'master'
- - 'release-'
- tags: '*'
- pull_request:
-
-jobs:
- build:
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- julia-version: [1.3.0]
- julia-arch: [x86]
- os: [ubuntu-latest]
- steps:
- - uses: julia-actions/setup-julia@latest
- with:
- version: ${{ matrix.julia-version }}
-
- - uses: actions/checkout@v4
- - name: Install JuliaFormatter and format
- # This will use the latest version by default but you can set the version like so:
- #
- # julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
- run: |
- julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
- julia -e 'using JuliaFormatter; format(".", verbose=true)'
- - name: Format check
- run: |
- julia -e '
- out = Cmd(`git diff --name-only`) |> read |> String
- if out == ""
- exit(0)
- else
- @error "Some files have not been formatted !!!"
- write(stdout, out)
- exit(1)
- end'
-
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 83a49f5..c1e860e 100755
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -19,3 +19,7 @@ repos:
rev: v2.2.4
hooks:
- id: codespell
+- repo: https://github.com/fredrikekre/runic-pre-commit
+ rev: v1.0.0
+ hooks:
+ - id: runic
diff --git a/README.md b/README.md
index 0467ab2..60c5924 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
[](https://WIAS-PDELib.github.io/SimplexGridFactory.jl/stable)
[](https://WIAS-PDELib.github.io/SimplexGridFactory.jl/dev)
[](https://github.com/JuliaTesting/Aqua.jl)
+[](https://github.com/fredrikekre/Runic.jl)
SimplexGridFactory
diff --git a/docs/make.jl b/docs/make.jl
index 5ebd54f..6c77acb 100644
--- a/docs/make.jl
+++ b/docs/make.jl
@@ -1,42 +1,43 @@
using Documenter, SimplexGridFactory, ExtendableGrids
import PlutoSliderServer
using GridVisualize, ExampleJuggler
-ENV["MPLBACKEND"]= "agg"
+ENV["MPLBACKEND"] = "agg"
import CairoMakie, PyPlot
ExampleJuggler.verbose!(true)
-
###zzaccessing
function mkdocs()
cleanexamples()
exampledir = joinpath(@__DIR__, "..", "examples")
notebookdir = joinpath(@__DIR__, "..", "notebooks")
- cairo_examples = @docscripts(exampledir,["examples2d.jl"], Plotter=CairoMakie)
- pyplot_examples = @docscripts(exampledir,["examples3d.jl"], Plotter=PyPlot)
-
- generated_examples=[cairo_examples..., pyplot_examples...]
- notebook_examples = @docplutonotebooks(notebookdir, ["gridgenvis.jl","cylinder.jl"], iframe=true, iframe_height="2000px")
-
-
- makedocs(; sitename = "SimplexGridFactory.jl",
- modules = [SimplexGridFactory],
- doctest = false,
- clean = false,
- authors = "J. Fuhrmann, Ch. Merdon",
- repo = "https://github.com/WIAS-PDELib/SimplexGridFactory.jl",
- pages = [
- "Home" => "index.md",
- "Changes" => "changes.md",
- "API" => "api.md",
- "Examples" => generated_examples,
- "Notebooks" => notebook_examples,
- "Internals" => "internals.md",
- "allindex.md",
- ])
-
- cleanexamples()
+ cairo_examples = @docscripts(exampledir, ["examples2d.jl"], Plotter = CairoMakie)
+ pyplot_examples = @docscripts(exampledir, ["examples3d.jl"], Plotter = PyPlot)
+
+ generated_examples = [cairo_examples..., pyplot_examples...]
+ notebook_examples = @docplutonotebooks(notebookdir, ["gridgenvis.jl", "cylinder.jl"], iframe = true, iframe_height = "2000px")
+
+
+ makedocs(;
+ sitename = "SimplexGridFactory.jl",
+ modules = [SimplexGridFactory],
+ doctest = false,
+ clean = false,
+ authors = "J. Fuhrmann, Ch. Merdon",
+ repo = "https://github.com/WIAS-PDELib/SimplexGridFactory.jl",
+ pages = [
+ "Home" => "index.md",
+ "Changes" => "changes.md",
+ "API" => "api.md",
+ "Examples" => generated_examples,
+ "Notebooks" => notebook_examples,
+ "Internals" => "internals.md",
+ "allindex.md",
+ ]
+ )
+
+ return cleanexamples()
end
diff --git a/examples/examples2d.jl b/examples/examples2d.jl
index 611a0b7..6e6f39e 100644
--- a/examples/examples2d.jl
+++ b/examples/examples2d.jl
@@ -43,7 +43,7 @@ function triangulation_of_domain()
facet!(builder, p4, p5)
facet!(builder, p5, p1)
- builder
+ return builder
end
#
@@ -56,7 +56,7 @@ end
# We miss:
# - size control for the triangles
# - differently marking of boundary parts
-#
+#
function nicer_triangulation_of_domain()
builder = SimplexGridBuilder(; Generator = Triangulate)
@@ -77,7 +77,7 @@ function nicer_triangulation_of_domain()
options!(builder; maxvolume = 0.01)
- builder
+ return builder
end
#
# 
@@ -117,7 +117,7 @@ function triangulation_of_domain_with_subregions()
maxvolume!(builder, 0.01)
regionpoint!(builder, 0.2, 0.2)
- builder
+ return builder
end
#
# 
@@ -129,13 +129,15 @@ end
# the tedious and error prone counting connected
# with this approach.
function direct_square(Generator = Triangulate)
- simplexgrid(Generator;
- points = [0 0; 0 1; 1 1; 1 0]',
- bfaces = [1 2; 2 3; 3 4; 4 1]',
- bfaceregions = [1, 2, 3, 4],
- regionpoints = [0.5 0.5;]',
- regionnumbers = [1],
- regionvolumes = [0.01])
+ return simplexgrid(
+ Generator;
+ points = [0 0; 0 1; 1 1; 1 0]',
+ bfaces = [1 2; 2 3; 3 4; 4 1]',
+ bfaceregions = [1, 2, 3, 4],
+ regionpoints = [0.5 0.5;]',
+ regionnumbers = [1],
+ regionvolumes = [0.01]
+ )
end
#
# 
@@ -176,7 +178,7 @@ function square_localref()
end
end
options!(builder; unsuitable = unsuitable)
- builder
+ return builder
end
#
# 
@@ -184,18 +186,18 @@ end
# ## Domain with holes
# We can generate domains with holes.
-# This at once shall demonstrate how the chosen
+# This at once shall demonstrate how the chosen
# API approach eases bookkeeping of features added to the
# geometry description
#
function swiss_cheese_2d()
function circlehole!(builder, center, radius; n = 20)
points = [point!(builder, center[1] + radius * sin(t), center[2] + radius * cos(t)) for t in range(0, 2π; length = n)]
- for i = 1:(n - 1)
+ for i in 1:(n - 1)
facet!(builder, points[i], points[i + 1])
end
facet!(builder, points[end], points[1])
- holepoint!(builder, center)
+ return holepoint!(builder, center)
end
builder = SimplexGridBuilder(; Generator = Triangulate)
@@ -214,35 +216,37 @@ function swiss_cheese_2d()
facet!(builder, p3, p4)
facet!(builder, p4, p1)
- holes = [8.0 4.0;
- 1.0 2.0;
- 8.0 9.0;
- 3.0 4.0;
- 4.0 6.0;
- 7.0 9.0;
- 4.0 7.0;
- 7.0 5.0;
- 2.0 1.0;
- 4.0 1.0;
- 4.0 8.0;
- 2.0 8.0;
- 3.0 6.0;
- 4.0 9.0;
- 9.0 1.0;
- 9.0 1.0;
- 6.0 9.0;
- 8.0 9.0;
- 3.0 5.0;
- 1.0 4.0]'
+ holes = [
+ 8.0 4.0;
+ 1.0 2.0;
+ 8.0 9.0;
+ 3.0 4.0;
+ 4.0 6.0;
+ 7.0 9.0;
+ 4.0 7.0;
+ 7.0 5.0;
+ 2.0 1.0;
+ 4.0 1.0;
+ 4.0 8.0;
+ 2.0 8.0;
+ 3.0 6.0;
+ 4.0 9.0;
+ 9.0 1.0;
+ 9.0 1.0;
+ 6.0 9.0;
+ 8.0 9.0;
+ 3.0 5.0;
+ 1.0 4.0
+ ]'
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]
- for i = 1:length(radii)
+ for i in 1:length(radii)
facetregion!(builder, i + 1)
circlehole!(builder, holes[:, i], radii[i])
end
- builder
+ return builder
end
#
# 
@@ -252,13 +256,13 @@ end
# ## Remeshing another grid
#
# The `bregions!` method allows to use another grid as geometry description
-#
+#
function remesh_2d()
b = SimplexGridBuilder(; Generator = Triangulate)
- X=0:0.1:1
+ X = 0:0.1:1
grid1 = simplexgrid(X, X)
- bregions!(b,grid1)
- simplexgrid(b,maxvolume=0.01)
+ bregions!(b, grid1)
+ return simplexgrid(b, maxvolume = 0.01)
end
#
# 
@@ -268,7 +272,7 @@ end
#
# The `bregions!` method allows to extract parts of the geometry description from
# an already existing grid.
-#
+#
function glue_2d()
b = SimplexGridBuilder(; Generator = Triangulate)
@@ -310,43 +314,42 @@ function glue_2d()
bregions!(b, grid1, 1:6)
grid2 = simplexgrid(b; maxvolume = 0.6)
- grid2 = glue(grid1, grid2)
+ return grid2 = glue(grid1, grid2)
end
#
# 
#
-
# Plot generation
using GridVisualize
function generateplots(picdir; Plotter = nothing)
- if isdefined(Plotter, :Makie)
+ return if isdefined(Plotter, :Makie)
size = (600, 300)
Plotter.activate!(; type = "png", visible = false)
p = builderplot(triangulation_of_domain(); Plotter, size)
- Plotter.save(joinpath(picdir, "triangulation_of_domain.png"),p)
-
+ Plotter.save(joinpath(picdir, "triangulation_of_domain.png"), p)
+
p = builderplot(nicer_triangulation_of_domain(); Plotter, size)
- Plotter.save(joinpath(picdir, "nicer_triangulation_of_domain.png"),p)
-
+ Plotter.save(joinpath(picdir, "nicer_triangulation_of_domain.png"), p)
+
p = builderplot(triangulation_of_domain_with_subregions(); Plotter, size)
- Plotter.save(joinpath(picdir, "triangulation_of_domain_with_subregions.png"),p)
+ Plotter.save(joinpath(picdir, "triangulation_of_domain_with_subregions.png"), p)
p = builderplot(square_localref(); Plotter, size)
- Plotter.save(joinpath(picdir, "square_localref.png"),p)
-
+ Plotter.save(joinpath(picdir, "square_localref.png"), p)
+
p = gridplot(direct_square(); Plotter, size)
- Plotter.save(joinpath(picdir, "direct_square.png"),p)
-
+ Plotter.save(joinpath(picdir, "direct_square.png"), p)
+
p = builderplot(swiss_cheese_2d(); Plotter, size)
- Plotter.save(joinpath(picdir, "swiss_cheese_2d.png"),p)
-
+ Plotter.save(joinpath(picdir, "swiss_cheese_2d.png"), p)
+
p = gridplot(remesh_2d(); Plotter, size)
- Plotter.save(joinpath(picdir, "remesh_2d.png"),p)
+ Plotter.save(joinpath(picdir, "remesh_2d.png"), p)
p = gridplot(glue_2d(); Plotter, size)
- Plotter.save(joinpath(picdir, "glue_2d.png"),p)
+ Plotter.save(joinpath(picdir, "glue_2d.png"), p)
end
end
diff --git a/examples/examples3d.jl b/examples/examples3d.jl
index 1cb1a88..b99f31d 100644
--- a/examples/examples3d.jl
+++ b/examples/examples3d.jl
@@ -49,7 +49,7 @@ function tetrahedralization_of_cube()
facetregion!(builder, 6)
facet!(builder, p4, p1, p5, p8)
- simplexgrid(builder; maxvolume = 0.001)
+ return simplexgrid(builder; maxvolume = 0.001)
end
# 
@@ -80,30 +80,28 @@ function tet_cube_with_primitives()
holepoint!(builder, (2, 7, 5))
sphere!(builder, (2, 7, 5), 1.5; nref = 3)
- simplexgrid(builder)
+ return simplexgrid(builder)
end
# 
-
# ## Remeshing another grid
#
# The `bregions!` method allows to use another grid as geometry description
-#
+#
function remesh_3d()
b = SimplexGridBuilder(; Generator = TetGen)
- X=0:0.1:1
+ X = 0:0.1:1
grid1 = simplexgrid(X, X, X)
- bregions!(b,grid1)
- simplexgrid(b,maxvolume=0.0001)
+ bregions!(b, grid1)
+ return simplexgrid(b, maxvolume = 0.0001)
end
#
# 
#
-
# ## Glue-in of existing grid
#
# The [`bregions!`](@ref) method allows to extract parts of the geometry description from
@@ -122,14 +120,14 @@ function glue_3d()
grid3 = simplexgrid(X, X, Z)
b = SimplexGridBuilder(; Generator = TetGen)
- bregions!(b, g0, 1:6; facetregions = [8 for i = 1:7])
+ bregions!(b, g0, 1:6; facetregions = [8 for i in 1:7])
cellregion!(b, 2)
regionpoint!(b, (-1, -1, -1))
bregions!(b, grid3, 1:6)
holepoint!(b, (5, 5, 2))
gouter = simplexgrid(b; maxvolume = 0.4, nosteiner = true)
- glue(gouter, grid3; g1regions = 1:6, interface = 7)
+ return glue(gouter, grid3; g1regions = 1:6, interface = 7)
end
#
# 
@@ -145,36 +143,35 @@ function stl_3d()
b = SimplexGridBuilder(; Generator = TetGen)
facetregion!(b, 2)
model3d!(b, modelfile; scale = 1 / 100, translate = (1, 1, 1), cellregion = 3)
- simplexgrid(b; maxvolume = 1.0e-2)
+ return simplexgrid(b; maxvolume = 1.0e-2)
end
#
# 
#
-
# Plot generation
using GridVisualize
function generateplots(picdir; Plotter = nothing)
- if isdefined(Plotter, :gcf)
- size=(300,300)
+ return if isdefined(Plotter, :gcf)
+ size = (300, 300)
Plotter.clf()
gridplot(tetrahedralization_of_cube(); Plotter, size, zplane = 0.5)
Plotter.savefig(joinpath(picdir, "tetrahedralization_of_cube.png"))
-
+
Plotter.clf()
gridplot(tet_cube_with_primitives(); Plotter, size, zplane = 5, azim = 47, elev = 80, interior = false)
Plotter.savefig(joinpath(picdir, "tet_cube_with_primitives.png"))
-
+
Plotter.clf()
gridplot(glue_3d(); Plotter, size, azim = 0, elev = 15, xplanes = [5])
Plotter.savefig(joinpath(picdir, "glue_3d.png"))
-
+
Plotter.clf()
gridplot(remesh_3d(); Plotter, size, zplanes = [0.5])
Plotter.savefig(joinpath(picdir, "remesh_3d.png"))
-
+
Plotter.clf()
gridplot(stl_3d(); Plotter, size, xplanes = [5])
Plotter.savefig(joinpath(picdir, "stl_3d.png"))
diff --git a/examples/zzaccessing.jl b/examples/zzaccessing.jl
index 557bd13..38bad57 100644
--- a/examples/zzaccessing.jl
+++ b/examples/zzaccessing.jl
@@ -30,7 +30,7 @@ function extract_2d()
@show grid[CellRegions]
@show grid[BFaceNodes]
@show grid[BFaceRegions]
- grid
+ return grid
end
# The output of this call is this:
# ```julia
diff --git a/notebooks/cylinder.jl b/notebooks/cylinder.jl
index 99f2ba5..15fb122 100644
--- a/notebooks/cylinder.jl
+++ b/notebooks/cylinder.jl
@@ -8,15 +8,15 @@ using InteractiveUtils
begin
import Pkg as _Pkg
haskey(ENV, "PLUTO_PROJECT") && _Pkg.activate(ENV["PLUTO_PROJECT"])
- #using Revise
- using ExtendableGrids
- using SimplexGridFactory
- using GridVisualize
- using Triangulate
- using PlutoVista
- using VoronoiFVM
- default_plotter!(PlutoVista)
- _Pkg.status()
+ #using Revise
+ using ExtendableGrids
+ using SimplexGridFactory
+ using GridVisualize
+ using Triangulate
+ using PlutoVista
+ using VoronoiFVM
+ default_plotter!(PlutoVista)
+ _Pkg.status()
end
# ╔═╡ 732e7d64-0b14-409b-9776-c222951bd79f
@@ -28,14 +28,14 @@ We want to have grid refinement towards the vall in order to be eventually able
# ╔═╡ 84d3f058-3838-4c38-afc5-f2ea30fb9bb6
begin
- nref=2 # refinement level
- rad=1 # outer radius
- rad_inner=0.5*rad # inner radius - transition between ring and inner part
- hmin=rad*0.025*2.0^(-nref) # smallest radial grid size (close to wall)
- hmax=rad*0.25*2.0^(-nref) # largest radial grid size
- nang=15*2^(nref)|>ceil|>Int # resolution in angular direction
- len=10 # length of cylinder
- nz=len*2^nref+1 |>ceil |>Int # resolution in length direction
+ nref = 2 # refinement level
+ rad = 1 # outer radius
+ rad_inner = 0.5 * rad # inner radius - transition between ring and inner part
+ hmin = rad * 0.025 * 2.0^(-nref) # smallest radial grid size (close to wall)
+ hmax = rad * 0.25 * 2.0^(-nref) # largest radial grid size
+ nang = 15 * 2^(nref) |> ceil |> Int # resolution in angular direction
+ len = 10 # length of cylinder
+ nz = len * 2^nref + 1 |> ceil |> Int # resolution in length direction
end
# ╔═╡ 08c71069-4ecb-450c-a905-ca6e7a62ac88
@@ -44,13 +44,13 @@ md"""
"""
# ╔═╡ ea4d6975-bbf9-4b72-b3df-aa4d1faea6c7
-R=geomspace(rad_inner,rad,hmax,hmin)
+R = geomspace(rad_inner, rad, hmax, hmin)
# ╔═╡ a5120dd7-4442-4f87-90c0-bdbce949cd31
-Φ=range(0,2π,length=nang)
+Φ = range(0, 2π, length = nang)
# ╔═╡ 364db500-712e-4b02-b124-1fa005e53e8e
-g_ring=ringsector(R,Φ)
+g_ring = ringsector(R, Φ)
# ╔═╡ f4c5efff-d36a-445c-b59d-abfdc5690212
gridplot(g_ring)
@@ -82,21 +82,22 @@ point list.
# ╔═╡ 2638116e-d895-4099-a6e4-2a996512cb4a
begin
- b1=SimplexGridBuilder(Generator=Triangulate)
- coord=g_ring[Coordinates]
- for i=1:size(coord,2)
- p=point!(b1,coord[:,i])
- end
- bregions!(b1,g_ring)
- cellregion!(b1,1)
- regionpoint!(b1,0,-0.75)
- holepoint!(b1,0,0)
- g_ring2=simplexgrid(b1,
- confdelaunay=true, # Ensure Delaunay property
- minangle=1, # Minimum angle (degrees)
- nosteiner=true, # Disallow new points at the boundary
- quality=false, # Don't care about grid quality, focus on Delaunay
- )
+ b1 = SimplexGridBuilder(Generator = Triangulate)
+ coord = g_ring[Coordinates]
+ for i in 1:size(coord, 2)
+ p = point!(b1, coord[:, i])
+ end
+ bregions!(b1, g_ring)
+ cellregion!(b1, 1)
+ regionpoint!(b1, 0, -0.75)
+ holepoint!(b1, 0, 0)
+ g_ring2 = simplexgrid(
+ b1,
+ confdelaunay = true, # Ensure Delaunay property
+ minangle = 1, # Minimum angle (degrees)
+ nosteiner = true, # Disallow new points at the boundary
+ quality = false, # Don't care about grid quality, focus on Delaunay
+ )
end
# ╔═╡ 38db1757-2caa-4339-9aeb-177acb9d49a5
@@ -115,11 +116,11 @@ We insert the inner boundary of the ring as part of the geometry description.
# ╔═╡ a4dba614-5955-4a02-afcd-c41160c352ea
begin
- b=SimplexGridBuilder(; Generator = Triangulate)
- bregions!(b,g_ring2,[1])
- cellregion!(b,1)
- regionpoint!(b,0,0)
- g_disk=simplexgrid(b,maxvolume=hmax^2/2,nosteiner=true, confdelunay=true)
+ b = SimplexGridBuilder(; Generator = Triangulate)
+ bregions!(b, g_ring2, [1])
+ cellregion!(b, 1)
+ regionpoint!(b, 0, 0)
+ g_disk = simplexgrid(b, maxvolume = hmax^2 / 2, nosteiner = true, confdelunay = true)
end
# ╔═╡ f91c6948-9228-4a8c-8aff-0c62bd5007b5
@@ -134,13 +135,13 @@ md"""
"""
# ╔═╡ 3ef68de0-1f52-46a7-8e20-a6f001060d9e
-g_base=glue(g_ring2,g_disk,g1regions=[1],naive=false,strict=true)
+g_base = glue(g_ring2, g_disk, g1regions = [1], naive = false, strict = true)
# ╔═╡ 8922be39-5e1b-4cbe-82c9-cccd5fc34160
gridplot(g_base)
# ╔═╡ ac343bed-c301-4aa7-9a5e-331f6f01b119
-nondelaunay(g_base, tol=-1.0e-17)
+nondelaunay(g_base, tol = -1.0e-17)
# ╔═╡ 436a74ae-148b-4c8f-b789-04fee27605f3
md"""
@@ -148,16 +149,16 @@ md"""
"""
# ╔═╡ 088314ef-3896-4826-b1d2-53cdd9c1f4ea
-Z=range(0,len,length=nz)
+Z = range(0, len, length = nz)
# ╔═╡ f13783f1-73db-474d-82d4-da57ca91220c
-g_cyl=simplexgrid(g_base,Z,top_offset=2)
+g_cyl = simplexgrid(g_base, Z, top_offset = 2)
# ╔═╡ 8027688a-600f-477c-a581-6bd785a517d6
-gridplot(g_cyl, Plotter=PlutoVista, zplanes=[5])
+gridplot(g_cyl, Plotter = PlutoVista, zplanes = [5])
# ╔═╡ 56502247-0d07-4cba-8a77-d1e02b8195fb
-nondelaunay(g_cyl,tol=1.0e-14)
+nondelaunay(g_cyl, tol = 1.0e-14)
# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
diff --git a/notebooks/gluein.jl b/notebooks/gluein.jl
index 6167937..ed68bcb 100644
--- a/notebooks/gluein.jl
+++ b/notebooks/gluein.jl
@@ -95,8 +95,10 @@ begin
grid3_1 = simplexgrid(X, X, Z1)
cellmask!(grid3_1, [0, 0, 0], [10, 10, 4], 2)
grid3_2 = simplexgrid(X, X, Z2)
- grid3 = glue(grid3_1, grid3_2;
- interface = 7, g1regions = [6], g2regions = [5])
+ grid3 = glue(
+ grid3_1, grid3_2;
+ interface = 7, g1regions = [6], g2regions = [5]
+ )
end
# ╔═╡ 11ca5bdf-6cf0-4e6d-bf76-7a6aec0b7d42
@@ -265,14 +267,14 @@ function glue_3d()
grid3 = simplexgrid(X, X, Z)
b = SimplexGridBuilder(; Generator = TetGen)
- bregions!(b, g0, 1:6; facetregions = [8 for i = 1:7])
+ bregions!(b, g0, 1:6; facetregions = [8 for i in 1:7])
cellregion!(b, 2)
regionpoint!(b, (-1, -1, -1))
bregions!(b, grid3, 1:6)
holepoint!(b, (5, 5, 2))
gouter = simplexgrid(b; maxvolume = 0.4, nosteiner = true)
- glue(gouter, grid3; interface = 7)
+ return glue(gouter, grid3; interface = 7)
end
# ╔═╡ 816401f3-d9fb-427b-b595-8dbd055cee5f
diff --git a/notebooks/gridgenvis.jl b/notebooks/gridgenvis.jl
index c835028..a123de9 100644
--- a/notebooks/gridgenvis.jl
+++ b/notebooks/gridgenvis.jl
@@ -6,8 +6,12 @@ using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
- quote
- local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
+ return quote
+ local iv = try
+ Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value
+ catch
+ b -> missing
+ end
local el = $(esc(element))
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el)
el
@@ -19,11 +23,11 @@ begin
import Pkg as _Pkg
haskey(ENV, "PLUTO_PROJECT") && _Pkg.activate(ENV["PLUTO_PROJECT"])
using SimplexGridFactory, GridVisualize, ExtendableGrids
- import Triangulate, TetGen
- using PlutoUI
- using PlutoVista
- import CairoMakie
- default_plotter!(CairoMakie)
+ import Triangulate, TetGen
+ using PlutoUI
+ using PlutoVista
+ import CairoMakie
+ default_plotter!(CairoMakie)
end;
# ╔═╡ 940b1996-fe9d-11ea-2fa4-8b72bee62b76
@@ -112,8 +116,8 @@ Two support methods are provided for this purpose.
# ╔═╡ 2d5cb9e1-2d14-415e-b792-c3124901011d
begin
- hmin = 0.01;
- hmax = 0.1;
+ hmin = 0.01
+ hmax = 0.1
end
# ╔═╡ b1f903b3-29d7-4909-b7e2-8ef3528c9965
@@ -169,8 +173,10 @@ let
scalarplot!(vis, g1d2, fsinh; label = "sinh", markershape = :dtriangle, color = :red, markevery = 5, clear = false)
- scalarplot!(vis, g1d2, fcos; label = "cos", markershape = :xcross, color = :green, linestyle = :dash, clear = false,
- markevery = 20)
+ scalarplot!(
+ vis, g1d2, fcos; label = "cos", markershape = :xcross, color = :green, linestyle = :dash, clear = false,
+ markevery = 20
+ )
scalarplot!(vis, g1d2, fsin; label = "sin", markershape = :none, color = :blue, linestyle = :dot, clear = false, markevery = 20)
@@ -288,7 +294,7 @@ function unsuitable(x1, y1, x2, y2, x3, y3, area)
dx = bary_x - refinement_center[1]
dy = bary_y - refinement_center[2]
qdist = dx^2 + dy^2
- area > 0.1 * max(1.0e-2, qdist)
+ return area > 0.1 * max(1.0e-2, qdist)
end;
# ╔═╡ 1ae86964-fe9e-11ea-303b-65bb128384a5
@@ -369,7 +375,7 @@ __Testplot with input and output__
"""
# ╔═╡ 8f0bd5c0-f920-11ea-3b1c-db90fc95f990
-builderplot(builder3; size = (750, 700), Plotter=CairoMakie)
+builderplot(builder3; size = (750, 700), Plotter = CairoMakie)
# ╔═╡ d2129483-285b-49a2-a11d-886956146b85
md"""
@@ -442,10 +448,10 @@ z=$(@bind zplane Slider(X3[1]:0.1:X3[end],default=X3[end],show_value=true))
# ╔═╡ 3b14e5ba-353d-45de-9851-8ddbf2c410a5
let
- vis3 = GridVisualizer(; dim=3,layout = (1, 2), resolution = (600, 300),Plotter=PlutoVista)
+ vis3 = GridVisualizer(; dim = 3, layout = (1, 2), resolution = (600, 300), Plotter = PlutoVista)
gridplot!(vis3[1, 1], grid3d1; zplane = zplane, yplane = yplane, xplane = xplane)
- scalarplot!(vis3[1, 2], grid3d1, func3; zplane = zplane, yplane = yplane, xplane = xplane, flevel = flevel)
- reveal(vis3)
+ scalarplot!(vis3[1, 2], grid3d1, func3; zplane = zplane, yplane = yplane, xplane = xplane, flevel = flevel)
+ reveal(vis3)
end
# ╔═╡ 6cad87eb-1c59-4000-b688-a6f6d41f9413
@@ -509,7 +515,7 @@ end;
grid3d2 = simplexgrid(builder3d; maxvolume = 0.001)
# ╔═╡ 329992a0-e352-468b-af8b-0b190315fc61
-gridplot(grid3d2; zplane = 0.5, azim = 20, elev = 60, linewidth = 0.5,Plotter=PlutoVista)
+gridplot(grid3d2; zplane = 0.5, azim = 20, elev = 60, linewidth = 0.5, Plotter = PlutoVista)
# ╔═╡ a7965a6e-2e83-47eb-aee2-d366246a8637
html"""
"""
diff --git a/src/SimplexGridFactory.jl b/src/SimplexGridFactory.jl
index b122c1e..f87d692 100644
--- a/src/SimplexGridFactory.jl
+++ b/src/SimplexGridFactory.jl
@@ -1,7 +1,7 @@
"""
SimplexGridFactory
-$(read(joinpath(@__DIR__,"..","README.md"),String))
+$(read(joinpath(@__DIR__, "..", "README.md"), String))
"""
module SimplexGridFactory
diff --git a/src/options.jl b/src/options.jl
index 963a4bc..fb8a7b4 100644
--- a/src/options.jl
+++ b/src/options.jl
@@ -39,23 +39,25 @@ The `unsuitable` parameter should be a function, see
[`triunsuitable!`](https://juliageometry.github.io/TetGen.jl/stable/#TetGen.triunsuitable!-Tuple{Function}) .
"""
-default_options() = Dict{Symbol, Any}(:PLC => true,
- :refine => false,
- :quality => true,
- :minangle => 20,
- :volumecontrol => true,
- :maxvolume => Inf,
- :attributes => true,
- :confdelaunay => true,
- :optlevel => 1,
- :nosteiner => false,
- :quiet => true,
- :verbose => false,
- :debugfacets => true,
- :check => false,
- :unsuitable => nothing,
- :flags => nothing,
- :addflags => "")
+default_options() = Dict{Symbol, Any}(
+ :PLC => true,
+ :refine => false,
+ :quality => true,
+ :minangle => 20,
+ :volumecontrol => true,
+ :maxvolume => Inf,
+ :attributes => true,
+ :confdelaunay => true,
+ :optlevel => 1,
+ :nosteiner => false,
+ :quiet => true,
+ :verbose => false,
+ :debugfacets => true,
+ :check => false,
+ :unsuitable => nothing,
+ :flags => nothing,
+ :addflags => ""
+)
function blendoptions!(opt; kwargs...)
for (k, v) in kwargs
@@ -71,11 +73,11 @@ function blendoptions!(opt; kwargs...)
end
end
end
- opt
+ return opt
end
function makeflags(options, mesher)
- if isnothing(options[:flags])
+ return if isnothing(options[:flags])
flags = ""
options[:PLC] ? flags *= "p" : nothing
options[:refine] ? flags *= "r" : nothing
diff --git a/src/plot.jl b/src/plot.jl
index 01f637b..3af304d 100644
--- a/src/plot.jl
+++ b/src/plot.jl
@@ -1,4 +1,3 @@
-
"""
$(TYPEDSIGNATURES)
@@ -45,5 +44,5 @@ function builderplot(builder::SimplexGridBuilder, Plotter::Module; size = (650,
if Triangulate.ismakie(Plotter)
figure = Plotter.Figure(; size)
end
- Triangulate.plot_in_out(Plotter, triin, triout; figure)
+ return Triangulate.plot_in_out(Plotter, triin, triout; figure)
end
diff --git a/src/primitives.jl b/src/primitives.jl
index cd65508..76abd9a 100644
--- a/src/primitives.jl
+++ b/src/primitives.jl
@@ -7,11 +7,11 @@ Add points and facets approximating a circle.
"""
function circle!(builder::SimplexGridBuilder, center, radius; n = 20)
points = [point!(builder, center[1] + radius * sin(t), center[2] + radius * cos(t)) for t in range(0, 2π; length = n)]
- for i = 1:(n - 1)
+ for i in 1:(n - 1)
facet!(builder, points[i], points[i + 1])
end
facet!(builder, points[end], points[1])
- builder
+ return builder
end
"""
@@ -29,16 +29,15 @@ bregions!(builder,grid, 1=>2, 3=>5)
```
"""
function bregions!(builder::SimplexGridBuilder, grid, pairs...)
- if length([pairs...])>0
+ return if length([pairs...]) > 0
bregions!(builder, grid, first.([pairs...]); facetregions = last.([pairs...]))
else
- cr=unique(grid[BFaceRegions])
- bregions!(builder, grid, cr; facetregions=cr)
+ cr = unique(grid[BFaceRegions])
+ bregions!(builder, grid, cr; facetregions = cr)
end
end
-
"""
```
bregions!(builder::SimplexGridBuilder,grid,regionlist;facetregions=nothing)
@@ -60,7 +59,7 @@ function bregions!(builder::SimplexGridBuilder, grid, regionlist::AbstractArray;
bfregions = grid[BFaceRegions]
nfacets = 0
- for ibface = 1:size(bfnodes, 2)
+ for ibface in 1:size(bfnodes, 2)
ireg = findfirst(i -> i == bfregions[ibface], regionlist)
if ireg != nothing
if dim_space(builder) == 2
@@ -84,7 +83,7 @@ function bregions!(builder::SimplexGridBuilder, grid, regionlist::AbstractArray;
end
end
@info "bregions!: added $nfacets facets to builder"
- facetregion!(builder, save_facetregion)
+ return facetregion!(builder, save_facetregion)
end
"""
@@ -111,7 +110,7 @@ function rect2d!(builder::SimplexGridBuilder, PA, PB; facetregions = nothing, nx
p01 = point!(builder, PA[1], PB[2])
x = range(PA[1], PB[1]; length = nx + 1)
- for i = 1:nx
+ for i in 1:nx
facetregion!(builder, facetregions[1])
p1 = point!(builder, x[i], PA[2])
p2 = point!(builder, x[i + 1], PA[2])
@@ -124,7 +123,7 @@ function rect2d!(builder::SimplexGridBuilder, PA, PB; facetregions = nothing, nx
end
y = range(PA[2], PB[2]; length = ny + 1)
- for i = 1:ny
+ for i in 1:ny
facetregion!(builder, facetregions[2])
p1 = point!(builder, PB[1], y[i])
p2 = point!(builder, PB[1], y[i + 1])
@@ -137,7 +136,7 @@ function rect2d!(builder::SimplexGridBuilder, PA, PB; facetregions = nothing, nx
end
facetregion!(builder, save_facetregion)
- builder
+ return builder
end
"""
@@ -180,7 +179,7 @@ function rect3d!(builder::SimplexGridBuilder, PA, PB; facetregions = nothing)
facetregion!(builder, facetregions[6])
facet!(builder, p4, p1, p5, p8)
facetregion!(builder, save_facetregion)
- builder
+ return builder
end
function refine(coord, tri)
@@ -198,7 +197,7 @@ function refine(coord, tri)
newtri = ElasticArray{Cint}(undef, 3, 0)
istop = size(coord, 2)
ntri = size(tri, 2)
- @views for itri = 1:ntri
+ @views for itri in 1:ntri
i1 = tri[1, itri]
i2 = tri[2, itri]
i3 = tri[3, itri]
@@ -216,7 +215,7 @@ function refine(coord, tri)
append!(newtri, (i3, i23, i13))
append!(newtri, (i12, i13, i23))
end
- coord, newtri
+ return coord, newtri
end
"""
@@ -230,33 +229,39 @@ function sphere!(builder::SimplexGridBuilder, center, radius; nref = 3)
# Initial octahedron
q = 1.0 / sqrt(2)
- coord = ElasticArray([-q -q 0;
- -q q 0;
- q q 0;
- q -q 0;
- 0 0 -1;
- 0 0 1]')
-
- tri = [1 2 5;
- 2 3 5;
- 3 4 5;
- 4 1 5;
- 1 2 6;
- 2 3 6;
- 3 4 6;
- 4 1 6]'
-
- for iref = 1:nref
+ coord = ElasticArray(
+ [
+ -q -q 0;
+ -q q 0;
+ q q 0;
+ q -q 0;
+ 0 0 -1;
+ 0 0 1
+ ]'
+ )
+
+ tri = [
+ 1 2 5;
+ 2 3 5;
+ 3 4 5;
+ 4 1 5;
+ 1 2 6;
+ 2 3 6;
+ 3 4 6;
+ 4 1 6
+ ]'
+
+ for iref in 1:nref
coord, tri = refine(coord, tri)
end
- @views pts = [point!(builder, (radius * coord[:, i] .+ center)) for i = 1:size(coord, 2)]
+ @views pts = [point!(builder, (radius * coord[:, i] .+ center)) for i in 1:size(coord, 2)]
- for i = 1:size(tri, 2)
+ for i in 1:size(tri, 2)
facet!(builder, pts[tri[1, i]], pts[tri[2, i]], pts[tri[3, i]])
end
- builder
+ return builder
end
"""
@@ -352,7 +357,7 @@ Load 3D model from file. File formats are those supported by [MeshIO.jl](https:
"""
function model3d!(builder, filename::String; translate = (0, 0, 0), scale = 1.0, cellregion = 0, hole = false)
mesh = load(filename)
- mesh3d!(builder, mesh; translate, scale, cellregion, hole, filename)
+ return mesh3d!(builder, mesh; translate, scale, cellregion, hole, filename)
end
"""
@@ -373,32 +378,32 @@ function mesh3d!(builder, mesh; translate = (0, 0, 0), scale = 1.0, cellregion =
for ngon in mesh
npts = length(ngon)
- for i = 1:npts
+ for i in 1:npts
p[1] = scale[1] * ngon[i][1] + translate[1]
p[2] = scale[2] * ngon[i][2] + translate[2]
p[3] = scale[3] * ngon[i][3] + translate[3]
pbary .+= p
- pmax[1]=max(pmax[1],p[1])
- pmax[2]=max(pmax[2],p[2])
- pmax[3]=max(pmax[3],p[3])
- pmin[1]=min(pmin[1],p[1])
- pmin[2]=min(pmin[2],p[2])
- pmin[3]=min(pmin[3],p[3])
+ pmax[1] = max(pmax[1], p[1])
+ pmax[2] = max(pmax[2], p[2])
+ pmax[3] = max(pmax[3], p[3])
+ pmin[1] = min(pmin[1], p[1])
+ pmin[2] = min(pmin[2], p[2])
+ pmin[3] = min(pmin[3], p[3])
ngonpoints[i] = point!(builder, p)
end
facet!(builder, view(ngonpoints, 1:npts)...)
end
pbary ./= 3 * length(mesh)
msg = "loaded model from $(filename)"
- msg *= ", added $(length(mesh)) facets in [ $(round.(pmin,digits=5)), $(round.(pmax,digits=5))]"
+ msg *= ", added $(length(mesh)) facets in [ $(round.(pmin, digits = 5)), $(round.(pmax, digits = 5))]"
if hole
holepoint!(builder, pbary)
- msg *= ", added holepoint $(round.(pbary,digits=5))"
+ msg *= ", added holepoint $(round.(pbary, digits = 5))"
elseif cellregion > 0
cellregion!(builder, cellregion)
regionpoint!(builder, pbary)
- msg *= ", added cellregion $cellregion, regionpoint $(round.(pbary,digits=5))"
+ msg *= ", added cellregion $cellregion, regionpoint $(round.(pbary, digits = 5))"
end
@info msg
- nothing
+ return nothing
end
diff --git a/src/simplexgrid.jl b/src/simplexgrid.jl
index 77035d9..5ba1ea8 100644
--- a/src/simplexgrid.jl
+++ b/src/simplexgrid.jl
@@ -21,31 +21,37 @@ corresponds to the space dimension.
See [`default_options`](@ref) for available `kwargs`.
"""
-function ExtendableGrids.simplexgrid(Generator::Module;
- points = Array{Cdouble, 2}(undef, 0, 0),
- bfaces = Array{Cint, 2}(undef, 0, 0),
- bfaceregions = Array{Cint, 1}(undef, 0),
- regionpoints = Array{Cdouble, 2}(undef, 0, 0),
- regionnumbers = Array{Cint, 1}(undef, 0),
- regionvolumes = Array{Cdouble, 1}(undef, 0),
- kwargs...)
+function ExtendableGrids.simplexgrid(
+ Generator::Module;
+ points = Array{Cdouble, 2}(undef, 0, 0),
+ bfaces = Array{Cint, 2}(undef, 0, 0),
+ bfaceregions = Array{Cint, 1}(undef, 0),
+ regionpoints = Array{Cdouble, 2}(undef, 0, 0),
+ regionnumbers = Array{Cint, 1}(undef, 0),
+ regionvolumes = Array{Cdouble, 1}(undef, 0),
+ kwargs...
+ )
@warn "ExtendableGrids.simplexgrid(::Module; kwargs...) is deprecated"
- if size(points, 1) == 2
- tio = triangulateio(Generator; points = points,
- bfaces = bfaces,
- bfaceregions = bfaceregions,
- regionpoints = regionpoints,
- regionnumbers = regionnumbers,
- regionvolumes = regionvolumes)
+ return if size(points, 1) == 2
+ tio = triangulateio(
+ Generator; points = points,
+ bfaces = bfaces,
+ bfaceregions = bfaceregions,
+ regionpoints = regionpoints,
+ regionnumbers = regionnumbers,
+ regionvolumes = regionvolumes
+ )
ExtendableGrids.simplexgrid(TriangulateType, Generator, tio; kwargs...)
else
- tio = tetgenio(Generator;
- points = points,
- bfaces = bfaces,
- bfaceregions = bfaceregions,
- regionpoints = regionpoints,
- regionnumbers = regionnumbers,
- regionvolumes = regionvolumes)
+ tio = tetgenio(
+ Generator;
+ points = points,
+ bfaces = bfaces,
+ bfaceregions = bfaceregions,
+ regionpoints = regionpoints,
+ regionnumbers = regionnumbers,
+ regionvolumes = regionvolumes
+ )
ExtendableGrids.simplexgrid(TetGenType, Generator, tio; kwargs...)
end
end
diff --git a/src/simplexgridbuilder.jl b/src/simplexgridbuilder.jl
index 7899aac..873fa09 100644
--- a/src/simplexgridbuilder.jl
+++ b/src/simplexgridbuilder.jl
@@ -69,7 +69,7 @@ function SimplexGridBuilder(; Generator = nothing, tol = 1.0e-12, checkexisting
builder.options = default_options()
builder.checkexisting = checkexisting
builder._savedpoint = 0
- builder
+ return builder
end
"""
@@ -106,17 +106,17 @@ which can be used to set up facets with [`facet!`](@ref).
"""
function point!(builder::SimplexGridBuilder, x)
dim_space(builder) == 1 || throw(DimensionMismatch())
- insert!(builder.pointlist, [x])
+ return insert!(builder.pointlist, [x])
end
function point!(builder::SimplexGridBuilder, x, y)
dim_space(builder) == 2 || throw(DimensionMismatch())
- insert!(builder.pointlist, [x, y])
+ return insert!(builder.pointlist, [x, y])
end
function point!(builder::SimplexGridBuilder, x, y, z)
dim_space(builder) == 3 || throw(DimensionMismatch())
- insert!(builder.pointlist, [x, y, z])
+ return insert!(builder.pointlist, [x, y, z])
end
const PointCoord = Union{AbstractVector, Tuple}
@@ -164,21 +164,21 @@ function regionpoint!(builder::SimplexGridBuilder, x)
dim_space(builder) == 1 || throw(DimensionMismatch())
append!(builder.regionpoints, (x))
push!(builder.regionvolumes, builder.current_cellvolume)
- push!(builder.regionnumbers, builder.current_cellregion)
+ return push!(builder.regionnumbers, builder.current_cellregion)
end
function regionpoint!(builder::SimplexGridBuilder, x, y)
dim_space(builder) == 2 || throw(DimensionMismatch())
append!(builder.regionpoints, (x, y))
push!(builder.regionvolumes, builder.current_cellvolume)
- push!(builder.regionnumbers, builder.current_cellregion)
+ return push!(builder.regionnumbers, builder.current_cellregion)
end
function regionpoint!(builder::SimplexGridBuilder, x, y, z)
dim_space(builder) == 3 || throw(DimensionMismatch())
append!(builder.regionpoints, (x, y, z))
push!(builder.regionvolumes, builder.current_cellvolume)
- push!(builder.regionnumbers, builder.current_cellregion)
+ return push!(builder.regionnumbers, builder.current_cellregion)
end
regionpoint!(builder::SimplexGridBuilder, p::PointCoord) = regionpoint!(builder, p...)
@@ -198,7 +198,7 @@ function holepoint!(builder::SimplexGridBuilder, x)
append!(builder.regionpoints, (x))
push!(builder.regionvolumes, 0)
push!(builder.regionnumbers, 0)
- nothing
+ return nothing
end
function holepoint!(builder::SimplexGridBuilder, x, y)
@@ -206,7 +206,7 @@ function holepoint!(builder::SimplexGridBuilder, x, y)
append!(builder.regionpoints, (x, y))
push!(builder.regionvolumes, 0)
push!(builder.regionnumbers, 0)
- nothing
+ return nothing
end
function holepoint!(builder::SimplexGridBuilder, x, y, z)
@@ -214,7 +214,7 @@ function holepoint!(builder::SimplexGridBuilder, x, y, z)
append!(builder.regionpoints, (x, y, z))
push!(builder.regionvolumes, 0)
push!(builder.regionnumbers, 0)
- nothing
+ return nothing
end
holepoint!(builder::SimplexGridBuilder, p::PointCoord) = holepoint!(builder, p...)
@@ -250,28 +250,28 @@ function facet!(builder::SimplexGridBuilder, i)
dim_space(builder) == 1 || throw(DimensionMismatch())
push!(builder.facets, [i])
push!(builder.facetregions, builder.current_facetregion)
- length(builder.facets)
+ return length(builder.facets)
end
function facet!(builder::SimplexGridBuilder, i1, i2)
dim_space(builder) == 2 || throw(DimensionMismatch())
push!(builder.facets, [i1, i2])
push!(builder.facetregions, builder.current_facetregion)
- length(builder.facets)
+ return length(builder.facets)
end
function facet!(builder::SimplexGridBuilder, i1, i2, i3)
dim_space(builder) == 3 || throw(DimensionMismatch())
push!(builder.facets, [i1, i2, i3])
push!(builder.facetregions, builder.current_facetregion)
- length(builder.facets)
+ return length(builder.facets)
end
function facet!(builder::SimplexGridBuilder, i1, i2, i3, i4)
dim_space(builder) == 3 || throw(DimensionMismatch())
push!(builder.facets, [i1, i2, i3, i4])
push!(builder.facetregions, builder.current_facetregion)
- length(builder.facets)
+ return length(builder.facets)
end
function facet!(builder::SimplexGridBuilder, p::Union{Vector, Tuple})
@@ -286,12 +286,12 @@ function facet!(builder::SimplexGridBuilder, p::Union{Vector, Tuple})
end
push!(builder.facets, [p...])
push!(builder.facetregions, builder.current_facetregion)
- length(builder.facets)
+ return length(builder.facets)
end
facet!(builder::SimplexGridBuilder, p1::PointCoord, p2::PointCoord) = facet!(builder, point!(builder, p1), point!(builder, p2))
function facet!(builder::SimplexGridBuilder, p1::PointCoord, p2::PointCoord, p3::PointCoord)
- facet!(builder, point!(builder, p1), point!(builder, p2), point!(builder, p3))
+ return facet!(builder, point!(builder, p1), point!(builder, p2), point!(builder, p3))
end
"""
@@ -308,7 +308,7 @@ planar.
function polyfacet!(builder::SimplexGridBuilder, p::Union{Vector, Tuple})
push!(builder.facets, [p...])
push!(builder.facetregions, builder.current_facetregion)
- length(builder.facets)
+ return length(builder.facets)
end
"""
@@ -323,29 +323,31 @@ See [`default_options`](@ref) for available `kwargs`.
function ExtendableGrids.simplexgrid(builder::SimplexGridBuilder; kwargs...)
if dim_space(builder) == 2
facets = Array{Cint, 2}(undef, 2, length(builder.facets))
- for i = 1:length(builder.facets)
+ for i in 1:length(builder.facets)
facets[1, i] = builder.facets[i][1]
facets[2, i] = builder.facets[i][2]
end
- make_tio=triangulateio
- generator_type=TriangulateType
+ make_tio = triangulateio
+ generator_type = TriangulateType
else
facets = builder.facets
- make_tio= tetgenio
- generator_type=TetGenType
+ make_tio = tetgenio
+ generator_type = TetGenType
end
options = blendoptions!(copy(builder.options); kwargs...)
-
- tio = make_tio(builder.Generator;
- points = builder.pointlist.points,
- bfaces = facets,
- bfaceregions = builder.facetregions,
- regionpoints = builder.regionpoints,
- regionnumbers = builder.regionnumbers,
- regionvolumes = builder.regionvolumes)
-
- ExtendableGrids.simplexgrid(generator_type, builder.Generator, tio; options...)
+
+ tio = make_tio(
+ builder.Generator;
+ points = builder.pointlist.points,
+ bfaces = facets,
+ bfaceregions = builder.facetregions,
+ regionpoints = builder.regionpoints,
+ regionnumbers = builder.regionnumbers,
+ regionvolumes = builder.regionvolumes
+ )
+
+ return ExtendableGrids.simplexgrid(generator_type, builder.Generator, tio; options...)
end
"""
@@ -354,7 +356,7 @@ end
Return mesh generator specific flag string created from builder options.
"""
function flags(builder::SimplexGridBuilder)
- if istetgen(builder.Generator)
+ return if istetgen(builder.Generator)
makeflags(builder.options, :tetgen)
elseif istriangulate(builder.Generator)
makeflags(builder.options, :triangle)
@@ -386,9 +388,9 @@ function maybewatertight(this::SimplexGridBuilder; bregions = nothing)
nfacets = size(facets, 1)
ptmarkers = zeros(Int, npoints)
- for ifacet = 1:nfacets
+ for ifacet in 1:nfacets
if bfaceregions[ifacet] ∈ bregions
- for idim = 1:dim
+ for idim in 1:dim
ptmarkers[facets[ifacet][idim]] += 1
end
end
@@ -407,16 +409,16 @@ function maybewatertight(this::SimplexGridBuilder; bregions = nothing)
@info "Maybe description is watertight, but not sure"
else
@warn "Description is not watertight"
- for ifacet = 1:nfacets
+ for ifacet in 1:nfacets
if bfaceregions[ifacet] ∈ bregions
- for idim = 1:dim
+ for idim in 1:dim
pt = facets[ifacet][idim]
if ptmarkers[pt] < dim
- @warn "Dangling facet $ifacet (bregion $(bfaceregions[ifacet]), point $(points[:,pt])"
+ @warn "Dangling facet $ifacet (bregion $(bfaceregions[ifacet]), point $(points[:, pt])"
end
end
end
end
end
- maybe
+ return maybe
end
diff --git a/src/tetgen.jl b/src/tetgen.jl
index 09b73c3..271a613 100644
--- a/src/tetgen.jl
+++ b/src/tetgen.jl
@@ -21,7 +21,7 @@ function ExtendableGrids.simplexgrid(::Type{TetGenType}, TetGen, input; kwargs..
tetout = TetGen.tetrahedralize(input, flags)
- ExtendableGrids.simplexgrid(tetout)
+ return ExtendableGrids.simplexgrid(tetout)
end
"""
@@ -36,12 +36,14 @@ indicated in the defaults and the leading dimension of 2D arrays
corresponds to the space dimension.
"""
-function tetgenio(TetGen; points = Array{Cdouble, 2}(undef, 0, 0),
- bfaces = Array{Cint, 2}(undef, 0, 0),
- bfaceregions = Array{Cint, 1}(undef, 0),
- regionpoints = Array{Cdouble, 2}(undef, 0, 0),
- regionnumbers = Array{Cint, 1}(undef, 0),
- regionvolumes = Array{Cdouble, 1}(undef, 0))
+function tetgenio(
+ TetGen; points = Array{Cdouble, 2}(undef, 0, 0),
+ bfaces = Array{Cint, 2}(undef, 0, 0),
+ bfaceregions = Array{Cint, 1}(undef, 0),
+ regionpoints = Array{Cdouble, 2}(undef, 0, 0),
+ regionnumbers = Array{Cint, 1}(undef, 0),
+ regionvolumes = Array{Cdouble, 1}(undef, 0)
+ )
@assert ndims(points) == 2
if size(points, 2) == 3
points = transpose(points)
@@ -49,7 +51,7 @@ function tetgenio(TetGen; points = Array{Cdouble, 2}(undef, 0, 0),
if typeof(points) != Array{Cdouble, 2}
points = Array{Cdouble, 2}(points)
end
- @assert(size(points, 2)>2)
+ @assert(size(points, 2) > 2)
# if ndims(bfaces)==2
# if size(bfaces,2)==2
@@ -87,7 +89,7 @@ function tetgenio(TetGen; points = Array{Cdouble, 2}(undef, 0, 0),
nholes = 0
nregions = 0
- for i = 1:length(regionnumbers)
+ for i in 1:length(regionnumbers)
if regionnumbers[i] == 0
nholes += 1
else
@@ -100,7 +102,7 @@ function tetgenio(TetGen; points = Array{Cdouble, 2}(undef, 0, 0),
ihole = 1
iregion = 1
- for i = 1:length(regionnumbers)
+ for i in 1:length(regionnumbers)
if regionnumbers[i] == 0
holelist[1, ihole] = regionpoints[1, i]
holelist[2, ihole] = regionpoints[2, i]
@@ -129,7 +131,7 @@ function tetgenio(TetGen; points = Array{Cdouble, 2}(undef, 0, 0),
if size(holelist, 2) > 0
tio.holelist = holelist
end
- tio
+ return tio
end
"""
@@ -140,10 +142,12 @@ Create tetgen input from the current state of the builder.
function tetgenio(this::SimplexGridBuilder)
dim_space(this) = 3 || throw(error("dimension !=2 not implemented"))
- tetgenio(this.Generator; points = this.pointlist.points,
- bfaces = this.facets,
- bfaceregions = this.facetregions,
- regionpoints = this.regionpoints,
- regionnumbers = this.regionnumbers,
- regionvolumes = this.regionvolumes)
+ return tetgenio(
+ this.Generator; points = this.pointlist.points,
+ bfaces = this.facets,
+ bfaceregions = this.facetregions,
+ regionpoints = this.regionpoints,
+ regionnumbers = this.regionnumbers,
+ regionvolumes = this.regionvolumes
+ )
end
diff --git a/src/triangle.jl b/src/triangle.jl
index ab2f3f3..d9ae5c4 100644
--- a/src/triangle.jl
+++ b/src/triangle.jl
@@ -18,7 +18,7 @@ function ExtendableGrids.simplexgrid(::Type{TriangulateType}, Triangulate, input
end
triout, vorout = Triangulate.triangulate(flags, input)
- ExtendableGrids.simplexgrid(triout)
+ return ExtendableGrids.simplexgrid(triout)
end
"""
@@ -33,13 +33,15 @@ indicated in the defaults and the leading dimension of 2D arrays
corresponds to the space dimension.
"""
-function triangulateio(Triangulate;
- points = Array{Cdouble, 2}(undef, 0, 0),
- bfaces = Array{Cint, 2}(undef, 0, 0),
- bfaceregions = Array{Cint, 1}(undef, 0),
- regionpoints = Array{Cdouble, 2}(undef, 0, 0),
- regionnumbers = Array{Cint, 1}(undef, 0),
- regionvolumes = Array{Cdouble, 1}(undef, 0))
+function triangulateio(
+ Triangulate;
+ points = Array{Cdouble, 2}(undef, 0, 0),
+ bfaces = Array{Cint, 2}(undef, 0, 0),
+ bfaceregions = Array{Cint, 1}(undef, 0),
+ regionpoints = Array{Cdouble, 2}(undef, 0, 0),
+ regionnumbers = Array{Cint, 1}(undef, 0),
+ regionvolumes = Array{Cdouble, 1}(undef, 0)
+ )
ndims(points) == 2 || throw(DimensionMismatch("Wrong space dimension"))
if size(points, 2) == 2
points = transpose(points)
@@ -76,13 +78,13 @@ function triangulateio(Triangulate;
@assert ndims(regionnumbers) == 1 || throw(DimensionMismatch("regionnumbers must be vector"))
@assert ndims(regionvolumes) == 1 || throw(DimensionMismatch("regionvolumes must be vector"))
@assert size(regionnumbers, 1) == size(regionpoints, 2) ||
- throw(DimensionMismatch("size(regionnumbers,1) != size(regionpoints,2)"))
+ throw(DimensionMismatch("size(regionnumbers,1) != size(regionpoints,2)"))
@assert size(regionvolumes, 1) == size(regionpoints, 2) ||
- throw(DimensionMismatch("size(regionvolumes,1) !== size(regionpoints,2)"))
+ throw(DimensionMismatch("size(regionvolumes,1) !== size(regionpoints,2)"))
nholes = 0
nregions = 0
- for i = 1:length(regionnumbers)
+ for i in 1:length(regionnumbers)
if regionnumbers[i] == 0
nholes += 1
else
@@ -95,7 +97,7 @@ function triangulateio(Triangulate;
ihole = 1
iregion = 1
- for i = 1:length(regionnumbers)
+ for i in 1:length(regionnumbers)
if regionnumbers[i] == 0
holelist[1, ihole] = regionpoints[1, i]
holelist[2, ihole] = regionpoints[2, i]
@@ -128,7 +130,7 @@ function triangulateio(Triangulate;
tio.holelist = holelist
end
- tio
+ return tio
end
"""
@@ -139,16 +141,18 @@ Create triangle input from the current state of the builder.
function triangulateio(this::SimplexGridBuilder)
dim_space(this) == 2 || throw(error("dimension !=2 not implemented"))
facets = Array{Cint, 2}(undef, 2, length(this.facets))
- for i = 1:length(this.facets)
+ for i in 1:length(this.facets)
facets[1, i] = this.facets[i][1]
facets[2, i] = this.facets[i][2]
end
- triangulateio(this.Generator;
- points = this.pointlist.points,
- bfaces = facets,
- bfaceregions = this.facetregions,
- regionpoints = this.regionpoints,
- regionnumbers = this.regionnumbers,
- regionvolumes = this.regionvolumes)
+ return triangulateio(
+ this.Generator;
+ points = this.pointlist.points,
+ bfaces = facets,
+ bfaceregions = this.facetregions,
+ regionpoints = this.regionpoints,
+ regionnumbers = this.regionnumbers,
+ regionvolumes = this.regionvolumes
+ )
end
diff --git a/src/utils.jl b/src/utils.jl
index 45cd967..59b817a 100644
--- a/src/utils.jl
+++ b/src/utils.jl
@@ -1,4 +1,3 @@
-
"""
istetgen(Generator)
diff --git a/test/runtests.jl b/test/runtests.jl
index 6ae40f5..7da66e0 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -18,10 +18,10 @@ using LinearAlgebra
end
-if isdefined(Docs,:undocumented_names) # >=1.11
-@testset "UndocumentedNames" begin
- @test isempty(Docs.undocumented_names(SimplexGridFactory))
-end
+if isdefined(Docs, :undocumented_names) # >=1.11
+ @testset "UndocumentedNames" begin
+ @test isempty(Docs.undocumented_names(SimplexGridFactory))
+ end
end
@@ -32,18 +32,17 @@ end
Aqua.test_project_extras(SimplexGridFactory)
Aqua.test_stale_deps(SimplexGridFactory)
Aqua.test_deps_compat(SimplexGridFactory)
- Aqua.test_piracies(SimplexGridFactory, treat_as_own=[simplexgrid])
+ Aqua.test_piracies(SimplexGridFactory, treat_as_own = [simplexgrid])
Aqua.test_persistent_tasks(SimplexGridFactory)
end
-
CairoMakie.activate!(; visible = false)
# Generated point numbers depend on floating point operations,
# so we don't insist in exact matches
function testgrid(grid::ExtendableGrid, testdata)
- all(isapprox.((num_nodes(grid), num_cells(grid), num_bfaces(grid)), testdata, rtol = 0.1))
+ return all(isapprox.((num_nodes(grid), num_cells(grid), num_bfaces(grid)), testdata, rtol = 0.1))
end
testgrid(builder::SimplexGridBuilder, testdata) = testgrid(simplexgrid(builder), testdata)
@@ -67,14 +66,22 @@ testgrid(builder::SimplexGridBuilder, testdata) = testgrid(simplexgrid(builder),
Triangulate.triangulate("paAqQ", triin, triout, vorout)
points = convert(Array{Float64, 2}, Base.unsafe_wrap(Array, triout.pointlist, (2, Int(triout.numberofpoints)); own = true))
- cells = convert(Array{Int32, 2},
- Base.unsafe_wrap(Array, triout.trianglelist, (2, Int(triout.numberoftriangles)); own = true))
- bfaces = convert(Array{Int32, 2},
- Base.unsafe_wrap(Array, triout.segmentlist, (2, Int(triout.numberofsegments)); own = true))
- cellregions = convert(Array{Float64, 1},
- Base.unsafe_wrap(Array, triout.triangleattributelist, (Int(triout.numberoftriangles)); own = true))
- bfaceregions = convert(Array{Int32, 1},
- Base.unsafe_wrap(Array, triout.segmentmarkerlist, (Int(triout.numberofsegments)); own = true))
+ cells = convert(
+ Array{Int32, 2},
+ Base.unsafe_wrap(Array, triout.trianglelist, (2, Int(triout.numberoftriangles)); own = true)
+ )
+ bfaces = convert(
+ Array{Int32, 2},
+ Base.unsafe_wrap(Array, triout.segmentlist, (2, Int(triout.numberofsegments)); own = true)
+ )
+ cellregions = convert(
+ Array{Float64, 1},
+ Base.unsafe_wrap(Array, triout.triangleattributelist, (Int(triout.numberoftriangles)); own = true)
+ )
+ bfaceregions = convert(
+ Array{Int32, 1},
+ Base.unsafe_wrap(Array, triout.segmentmarkerlist, (Int(triout.numberofsegments)); own = true)
+ )
cellregions = Vector{Int32}(cellregions)
grid = simplexgrid(points, cells, cellregions, bfaces, bfaceregions)
@@ -105,14 +112,16 @@ end
@testset "Simplexgrid (arrays 2d)" begin
function test_simplesquare(; kwargs...)
- tio= SimplexGridFactory.triangulateio(Triangulate,
- points = [0 0; 0 1; 1 1; 1 0]',
- bfaces = [1 2; 2 3; 3 4; 4 1]',
- bfaceregions = [1, 2, 3, 4],
- regionpoints = [0.5 0.5;]',
- regionnumbers = [1],
- regionvolumes = [0.01])
- grid = simplexgrid(SimplexGridFactory.TriangulateType,Triangulate, tio; kwargs...)
+ tio = SimplexGridFactory.triangulateio(
+ Triangulate,
+ points = [0 0; 0 1; 1 1; 1 0]',
+ bfaces = [1 2; 2 3; 3 4; 4 1]',
+ bfaceregions = [1, 2, 3, 4],
+ regionpoints = [0.5 0.5;]',
+ regionnumbers = [1],
+ regionvolumes = [0.01]
+ )
+ grid = simplexgrid(SimplexGridFactory.TriangulateType, Triangulate, tio; kwargs...)
end
@test testgrid(test_simplesquare(), (89, 144, 32))
@@ -179,32 +188,38 @@ end
function test_tetunsuitable(pa, pb, pc, pd)
vol = det(hcat(pb - pa, pc - pa, pd - pa)) / 6
center = 0.25 * (pa + pb + pc + pd) - [0.5, 0.5, 0.5]
- vol > 0.05 * norm(center)^2.5
+ return vol > 0.05 * norm(center)^2.5
end
@testset "Simplexgrid (arrays 3d)" begin
function test_simplecube(; kwargs...)
- tio= SimplexGridFactory.tetgenio(TetGen,
- points = [0 0 0;
- 1 0 0;
- 1 1 0;
- 0 1 0;
- 0 0 1;
- 1 0 1;
- 1 1 1;
- 0 1 1]', bfaces = [1 2 3 4;
- 5 6 7 8;
- 1 2 6 5;
- 2 3 7 6;
- 3 4 8 7;
- 4 1 5 8]',
- bfaceregions = [i for i = 1:6],
- regionpoints = [0.5 0.5 0.5]',
- regionnumbers = [1],
- regionvolumes = [0.01])
- grid = simplexgrid(SimplexGridFactory.TetGenType,TetGen, tio; kwargs...)
+ tio = SimplexGridFactory.tetgenio(
+ TetGen,
+ points = [
+ 0 0 0;
+ 1 0 0;
+ 1 1 0;
+ 0 1 0;
+ 0 0 1;
+ 1 0 1;
+ 1 1 1;
+ 0 1 1
+ ]', bfaces = [
+ 1 2 3 4;
+ 5 6 7 8;
+ 1 2 6 5;
+ 2 3 7 6;
+ 3 4 8 7;
+ 4 1 5 8
+ ]',
+ bfaceregions = [i for i in 1:6],
+ regionpoints = [0.5 0.5 0.5]',
+ regionnumbers = [1],
+ regionvolumes = [0.01]
+ )
+ grid = simplexgrid(SimplexGridFactory.TetGenType, TetGen, tio; kwargs...)
end
-
+
@test testgrid(test_simplecube(), (109, 286, 198))
@test testgrid(test_simplecube(; flags = "pAaqQD"), (109, 286, 198))
@test testgrid(test_simplecube(; maxvolume = 0.05), (50, 68, 96))