Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions DeepSDFStruct/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,18 @@ def get_mesh_from_torchfem(Solid: torchfem.Solid) -> pyvista.UnstructuredGrid:
if not isinstance(Solid, torchfem.Solid):
raise NotImplementedError("Currently only solid mesh is supported.")
# VTK cell types
if Solid.etype is Tetra1:
cell_types = Solid.n_elem * [pyvista.CellType.TETRA]
elif Solid.etype is Tetra2:
cell_types = Solid.n_elem * [pyvista.CellType.QUADRATIC_TETRA]
elif Solid.etype is Hexa1:
cell_types = Solid.n_elem * [pyvista.CellType.HEXAHEDRON]
elif Solid.etype is Hexa2:
cell_types = Solid.n_elem * [pyvista.CellType.QUADRATIC_HEXAHEDRON]
etype = Solid.etype

if etype is Tetra1 or isinstance(etype, Tetra1):
cell_types = [pyvista.CellType.TETRA] * Solid.n_elem
elif etype is Tetra2 or isinstance(etype, Tetra2):
cell_types = [pyvista.CellType.QUADRATIC_TETRA] * Solid.n_elem
elif etype is Hexa1 or isinstance(etype, Hexa1):
cell_types = [pyvista.CellType.HEXAHEDRON] * Solid.n_elem
elif etype is Hexa2 or isinstance(etype, Hexa2):
cell_types = [pyvista.CellType.QUADRATIC_HEXAHEDRON] * Solid.n_elem
else:
raise TypeError(f"Unsupported element type: {etype} ({type(etype)})")

# VTK element list
el = len(Solid.elements[0]) * torch.ones(Solid.n_elem, dtype=Solid.elements.dtype)
Expand Down
Loading