コード例 #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
ファイル: make_mesh.py プロジェクト: DongliangGao/pydec
"""
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
ファイル: driver.py プロジェクト: DongliangGao/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(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)