Skip to content

Commit 3f55ffc

Browse files
committed
bregions! without args and kwargs takes all boundaries instead of none.
1 parent 36ca94c commit 3f55ffc

3 files changed

Lines changed: 51 additions & 2 deletions

File tree

examples/examples2d.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,22 @@ end
248248
# ![](swiss_cheese_2d.png)
249249
#
250250

251+
252+
# ## Remeshing another grid
253+
#
254+
# The `bregions!` method allows to use another grid as geometry description
255+
#
256+
function remesh_2d()
257+
b = SimplexGridBuilder(; Generator = Triangulate)
258+
X=0:0.1:1
259+
grid1 = simplexgrid(X, X)
260+
bregions!(b,grid1)
261+
simplexgrid(b,maxvolume=0.01)
262+
end
263+
#
264+
# ![](remesh_2d.png)
265+
#
266+
251267
# ## Glueing in another grid
252268
#
253269
# The `bregions!` method allows to extract parts of the geometry description from
@@ -327,6 +343,9 @@ function generateplots(picdir; Plotter = nothing)
327343
p = builderplot(swiss_cheese_2d(); Plotter, size)
328344
Plotter.save(joinpath(picdir, "swiss_cheese_2d.png"),p)
329345

346+
p = gridplot(remesh_2d(); Plotter, size)
347+
Plotter.save(joinpath(picdir, "remesh_2d.png"),p)
348+
330349
p = gridplot(glue_2d(); Plotter, size)
331350
Plotter.save(joinpath(picdir, "glue_2d.png"),p)
332351
end

examples/examples3d.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,25 @@ end
8585

8686
# ![](tet_cube_with_primitives.png)
8787

88+
89+
90+
# ## Remeshing another grid
91+
#
92+
# The `bregions!` method allows to use another grid as geometry description
93+
#
94+
function remesh_3d()
95+
b = SimplexGridBuilder(; Generator = TetGen)
96+
X=0:0.1:1
97+
grid1 = simplexgrid(X, X, X)
98+
bregions!(b,grid1)
99+
simplexgrid(b,maxvolume=0.0001)
100+
end
101+
#
102+
# ![](remesh_3d.png)
103+
#
104+
105+
106+
88107
# ## Glue-in of existing grid
89108
#
90109
# The [`bregions!`](@ref) method allows to extract parts of the geometry description from
@@ -152,6 +171,10 @@ function generateplots(picdir; Plotter = nothing)
152171
gridplot(glue_3d(); Plotter, size, azim = 0, elev = 15, xplanes = [5])
153172
Plotter.savefig(joinpath(picdir, "glue_3d.png"))
154173

174+
Plotter.clf()
175+
gridplot(remesh_3d(); Plotter, size, zplanes = [0.5])
176+
Plotter.savefig(joinpath(picdir, "remesh_3d.png"))
177+
155178
Plotter.clf()
156179
gridplot(stl_3d(); Plotter, size, xplanes = [5])
157180
Plotter.savefig(joinpath(picdir, "stl_3d.png"))

src/primitives.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ bregions!(builder::SimplexGridBuilder,grid, pairs...)
2020
```
2121
Add boundary facets of `grid` with region numbers mentioned as first element in `pairs`
2222
with region number mentioned as second element of `pairs` to the geometry description.
23-
23+
If no pairs are given, add all boundary facets of `grid` with their original region numbers to builder.
2424
2525
Example:
2626
@@ -29,9 +29,16 @@ bregions!(builder,grid, 1=>2, 3=>5)
2929
```
3030
"""
3131
function bregions!(builder::SimplexGridBuilder, grid, pairs...)
32-
bregions!(builder, grid, first.([pairs...]); facetregions = last.([pairs...]))
32+
if length([pairs...])>0
33+
bregions!(builder, grid, first.([pairs...]); facetregions = last.([pairs...]))
34+
else
35+
cr=unique(grid[BFaceRegions])
36+
bregions!(builder, grid, cr; facetregions=cr)
37+
end
3338
end
3439

40+
41+
3542
"""
3643
```
3744
bregions!(builder::SimplexGridBuilder,grid,regionlist;facetregions=nothing)

0 commit comments

Comments
 (0)