changed the location of the declaration of global vars

This commit is contained in:
Stephen McQuay 2010-11-01 20:21:47 -06:00
parent 0f2581f04d
commit 6f63173489

View File

@ -8,10 +8,19 @@ from scipy.spatial import KDTree
from interp.grid import grid from interp.grid import grid
from interp.grid.simplex import face from interp.grid.simplex import face
from interp.tools import exact_func from interp.tools import exact_func, exact_func_3D
THREE_NODE_TRIANGLE = 2
FOUR_NODE_TET = 4
EDGES_FOR_FACE_CONNECTIVITY = 2
EDGES_FOR_VOLUME_CONNECTIVITY = 3
class gmsh_grid(grid): class gmsh_grid(grid):
THREE_NODE_TRIANGLE = 2
def __init__(self, filename): def __init__(self, filename):
""" """
@ -60,7 +69,7 @@ class gmsh_grid(grid):
int(cur_line[1]), int(cur_line[1]),
[int(j) for j in cur_line[2:]]) [int(j) for j in cur_line[2:]])
if(node_type == gmsh_grid.THREE_NODE_TRIANGLE): if(node_type == THREE_NODE_TRIANGLE):
points_for_cur_face = [i-1 for i in rest[rest[0]+1:]] points_for_cur_face = [i-1 for i in rest[rest[0]+1:]]
cur_face = face(cur_face_index) cur_face = face(cur_face_index)
@ -71,7 +80,7 @@ class gmsh_grid(grid):
cur_face.verts = points_for_cur_face cur_face.verts = points_for_cur_face
self.faces[cur_face_index] = cur_face self.faces[cur_face_index] = cur_face
edges = [tuple(sorted(i)) for i in combinations(points_for_cur_face, 2)] edges = [tuple(sorted(i)) for i in combinations(points_for_cur_face, EDGES_FOR_FACE_CONNECTIVITY)]
# edge is two verts # edge is two verts
for edge in edges: for edge in edges:
@ -90,7 +99,6 @@ class gmsh_grid(grid):
pickle.dump([f.verts for f in self.faces.itervalues()], open(ffile, 'w')) pickle.dump([f.verts for f in self.faces.itervalues()], open(ffile, 'w'))
class gmsh_grid3D(grid): class gmsh_grid3D(grid):
FOUR_NODE_TET = 4
def __init__(self, filename): def __init__(self, filename):
""" """
@ -120,7 +128,7 @@ class gmsh_grid3D(grid):
self.verts[i][0] = float(x) self.verts[i][0] = float(x)
self.verts[i][1] = float(y) self.verts[i][1] = float(y)
self.verts[i][2] = float(z) self.verts[i][2] = float(z)
self.q[i] = exact_func(self.verts[i]) self.q[i] = exact_func_3D(self.verts[i])
grid.__init__(self) grid.__init__(self)
@ -139,7 +147,7 @@ class gmsh_grid3D(grid):
int(cur_line[1]), int(cur_line[1]),
[int(j) for j in cur_line[2:]]) [int(j) for j in cur_line[2:]])
if(node_type == gmsh_grid3D.FOUR_NODE_TET): if(node_type == FOUR_NODE_TET):
points_for_cur_face = [i-1 for i in rest[rest[0]+1:]] points_for_cur_face = [i-1 for i in rest[rest[0]+1:]]
cur_face = face(cur_face_index) cur_face = face(cur_face_index)
@ -150,9 +158,8 @@ class gmsh_grid3D(grid):
cur_face.verts = points_for_cur_face cur_face.verts = points_for_cur_face
self.faces[cur_face_index] = cur_face self.faces[cur_face_index] = cur_face
edges = [tuple(sorted(i)) for i in combinations(points_for_cur_face, 3)] edges = [tuple(sorted(i)) for i in combinations(points_for_cur_face, EDGES_FOR_VOLUME_CONNECTIVITY)]
# edge is two verts
for edge in edges: for edge in edges:
if edge in neighbors: if edge in neighbors:
neighbors[edge].append(cur_face_index) neighbors[edge].append(cur_face_index)