Skip to content

Commit

Permalink
Changed tetrahedral mesh generation to make use of tetmesh flagging b…
Browse files Browse the repository at this point in the history
…oundary nodes.
  • Loading branch information
siboles committed Jul 22, 2016
1 parent 67ad530 commit a159545
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
15 changes: 6 additions & 9 deletions src/pyCellAnalyst/CellMech.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def _readstls(self):
massProps = vtk.vtkMassProperties()
massProps.SetInputData(self.rsurfs[-1])
massProps.Update()
print("Generating tetrahedral mesh from {:s}".format(fname))
self._make3Dmesh(
str(os.path.normpath(self._ref_dir + os.sep + fname)),
'MATERIAL', massProps.GetVolume())
Expand All @@ -189,6 +190,7 @@ def _readstls(self):
massProps = vtk.vtkMassProperties()
massProps.SetInputData(self.dsurfs[-1])
massProps.Update()
print("Generating tetrahedral mesh from {:s}".format(fname))
self._make3Dmesh(
str(os.path.normpath(self._def_dir + os.sep + fname)),
'SPATIAL', massProps.GetVolume())
Expand Down Expand Up @@ -473,14 +475,14 @@ def _make3Dmesh(self, filename, frame, vConst):
* dvols
* daxes
"""
vConst /= 30000.0
vConst /= 50000.0
edgeSize = (vConst*12/np.sqrt(2)) ** (1./3.)
m = mesh.Mesher(inputname=filename,
outputname="tmp.vtu",
facetAngle=30.0,
facetDistance=0.1,
edgeLength=edgeSize,
edgeRatio=1.5)
edgeRatio=1.3)
m.makeMesh()

gridReader = vtk.vtkXMLUnstructuredGridReader()
Expand All @@ -490,13 +492,8 @@ def _make3Dmesh(self, filename, frame, vConst):
nodes = vtk_to_numpy(vtkMesh.GetPoints().GetData())
elements = vtk_to_numpy(vtkMesh.GetCells().GetData()).reshape(
(vtkMesh.GetNumberOfCells(), 5))[:,1:]
extractSurface = vtk.vtkDataSetSurfaceFilter()
extractSurface.SetInputData(vtkMesh)
extractSurface.Update()
faces = extractSurface.GetOutput()
N = faces.GetNumberOfPolys()
faces = vtk_to_numpy(faces.GetPolys().GetData()).reshape((N, 4))[:,1:]
s_nodes = np.unique(np.ravel(faces))
vertex_type = vtk_to_numpy(vtkMesh.GetPointData().GetArray("Vertex Type"))
s_nodes = np.argwhere(vertex_type==1).ravel()

n1 = nodes[elements[:, 0], :]
n2 = nodes[elements[:, 1], :]
Expand Down
1 change: 0 additions & 1 deletion src/pyCellAnalyst/FEA_GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ def performFEA(self):

mesh = febio.MeshDef()
# would be good to vectorize these
print self.data[filename]['elements']
for i, e in enumerate(self.data[filename]['elements']):
mesh.elements.append(['tet4', i + 1] + e)

Expand Down

0 comments on commit a159545

Please sign in to comment.