Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create mesh-complete folder using Python API #1049

Open
menon-karthik opened this issue Mar 7, 2024 · 5 comments
Open

Create mesh-complete folder using Python API #1049

menon-karthik opened this issue Mar 7, 2024 · 5 comments
Assignees

Comments

@menon-karthik
Copy link
Member

Is your feature request related to a problem? Please describe.
We don't currently seem to have a way to create an equivalent mesh-complete folder using the python API like you can with the GUI. We can use the API to import a model, generate a mesh, and write out the full volume (.vtu) and surface (.vtp) meshes. For example, this can be done using the below code snippet:

mesher = sv.meshing.TetGen()
mesher.set_model(model)
mesher.set_walls([wall_face_id])
options = sv.meshing.TetGenOptions(global_edge_size=0.05, surface_mesh_flag=True, volume_mesh_flag=True)
mesher.generate_mesh(options)
mesher.write_mesh("mesh-complete.mesh.vtu")
surface_poly = mesher.get_surface()
write_surface_mesh("mesh-complete.exterior.vtp", surface_poly)

But there doesn't seem to be functionality to write out the surface meshes corresponding to walls-combined.vtp and all the other mesh faces while easily preserving the Normals, ModelFaceID and ModelRegionID arrays that are already in mesh-complete.mesh.vtu and mesh-complete.exterior.vtp. For example, I tried using mesher.get_face_polydata(wall_face_id) to extract the surface mesh for walls-combined.vtp but this does not retain the arrays mentioned above.

Describe the solution you'd like
It would be great to have functionality that can go from the mesh generated with mesher.generate_mesh(options) to a full mesh-complete folder that is analogous to what you would get from using the GUI.

Describe alternatives you've considered
An alternative is to manually create the Normals, ModelFaceID and ModelRegionID arrays for each face by copying the data from the full surface mesh returned by mesher.get_surface(). But this is clunky.

@ktbolt ktbolt self-assigned this Mar 7, 2024
@ktbolt
Copy link
Contributor

ktbolt commented Mar 8, 2024

I've modified the TGenUtils_GetFacePolyData() function to add a ModelFaceID CellData array to the vtkPolyData for a face. A call to mesher.get_face_polydata(id) now returns a ModelFaceID CellData array.

Note that mesh faces don't have a Normals data array unless the mesh is a boundary layer mesh.

@menon-karthik
Copy link
Member Author

Thanks @ktbolt! Does this also add ModelRegionID and Normals (if it is a boundary layer mesh) to the vtkPolyData returned by mesher.get_face_polydata(id)?

@ktbolt
Copy link
Contributor

ktbolt commented Mar 11, 2024

@menon-karthik I can add normals, do you need Cell or Point normals?

I can also add ModelRegionID although I don't see this in any of my mesh files.

@menon-karthik
Copy link
Member Author

The normals written out by the GUI are cell normals, so let's do that. My meshes also have ModelRegionID for each .vtp in mesh-surfaces. This is also on the cells. Maybe that's also only written out if it's a boundary layer mesh? Not sure.

@ktbolt
Copy link
Contributor

ktbolt commented Mar 12, 2024

I've added creating aModelRegionID Cell Array and Cell normals for faces. The ModelRegionID is only created if the mesh has that data defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants