Idenitfying free surfaces using python script

I am currently working on automating the mesh generation process and subsequently importing the mesh into OPENFOAM. At present, I am encountering a challenge with creating groups. Specifically, I am working with a blocked pipe for structured meshing. Please refer to the attached image for a visual reference:


My objective is to extract only the surface faces. For the walls, I require all faces on the circumference of the cylinder, and for the inlets (1, 2, 3, 4, 5) and the outlets, I need the respective faces.
When I use all_faces = geompy.ExtractShapes(Divided_Cylinder_1, geompy.ShapeType[“FACE”], True)
I can extract all the faces. However, this includes faces inside the block, which I do not need. I considered sorting these based on coordinates and tried using:
center = geompy.MakeCDG(face)
Unfortunately, this did not work as anticipated, as multiple faces have their center of mass not aligning as expected.

Is there a more straightforward method to achieve this, such as a specific function to extract only the surface faces?

Thank you very much for your support and assistance.

Best regards,
Shariq

Have a look at geompy.getonplace, it will select a type of object face solid vertex using another external object such as a plane or a cylinder. That way you can go little by little selecting the correct ones. For this part as it is simple you can select the compound fuse internal faces then remove internal faces and remove extra wires, this will give you a clean cylinder of same height and diameter and you can use this faces to select what you want.

Hi,

you can use GetFreeFacesIDs to get the free faces ids. Then add it to a group with UnionIDs.

Have a look at this script
get_free_faces.py (664 Octets)

Best regards,

Christophe

1 Like

Greetings of the time,

@franco.ota and @cbourcier

Thank you for your help and time. I managed to resolve the issue using the free face IDs method. By utilizing those IDs, I was able to determine the respective centers of projection/mass and subsequently sort based on the coordinates for the inlet and outlet.

Thank you once again.

Best regards,
Shariq

1 Like