refactored the term 'face' to 'cell' to match what I've found in literature
This commit is contained in:
+31
-31
@@ -7,7 +7,7 @@ import numpy as np
|
||||
from scipy.spatial import KDTree
|
||||
|
||||
from interp.grid import grid
|
||||
from interp.grid.simplex import face
|
||||
from interp.grid.simplex import cell
|
||||
from interp.tools import exact_func, exact_func_3D
|
||||
|
||||
|
||||
@@ -58,45 +58,45 @@ class gmsh_grid(grid):
|
||||
gmsh_file.readline() # $EndNodes
|
||||
gmsh_file.readline() # $Elements
|
||||
|
||||
# temporary dict used to compute face connectivity
|
||||
# temporary dict used to compute cell connectivity
|
||||
neighbors = {}
|
||||
|
||||
element_count = int(gmsh_file.readline())
|
||||
for i in xrange(element_count):
|
||||
cur_line = gmsh_file.readline()
|
||||
cur_line = cur_line.split()
|
||||
cur_face_index, node_type, rest = (int(cur_line[0]),
|
||||
cur_cell_index, node_type, rest = (int(cur_line[0]),
|
||||
int(cur_line[1]),
|
||||
[int(j) for j in cur_line[2:]])
|
||||
|
||||
if(node_type == THREE_NODE_TRIANGLE):
|
||||
points_for_cur_face = [i-1 for i in rest[rest[0]+1:]]
|
||||
points_for_cur_cell = [i-1 for i in rest[rest[0]+1:]]
|
||||
|
||||
cur_face = face(cur_face_index)
|
||||
cur_cell = cell(cur_cell_index)
|
||||
|
||||
for cur_point in points_for_cur_face:
|
||||
self.faces_for_vert[cur_point].append(cur_face)
|
||||
for cur_point in points_for_cur_cell:
|
||||
self.cells_for_vert[cur_point].append(cur_cell)
|
||||
|
||||
cur_face.verts = points_for_cur_face
|
||||
cur_cell.verts = points_for_cur_cell
|
||||
|
||||
self.faces[cur_face_index] = cur_face
|
||||
edges = [tuple(sorted(i)) for i in combinations(points_for_cur_face, EDGES_FOR_FACE_CONNECTIVITY)]
|
||||
self.cells[cur_cell_index] = cur_cell
|
||||
edges = [tuple(sorted(i)) for i in combinations(points_for_cur_cell, EDGES_FOR_FACE_CONNECTIVITY)]
|
||||
|
||||
# edge is two verts
|
||||
for edge in edges:
|
||||
if edge in neighbors:
|
||||
neighbors[edge].append(cur_face_index)
|
||||
neighbors[edge].append(cur_cell_index)
|
||||
else:
|
||||
neighbors[edge] = [cur_face_index]
|
||||
neighbors[edge] = [cur_cell_index]
|
||||
|
||||
for k,v in neighbors.iteritems():
|
||||
if len(v) > 1:
|
||||
self.faces[v[0]].add_neighbor(self.faces[v[1]])
|
||||
self.faces[v[1]].add_neighbor(self.faces[v[0]])
|
||||
self.cells[v[0]].add_neighbor(self.cells[v[1]])
|
||||
self.cells[v[1]].add_neighbor(self.cells[v[0]])
|
||||
|
||||
def dump_to_blender_files(self, pfile = '/tmp/points.p', ffile = '/tmp/faces.p'):
|
||||
def dump_to_blender_files(self, pfile = '/tmp/points.p', ffile = '/tmp/cells.p'):
|
||||
pickle.dump([(p[0], p[1], p[2]) for p in self.verts], open(pfile, 'w'))
|
||||
pickle.dump([f.verts for f in self.faces.itervalues()], open(ffile, 'w'))
|
||||
pickle.dump([f.verts for f in self.cells.itervalues()], open(ffile, 'w'))
|
||||
|
||||
class gmsh_grid3D(grid):
|
||||
|
||||
@@ -136,41 +136,41 @@ class gmsh_grid3D(grid):
|
||||
gmsh_file.readline() # $EndNodes
|
||||
gmsh_file.readline() # $Elements
|
||||
|
||||
# temporary dict used to compute face connectivity
|
||||
# temporary dict used to compute cell connectivity
|
||||
neighbors = {}
|
||||
|
||||
element_count = int(gmsh_file.readline())
|
||||
for i in xrange(element_count):
|
||||
cur_line = gmsh_file.readline()
|
||||
cur_line = cur_line.split()
|
||||
cur_face_index, node_type, rest = (int(cur_line[0]),
|
||||
cur_cell_index, node_type, rest = (int(cur_line[0]),
|
||||
int(cur_line[1]),
|
||||
[int(j) for j in cur_line[2:]])
|
||||
|
||||
if(node_type == FOUR_NODE_TET):
|
||||
points_for_cur_face = [i-1 for i in rest[rest[0]+1:]]
|
||||
points_for_cur_cell = [i-1 for i in rest[rest[0]+1:]]
|
||||
|
||||
cur_face = face(cur_face_index)
|
||||
cur_cell = cell(cur_cell_index)
|
||||
|
||||
for cur_point in points_for_cur_face:
|
||||
self.faces_for_vert[cur_point].append(cur_face)
|
||||
for cur_point in points_for_cur_cell:
|
||||
self.cells_for_vert[cur_point].append(cur_cell)
|
||||
|
||||
cur_face.verts = points_for_cur_face
|
||||
cur_cell.verts = points_for_cur_cell
|
||||
|
||||
self.faces[cur_face_index] = cur_face
|
||||
edges = [tuple(sorted(i)) for i in combinations(points_for_cur_face, EDGES_FOR_VOLUME_CONNECTIVITY)]
|
||||
self.cells[cur_cell_index] = cur_cell
|
||||
edges = [tuple(sorted(i)) for i in combinations(points_for_cur_cell, EDGES_FOR_VOLUME_CONNECTIVITY)]
|
||||
|
||||
for edge in edges:
|
||||
if edge in neighbors:
|
||||
neighbors[edge].append(cur_face_index)
|
||||
neighbors[edge].append(cur_cell_index)
|
||||
else:
|
||||
neighbors[edge] = [cur_face_index]
|
||||
neighbors[edge] = [cur_cell_index]
|
||||
|
||||
for k,v in neighbors.iteritems():
|
||||
if len(v) > 1:
|
||||
self.faces[v[0]].add_neighbor(self.faces[v[1]])
|
||||
self.faces[v[1]].add_neighbor(self.faces[v[0]])
|
||||
self.cells[v[0]].add_neighbor(self.cells[v[1]])
|
||||
self.cells[v[1]].add_neighbor(self.cells[v[0]])
|
||||
|
||||
def dump_to_blender_files(self, pfile = '/tmp/points.p', ffile = '/tmp/faces.p'):
|
||||
def dump_to_blender_files(self, pfile = '/tmp/points.p', ffile = '/tmp/cells.p'):
|
||||
pickle.dump([(p[0], p[1], p[2]) for p in self.verts], open(pfile, 'w'))
|
||||
pickle.dump([f.verts for f in self.faces.itervalues()], open(ffile, 'w'))
|
||||
pickle.dump([f.verts for f in self.cells.itervalues()], open(ffile, 'w'))
|
||||
|
||||
Reference in New Issue
Block a user