Problems when dividing shapes that contain other shapes inside

I want to create a model that contains a simple square and a cylinder, but I’m having problems with the mesh, how can I solve this kind of problem, I hope you can give me some advice!
**cubit.cmd(‘reset’)
cubit.cmd(‘brick x 100 y 100 z 100’)
cubit.cmd(‘move vol 1 x 50 y 50 z -50’)

cubit.cmd(‘brick x 24 y 24 z 24’)
cubit.cmd(‘move volume 2 x 35 y 35 z -35’)

cubit.cmd(‘frustum z 24 radius 12 top 12’)
cubit.cmd(‘move vol 3 x 65 y 65 z -65’)

cubit.cmd(‘subtract volume 2 from volume 1 keep_tool’)
cubit.cmd(‘subtract volume 3 from volume 4 keep_tool’)

cubit.cmd(‘imprint all’)
cubit.cmd(‘merge all’)

Meshing the volumes

cubit.cmd(‘volume all size 1’)
cubit.cmd(‘mesh volume all’)**

For these geometries, you will have to webcut in order to mesh this as one solid mesh if that’s what you’re hoping for. Also, are you hoping for a hex/tet mesh for this?

yes, I would like to be a hexahedral mesh, and I have tried to make cuts, but unsuccessfully, due to the different way of dividing the upper and lower meshes, resulting in unsuccessful division of the middle layer.

Hi @sunflower,
just using one middle layer won’t work here. You need geometry that can be meshed with a sweep. You got here a many-to-many sweep attempt.

You could sweep surfaces to decompose the geometry. I just put the 3 volumes in blocks before doing the webcuts. This way you don’t need to handpick them together afterwards.

reset
brick x 100 y 100 z 100
move vol 1 x 50 y 50 z -50

brick x 24 y 24 z 24
move volume 2 x 35 y 35 z -35

frustum z 24 radius 12 top 12
move vol 3 x 65 y 65 z -65

subtract volume 2 from volume 1 keep_tool
subtract volume 3 from volume 4 keep_tool

compress

block 1 add vol 1
block 2 add vol 2
block 3 add vol 3

webcut volume 3  sweep surface 16  perpendicular inward through_all 
webcut volume 4  sweep surface 24  perpendicular inward through_all 
webcut volume 4  sweep surface 8  perpendicular outward through_all 
webcut volume 4  sweep surface 14  perpendicular outward through_all 


imprint all
merge all

#volume all size 1
mesh volume all