예제 #1
0
파일: driver.py 프로젝트: msebaa/pydec
        v = A[:, j].copy()
        if A[i, j] > 0:
            v[i] += norm(v)
        else:
            v[i] -= norm(v)
        Q = eye(A.shape[0]) - 2 * outer(v, v) / inner(v, v)

        A = dot(Q, A)

    return A


seed(1)  # make results consistent

# Read in mesh data from file
mesh = read_mesh('mesh_example.xml')

vertices = mesh.vertices
triangles = mesh.elements

# remove some triangle from the mesh
triangles = triangles[
    list(set(range(len(triangles))) - set([30, 320, 21, 198])), :]

sc = simplicial_complex((vertices, triangles))

H = []  # harmonic forms

# decompose 4 random 1-cochains
for i in range(4):
    omega = sc.get_cochain(1)
예제 #2
0
"""
Reads ascii vertex and element files, writes a pydec mesh and displays it
"""

import scipy
from pydec import SimplicialMesh, write_mesh, read_mesh
from matplotlib.pylab import triplot, show

vertices = scipy.loadtxt("v.txt")
elements = scipy.loadtxt("s.txt",dtype='int32') - 1
mymesh = SimplicialMesh(vertices=vertices,indices=elements)
write_mesh("square_8.xml",mymesh,format='basic')
rmesh = read_mesh("square_8.xml")
triplot(rmesh.vertices[:,0], rmesh.vertices[:,1], rmesh.indices)

show()

예제 #3
0
"""
Reads ascii vertex and element files, writes a pydec mesh and displays it
"""

import scipy
from pydec import SimplicialMesh, write_mesh, read_mesh
from matplotlib.pylab import triplot, show

vertices = scipy.loadtxt("v.txt")
elements = scipy.loadtxt("s.txt", dtype='int32') - 1
mymesh = SimplicialMesh(vertices=vertices, indices=elements)
write_mesh("square_8.xml", mymesh, format='basic')
rmesh = read_mesh("square_8.xml")
triplot(rmesh.vertices[:, 0], rmesh.vertices[:, 1], rmesh.indices)

show()
예제 #4
0
     
        v = A[:,j].copy()
        if A[i,j] > 0:
            v[i] += norm(v)
        else:
            v[i] -= norm(v)
        Q = eye(A.shape[0]) - 2 * outer(v,v) / inner(v,v)

        A = dot(Q,A)

    return A

seed(0) # make results consistent

# Read in mesh data from file
mesh = read_mesh('mesh_example.xml')

vertices  = mesh.vertices
triangles = mesh.elements

# remove some triangle from the mesh
triangles = triangles[list(set(range(len(triangles))) - set([30,320,21,198])),:]

sc = simplicial_complex((vertices,triangles))

H = []  # harmonic forms

# decompose 4 random 1-cochains
for i in range(4):
    omega = sc.get_cochain(1)
    omega.v[:] = rand(*omega.v.shape)