Пример #1
0
inner_edges = AggOp.indices[E[:, 0]] == AggOp.indices[E[:, 1]]
outer_edges = -inner_edges

# Grab the root-nodes (i.e., the C/F splitting)
Cpts = mls.levels[0].Cpts
Fpts = mls.levels[0].Fpts

from draw import lineplot
from pylab import figure, axis, scatter, show, title

##
# Plot the aggregation
figure(figsize=(6, 6))
title('Finest-Level Aggregation\nC-pts in Red, F-pts in Blue')
axis('equal')
lineplot(V, E[inner_edges], linewidths=3.0)
lineplot(V, E[outer_edges], linewidths=0.2)
scatter(V[:, 0][Fpts], V[:, 1][Fpts], c='b', s=100.0)  #plot F-nodes in blue
scatter(V[:, 0][Cpts], V[:, 1][Cpts], c='r', s=220.0)  #plot C-nodes in red

##
# Plot the C/F splitting
figure(figsize=(6, 6))
title('Finest-Level C/F splitting\nC-pts in Red, F-pts in Blue')
axis('equal')
lineplot(V, E)
scatter(V[:, 0][Cpts], V[:, 1][Cpts], c='r', s=100.0)  #plot C-nodes in red
scatter(V[:, 0][Fpts], V[:, 1][Fpts], c='b', s=100.0)  #plot F-nodes in blue

show()
Пример #2
0
inner_edges = AggOp.indices[E[:,0]] == AggOp.indices[E[:,1]]  
outer_edges = -inner_edges

# Grab the root-nodes (i.e., the C/F splitting)
Cpts = mls.levels[0].Cpts
Fpts = mls.levels[0].Fpts

from draw import lineplot
from pylab import figure, axis, scatter, show, title

##
# Plot the aggregation
figure(figsize=(6,6))
title('Finest-Level Aggregation\nC-pts in Red, F-pts in Blue')
axis('equal')
lineplot(V, E[inner_edges], linewidths=3.0)
lineplot(V, E[outer_edges], linewidths=0.2)
scatter(V[:,0][Fpts], V[:,1][Fpts], c='b', s=100.0)  #plot F-nodes in blue
scatter(V[:,0][Cpts], V[:,1][Cpts], c='r', s=220.0)  #plot C-nodes in red

##
# Plot the C/F splitting
figure(figsize=(6,6))
title('Finest-Level C/F splitting\nC-pts in Red, F-pts in Blue')
axis('equal')
lineplot(V, E)
scatter(V[:,0][Cpts], V[:,1][Cpts], c='r', s=100.0)  #plot C-nodes in red
scatter(V[:,0][Fpts], V[:,1][Fpts], c='b', s=100.0)  #plot F-nodes in blue

show()
 
Пример #3
0
import numpy
from scipy.io import loadmat
from pyamg import ruge_stuben_solver
from pyamg.gallery import load_example

data = loadmat('square.mat') #load_example('airfoil')

A = data['A']                                # matrix
V = data['vertices'][:A.shape[0]]            # vertices of each variable
E = numpy.vstack((A.tocoo().row,A.tocoo().col)).T  # edges of the matrix graph

# Use Ruge-Stuben Splitting Algorithm (use 'keep' in order to retain the splitting)
mls = ruge_stuben_solver(A, max_levels=2, max_coarse=1, CF='RS',keep=True)
print mls

# The CF splitting, 1 == C-node and 0 == F-node
splitting = mls.levels[0].splitting
C_nodes = splitting == 1
F_nodes = splitting == 0

from draw import lineplot
from pylab import figure, axis, scatter, show

figure(figsize=(6,6))
axis('equal')
lineplot(V, E)
scatter(V[:,0][C_nodes], V[:,1][C_nodes], c='r', s=100.0)  #plot C-nodes in red
scatter(V[:,0][F_nodes], V[:,1][F_nodes], c='b', s=100.0)  #plot F-nodes in blue
show()
 
Пример #4
0
from scipy.io import loadmat
from pyamg import ruge_stuben_solver
from pyamg.gallery import load_example

data = loadmat('square.mat')  #load_example('airfoil')

A = data['A']  # matrix
V = data['vertices'][:A.shape[0]]  # vertices of each variable
E = numpy.vstack((A.tocoo().row, A.tocoo().col)).T  # edges of the matrix graph

# Use Ruge-Stuben Splitting Algorithm (use 'keep' in order to retain the splitting)
mls = ruge_stuben_solver(A, max_levels=2, max_coarse=1, CF='RS', keep=True)
print mls

# The CF splitting, 1 == C-node and 0 == F-node
splitting = mls.levels[0].splitting
C_nodes = splitting == 1
F_nodes = splitting == 0

from draw import lineplot
from pylab import figure, axis, scatter, show

figure(figsize=(6, 6))
axis('equal')
lineplot(V, E)
scatter(V[:, 0][C_nodes], V[:, 1][C_nodes], c='r',
        s=100.0)  #plot C-nodes in red
scatter(V[:, 0][F_nodes], V[:, 1][F_nodes], c='b',
        s=100.0)  #plot F-nodes in blue
show()