Problems with meshing

Hi,all.I’m trying to create a cube containing two regular small cubes, which I get by creating them and subtracting them from the original cube and filling them in, but this doesn’t seem to mesh. Here is my exact process, any suggestions.

reset
brick x 50
move vol 1 x -25 y -25 z -25
brick x 10
move vol 2 x -15 y -15 z -15
brick x 10
move vol 3 x -35 y -35 z -35
subtract vol 2 from vol 1
subtract vol 3 from vol 4
brick x 10
move vol 6 x -15 y -15 z -15
brick x 10
move vol 7 x -35 y -35 z -35
imprint all
merge all
volume all size 1
mesh volume all

Hi @sunflower,

To mesh this kind of geometry, you’ll likely have to decompose the domain into several smaller pieces that you mesh individually.

Here’s one possible way to go about doing that:

reset

# Create the individual blocks
brick x 50
move vol 1 x -25 y -25 z -25
brick x 10
move vol 2 x -15 y -15 z -15
brick x 10
move vol 3 x -35 y -35 z -35

# Subtract the small ones from the large one while keeping the originals
subtract vol 2 from vol 1 keep_tool
subtract vol 3 from vol 4 keep_tool

# Merge the common surfaces we created during the above boolean operations
merge surface all

# Make webcuts extending from the cubes into the vertical direction
webcut volume 5 sweep surface 13 vector 0 0 1 through_all
webcut volume 6 sweep surface 14 vector 0 0 -1 through_all
webcut volume 7 sweep surface 7 vector 0 0 1 through_all
webcut volume 7 sweep surface 8 vector 0 0 -1 through_all

# Imprint all of the new columns that we've created onto the large block
imprint volume 5 7
imprint volume 3 7
imprint volume 5 7
imprint volume 8 7
imprint volume 2 7
imprint volume 9 7

# Merge common surfaces again
merge surface all

# We'll assume that we want the same element size everywhere
volume all size 2

# Mesh the small cubes first
surface 48 36 size 2
surface 48 36 scheme map
mesh surface 48 36

# Sweep these downwards
volume 8 scheme Sweep sweep transform least squares
volume 2 scheme Sweep sweep transform least squares
volume 9 scheme Sweep sweep transform least squares
volume 3 scheme Sweep sweep transform least squares
volume 5 scheme Sweep sweep transform least squares
volume 6 scheme Sweep sweep transform least squares
mesh volume 8 2 9 3 5 6

# Mesh the top surface of the big block
surface 43 size 2
surface 43 scheme pave
mesh surface 43

# Sweep the top surface downwards
volume 7 scheme Sweep source surface 43 target surface 49 sweep transform least squares
mesh volume 7

There are definitely other (probably more elegant) ways that you could go about doing this, but this is just one potential option.

Have a nice day :slight_smile:

Cheers,
Pat

Thank you for your help. That’s one way to fix it.

Hi @sunflower,
it’s just as @pmarty said. You will have to decompose the volumes and probably set some mesh schemes.

Here is another possble way. Just adding 2 webcuts and setting one scheme.

reset
brick x 50
move vol 1 x -25 y -25 z -25
brick x 10
move vol 2 x -15 y -15 z -15
brick x 10
move vol 3 x -35 y -35 z -35
subtract vol 2 from vol 1
subtract vol 3 from vol 4
brick x 10
move vol 6 x -15 y -15 z -15
brick x 10
move vol 7 x -35 y -35 z -35

webcut volume 5 with sheet extended from surface 30
webcut volume 8  with sheet extended from surface 34  

imprint all
merge all
volume all size 1
Volume 9 scheme submap
mesh volume all