Navigation Menu

Skip to content

Commit

Permalink
PEP8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed May 24, 2016
1 parent af8ea0a commit 40cc84a
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions meshpy/tools.py
@@ -1,6 +1,9 @@
from __future__ import absolute_import

import six
from six.moves import range


def uniform_refine_triangles(points, elements, factor=2):
new_points = points[:]
new_elements = []
Expand All @@ -17,14 +20,14 @@ def get_refined_face(a, b):
flipped = False

try:
face_points = face_point_dict[a,b]
face_points = face_point_dict[a, b]
except KeyError:
a_pt, b_pt = [points[idx] for idx in [a, b]]
dx = (b_pt - a_pt)/factor

# build subdivided facet
face_points = [a]

for i in range(1, points_per_edge-1):
face_points.append(len(new_points))
new_points.append(a_pt + dx*i)
Expand All @@ -34,7 +37,7 @@ def get_refined_face(a, b):
face_point_dict[a, b] = face_points

# build old_face_to_new_faces
old_face_to_new_faces[frozenset([a,b])] = [
old_face_to_new_faces[frozenset([a, b])] = [
(face_points[i], face_points[i+1])
for i in range(factor)]

Expand All @@ -47,38 +50,38 @@ def get_refined_face(a, b):
a_pt, b_pt, c_pt = [points[idx] for idx in [a, b, c]]
dr = (b_pt - a_pt)/factor
ds = (c_pt - a_pt)/factor

ab_refined, bc_refined, ac_refined = [
get_refined_face(*pt_indices)
for pt_indices in [(a,b), (b,c), (a,c)]]
for pt_indices in [(a, b), (b, c), (a, c)]]

el_point_dict = {}

# fill out edges of el_point_dict
for i in range(points_per_edge):
el_point_dict[i,0] = ab_refined[i]
el_point_dict[0,i] = ac_refined[i]
el_point_dict[points_per_edge-1-i,i] = bc_refined[i]
el_point_dict[i, 0] = ab_refined[i]
el_point_dict[0, i] = ac_refined[i]
el_point_dict[points_per_edge-1-i, i] = bc_refined[i]

# fill out interior of el_point_dict
for i in range(1, points_per_edge-1):
for j in range(1, points_per_edge-1-i):
el_point_dict[i,j] = len(new_points)
el_point_dict[i, j] = len(new_points)
new_points.append(a_pt + dr*i + ds*j)

# generate elements
for i in range(0, points_per_edge-1):
for j in range(0, points_per_edge-1-i):
new_elements.append((
el_point_dict[i,j],
el_point_dict[i+1,j],
el_point_dict[i,j+1],
el_point_dict[i, j],
el_point_dict[i+1, j],
el_point_dict[i, j+1],
))
if i+1+j+1 <= factor:
new_elements.append((
el_point_dict[i+1,j+1],
el_point_dict[i+1,j],
el_point_dict[i,j+1],
el_point_dict[i+1, j+1],
el_point_dict[i+1, j],
el_point_dict[i, j+1],
))

from meshpy.triangle import MeshInfo
Expand All @@ -93,8 +96,6 @@ def get_refined_face(a, b):
return new_points, new_elements, old_face_to_new_faces




def make_swizzle_matrix(spec):
import numpy
axes = ["x", "y", "z"]
Expand Down Expand Up @@ -124,4 +125,3 @@ def make_swizzle_matrix(spec):
result[final_axis, imp_axis] = sign

return result

0 comments on commit 40cc84a

Please sign in to comment.