Hi all,
Here’s the toy problem I’m working with:
I’m able to set up the geometry and construct the mesh using the attached Python script. However, one of the things which I’m trying to make more general is how the composite curve of the “blob” cutout is defined. Currently I have this set up to be
cubit.cmd(f"composite create curve all except 1 to 4")
since curves 1
to 4
in this case represent the outer boundaries of the square.
I’m trying to generalize this so that we can say something along the lines of:
cubit.cmd(f"composite create curve all except <OUTER BOUNDARY OF THE SQUARE>")
or
cubit.cmd(f"composite create curve all <BOUNDARY OF THE BLOB>")
Is there a nice way how one can iterate through the connected boundaries of a given surface to extract this information?
Here’s the full code in case you want to give it a go:
import cubit
import numpy as np
cubit.cmd("reset")
# Create an irregularly shaped blob with a lot of samples
n_pts = 2 ** 10 - 1
theta = np.linspace(0, 2 * np.pi, n_pts, endpoint=False)
r = 0.025 * np.sin(np.linspace(0, 16 * np.pi, n_pts, endpoint=False)) + 0.25
x = np.cos(theta) * r
y = np.sin(theta) * r
blob = np.vstack([x, y]).T
# Add a unit square
cubit.cmd("create surface rectangle width 1 height 1 zplane")
# Used for tracking the vert IDs in the blob
vertex_list = np.zeros(n_pts, dtype=int)
# Add the verts for the blob
for i, pt in enumerate(blob):
cubit.cmd(f"create vertex {pt[0]} {pt[1]} 0.0")
vertex_list[i] = cubit.get_last_id("vertex")
# Create the blob
verts = ""
for v in vertex_list:
verts += str(v) + ", "
cubit.cmd(f"create surface vertex {verts[:-2]}")
# Boolean surfaces
cubit.cmd("subtract surface 2 from surface 1")
# Create composite curve of the blob
cubit.cmd("composite create curve all except 1 to 4")
# Create the mesh
cubit.cmd("surface all scheme pave")
cubit.cmd("surface all size 0.01")
cubit.cmd("surface all sizing function constant")
cubit.cmd("mesh surface all")
Thanks a lot for your help
All the best,
Pat