Improving Mesh quality of a brick volume with spherical corner subtraction

Howdy Coreform Forum,

I’ve got a toy problem that I am able to get meshed, but I’m getting pretty low quality elements in a few places making me think there may be a better way that mesh gurus can point me toward. Let’s start with the geometry. I want to mesh a brick with a sphere subtracted from the corner:

# geometry construction
brick x 5
sphere radius 4.5
move Volume 2 x 2.5 y 2.5 z 2.5 include_merged 
subtract body 2 from body 1

Now, we need to decompose the geometry via webcuts. I start by taking a cylindrical webcut centered on the corner where the subtraction happened, then make a planar cut on the remaining volume. I could see this being where I start to go wrong, as the intention is for me to sweep a meshed edge on the larger geometries, but there is a pretty big difference in size between the edge surface and the planar webcut surface.

# webcuts
webcut volume 1 with cylinder radius 1.5 axis y center 2.5 0 2.5 merge
webcut volume 1 with plane xplane offset 0 rotate 45 about y center 0 0 0
imprint all
merge all

Now there are a couple of different options. I mesh the central “plug” volume on the flat surface and sweep to the concave surface. Then I can mesh either the edge surface of one of the remaining volumes and sweep to the webcut surface (then sweep to the other edge surface) or I can mesh the webcut surface and then sweep to the edge surfaces. I’ll present both below:

# edge first meshing
surf 21 size 0.1
mesh surface 21
vol 3 size 0.2
mesh vol 3
vol 1 4 size 0.2
mesh surface 16
mesh vol 1
mesh vol 4
# webcut first meshing
surf 21 size 0.1
mesh surface 21
vol 3 size 0.2
mesh vol 3
vol 1 4 size 0.2
mesh surf 22
mesh vol 1 4

So we have the thing meshed two ways now. Let’s look at the quality for both instances:

As you can see, there are a few problem areas in both. I would like to improve the quality of this mesh, so any advice would be greatly appreciated!

For pure simplicity, you can use the polyhedron scheme

vol 1 size 0.1
vol 1 scheme polyhedron
mesh vol 1

And then you could use the condition number smoothing scheme to improve the mesh quality a bit

volume 1 smooth scheme condition number beta 2.0 cpu 1
smooth volume 1

It’s relatively similar (poor) mesh quality, but less work.

Comparing the scaled Jacobians of your first mesh and the polyhedron mesh:

Webcut edge-first – scaled Jacobian

Polyhedron – scaled Jacobian

Wow, yeah this is a huge improvement!

Thanks!