Volumetric Meshing

Hello,
I’m attempting to create a volumetric mesh of a cuboid with a sphere cut out of the centre. I can create the geometry using the boolean tools, but I’m not sure how to mesh not just the surface, but the entire volume. This will be used for a physics simulation in another program. Any advice from anyone would be much appreciated! Apologies if this is obvious, I couldn’t find mention of it on the main site/tutorials, and the documentation website keeps freezing!

Best,
Andrew

Here is one way to do this. For this geometry, I have to explicitly set the meshing algorithm as scheme polyhedron.

reset
brick x 10
sphere radius 2
subtract volume 2 from 1
webcut volume 3 with plane yplane offset 0
webcut volume all with plane xplane offset 0
webcut volume all with plane zplane offset 0
merge all
vol all scheme polyhedron
mesh vol all

image
Display of internal features in model.

I will pass the concerns about the website to our web team.

Thanks,
Karl

Thanks very much, this is a great help! How can I control the density/fineness of the mesh?

The easiest way is to set the mesh size. Note that Cubit is dimensionless. So the units are whatever you choose but consistent. When you run your simulation, make sure that the materials units are consistent with the geometric units you used to build the model.

So for example,
volume all size .1

@adfboyd - to expand on this a bit, it’s best if you do your meshing in a unit-system that represents your model with length dimensions close to 1. This is because Cubit, as most/all other CAD software uses an absolute tolerance in its geometry engine. The tightest absolute tolerance that can be specified is 1\times 10^{-6} and some of the meshing algorithms (e.g. tetmesh) have an absolute tolerance of 1\times10^{-4}.

So what you can do is model in one length-scale (whether a common unit-system, or an “easy” scale conversion) and then scale the mesh when it’s exported into your simulation’s unit-system:

transform mesh output scale <scale_factor>

Note that this command is multiplicative so a script like this:

reset
brick x 1 
mesh vol 1
## Scaling output mesh by 0.1
transform mesh output scale 0.1
export exodus "mesh_scaled_0p1.e" overwrite
## Now the output mesh will be scaled by 0.1 * 0.1 = 0.01
transform mesh output scale 0.1
export exodus "mesh_scaled_0p01.e" overwrite

will result in a final mesh that’s scaled by 0.1 x 0.1 = 0.01.

To reset the scaling you’ll need to run:

transform mesh output reset

Brilliant, thank you! So, if I want a mesh of scale 0.01 when my simulation is around a sphere of diameter 1, it is best not to change the vol size parameter, but instead change the output scale on export?

Let’s pretend you want to model the flow around a 10\mu m radius sphere. If your simulation will be using standard SI unit-system (kg-m-s) your geometry would need to be represented with a sphere of radius 0.000010 meters. You would run into many modeling/meshing errors in Cubit if you tried modeling directly at this scale:

## THIS WILL FAIL
reset
brick x 0.000050
sphere radius 0.000010
subtract volume 2 from 1
webcut volume 3 with plane yplane offset 0
webcut volume all with plane xplane offset 0
webcut volume all with plane zplane offset 0
merge all
vol all scheme polyhedron
mesh vol all

Rather, it would be better for you to do your CAD modeling & meshing in Cubit at a different scale and then scale on export:

## THIS WILL WORK CORRECTLY
reset
brick x 10
sphere radius 2
subtract volume 2 from 1
webcut volume 3 with plane yplane offset 0
webcut volume all with plane xplane offset 0
webcut volume all with plane zplane offset 0
merge all
vol all scheme polyhedron
mesh vol all

transform mesh output scale 0.000005
export exodus "mesh_scaled.e" overwrite

I think a mesh scale of .01 on a model with a sphere of unit 1 should be fine without any transformation.

This makes sense, thank you! One last thing, apologies if this is trivial: is there an easy way to generate the sphere so that it is centered on some point (to be specified) away from the origin?

Not in a single command, however, you can translate the CAD geometry. Note that this may require a little bit of math if you do end up using the transform mesh output command to scale your mesh on export:

reset
brick x 10

## Create  a sphere located at (2, 0, 0) x 10^-5
sphere radius 2
move volume 2 x 2  

subtract volume 2 from 1
webcut volume all with plane xplane offset 2  # Need to modify our webcutting
webcut volume all with plane yplane offset 0
webcut volume all with plane zplane offset 0

merge all
vol all scheme polyhedron
mesh vol all

transform mesh output scale 0.000005
export exodus "mesh_scaled.e" overwrite

EDIT: GUI Screenshot

Excellent, thank you very much. I am also creating sidesets on the boundarises for use in my simulations; these won’t be affected by the change of mesh resolution on export?

They won’t be negatively affected, no.