This page contains the Vis Package documentation.
Visualization tools for coarse grids, both C/F splittings and aggregation.
Output is either to file (VTK) or to the screen (matplotlib).
vis_splitting: visualize C/F splittings through vertex elements vis_aggregate_groups: visualize aggregation through groupins of edges, elements
Coarse grid visualization for C/F splittings.
Parameters : | Verts : {array}
splitting : {array}
fname : {string, file object}
output : {string}
|
---|---|
Returns : | - Displays in screen or writes data to .vtu file for use in paraview (xml 0.1 format) : |
Notes
# of dof (= ldof * N)
Examples
>>> import numpy
>>> from pyamg.vis.vis_coarse import vis_splitting
>>> Verts = numpy.array([[0.0,0.0],
... [1.0,0.0],
... [0.0,1.0],
... [1.0,1.0]])
>>> splitting = numpy.array([0,1,0,1,1,0,1,0]) # two variables
>>> vis_splitting(Verts,splitting,output='vtk',fname='output.vtu')
>>> from pyamg.classical import RS
>>> from pyamg.vis.vis_coarse import vis_splitting
>>> from pyamg.gallery import load_example
>>> data = load_example('unit_square')
>>> A = data['A'].tocsr()
>>> V = data['vertices']
>>> E2V = data['elements']
>>> splitting = RS(A)
>>> vis_splitting(Verts=V,splitting=splitting,output='vtk',fname='output.vtu')
Coarse grid visualization of aggregate groups. Create .vtu files for use in Paraview or display with Matplotlib
Parameters : | Verts : {array}
E2V : {array}
Agg : {csr_matrix}
mesh_type : {string}
fname : {string, file object}
output : {string}
|
---|---|
Returns : | - Writes data to .vtu file for use in paraview (xml 0.1 format) or :
|
Notes
Examples
>>> from pyamg.aggregation import standard_aggregation
>>> from pyamg.vis.vis_coarse import vis_aggregate_groups
>>> from pyamg.gallery import load_example
>>> data = load_example('unit_square')
>>> A = data['A'].tocsr()
>>> V = data['vertices']
>>> E2V = data['elements']
>>> Agg = standard_aggregation(A)
>>> vis_aggregate_groups(Verts=V, E2V=E2V, Agg=Agg, mesh_type='tri', output='vtk', fname='output.vtu')
>>> from pyamg.aggregation import standard_aggregation
>>> from pyamg.vis.vis_coarse import vis_aggregate_groups
>>> from pyamg.gallery import load_example
>>> data = load_example('unit_cube')
>>> A = data['A'].tocsr()
>>> V = data['vertices']
>>> E2V = data['elements']
>>> Agg = standard_aggregation(A)
>>> vis_aggregate_groups(Verts=V, E2V=E2V, Agg=Agg, mesh_type='tet', output='vtk', fname='output.vtu')
VTK output functions.
Create coarse grid views and write meshes/primitives to .vtu files. Use the XML VTK format for unstructured meshes (.vtu)
This will use the XML VTK format for unstructured meshes, .vtu
See here for a guide: http://www.vtk.org/pdf/file-formats.pdf
Write a .vtu file in xml format
Parameters : | fname : {string}
Verts : {array}
Cells : {dictionary}
pdata : {array}
pvdata : {array}
cdata : {dictionary}
cvdata : {dictionary}
|
---|---|
Returns : | writes a .vtu file for use in Paraview : |
See also
write_mesh
Notes
keys | type | n points | dim |
---|---|---|---|
1 | VTK_VERTEX: | 1 point | 2d |
2 | VTK_POLY_VERTEX: | n points | 2d |
3 | VTK_LINE: | 2 points | 2d |
4 | VTK_POLY_LINE: | n+1 points | 2d |
5 | VTK_TRIANGLE: | 3 points | 2d |
6 | VTK_TRIANGLE_STRIP: | n+2 points | 2d |
7 | VTK_POLYGON: | n points | 2d |
8 | VTK_PIXEL: | 4 points | 2d |
9 | VTK_QUAD: | 4 points | 2d |
10 | VTK_TETRA: | 4 points | 3d |
11 | VTK_VOXEL: | 8 points | 3d |
12 | VTK_HEXAHEDRON: | 8 points | 3d |
13 | VTK_WEDGE: | 6 points | 3d |
14 | VTK_PYRAMID: | 5 points | 3d |
Examples
>>> import numpy
>>> Verts = numpy.array([[0.0,0.0],
... [1.0,0.0],
... [2.0,0.0],
... [0.0,1.0],
... [1.0,1.0],
... [2.0,1.0],
... [0.0,2.0],
... [1.0,2.0],
... [2.0,2.0],
... [0.0,3.0],
... [1.0,3.0],
... [2.0,3.0]])
>>> E2V = numpy.array([[0,4,3],
... [0,1,4],
... [1,5,4],
... [1,2,5],
... [3,7,6],
... [3,4,7],
... [4,8,7],
... [4,5,8],
... [6,10,9],
... [6,7,10],
... [7,11,10],
... [7,8,11]])
>>> E2edge = numpy.array([[0,1]])
>>> E2point = numpy.array([2,3,4,5])
>>> Cells = {5:E2V,3:E2edge,1:E2point}
>>> pdata=numpy.ones((12,2))
>>> pvdata=numpy.ones((12*3,2))
>>> cdata={5:numpy.ones((12,2)),3:numpy.ones((1,2)),1:numpy.ones((4,2))}
>>> cvdata={5:numpy.ones((3*12,2)),3:numpy.ones((3*1,2)),1:numpy.ones((3*4,2))}
>>> write_vtu(Verts=Verts, Cells=Cells, fname='test.vtu')
Write mesh file for basic types of elements
Parameters : | fname : {string}
Verts : {array}
E2V : {array}
mesh_type : {string}
pdata : {array}
pvdata : {array}
cdata : {array}
cvdata : {array}
|
---|---|
Returns : | writes a .vtu file for use in Paraview : |
See also
Notes
The difference between write_basic_mesh and write_vtu is that write_vtu is more general and requires dictionaries of cell information. write_basic_mesh calls write_vtu
Examples
>>> import numpy
>>> Verts = numpy.array([[0.0,0.0],
... [1.0,0.0],
... [2.0,0.0],
... [0.0,1.0],
... [1.0,1.0],
... [2.0,1.0],
... [0.0,2.0],
... [1.0,2.0],
... [2.0,2.0],
... [0.0,3.0],
... [1.0,3.0],
... [2.0,3.0]])
>>> E2V = numpy.array([[0,4,3],
... [0,1,4],
... [1,5,4],
... [1,2,5],
... [3,7,6],
... [3,4,7],
... [4,8,7],
... [4,5,8],
... [6,10,9],
... [6,7,10],
... [7,11,10],
... [7,8,11]])
>>> pdata=numpy.ones((12,2))
>>> pvdata=numpy.ones((12*3,2))
>>> cdata=numpy.ones((12,2))
>>> cvdata=numpy.ones((3*12,2))
>>> write_basic_mesh(Verts, E2V=E2V, mesh_type='tri',pdata=pdata, pvdata=pvdata, cdata=cdata, cvdata=cvdata, fname='test.vtu')