Hello all,
I am a new user in Cubit and in meshing. I am trying to create a mesh of a cylinder (radius 120, height 310). I want to be able to control the number of mesh cells created, specifically I want to create 250,000 mesh cells, and I want each cell to be approximately the same volume. Is there a way to do this?
Any suggestions or help will be greatly appreciated.
Thank you in advance!
Under volume meshing, you can choose the option “approximate size”. Choose the volume and the value it will make approximately equal volume elements. A good guess for your case will the volume of cylinder divided by 250000 i.e. 56.096.
Hello @tsiaraf,
hitting an exact number of elements won’t probably be possible, but we can get near it.
First the base geometry
#!cubit
reset
create Cylinder height 310 radius 120
Now we could try to get it done with the auto size function. For this we could take a look with python if the element budget would satisfy us.
#!python
cubit.get_element_budget("hex",[1],1)
But 35419 elements won’t be near your requested 250k.
The next try would be to approximate a element size that can be set.
#!python
# volume of volume
vv = cubit.get_volume_volume(1)
# number of elements
noe = 250000
# desired element size
es = (vv/noe) ** (1. / 3)
cubit.cmd(f"volume 1 size {es}") # set size
#!cubit
mesh vol 1
274914 hexes is already not bad.
Another option is to make a loop and remesh until the mesh size fits our requested element count.
#!cubit
reset
create Cylinder height 310 radius 120
#!python
# number of elements
noe = 250000
# element size
es = 20
delta_es = 0.1
for i in range(int(es/delta_es)-1):
cubit.cmd(f"volume 1 size {es-i*delta_es}") # set size
cubit.cmd(f"mesh volume 1") # mesh
# check numbers of elements
ve = cubit.get_volume_element_count(1)
if ve > noe:
break
else:
cubit.cmd("delete mesh volume 1 propagate") # delete mesh
print(ve)