Repository navigation
Expand file tree
/
Copy pathvisualize_matrices.py
More file actions
64 lines (51 loc) · 1.51 KB
/
Copy pathvisualize_matrices.py
File metadata and controls
64 lines (51 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Post-processing script for example `poisson_2d_mapping.py`.
Plot the mass and stiffness matrices built in the tensor-product spline space V
and in the C1 polar spline space V'.
USAGE
=====
$ ipython
In [1]: run poisson_2d_mapping.py -t target -n 10 20 -s -c
In [2]: run -i visualize_matrices.py
"""
from matplotlib import colors
globals().update(namespace)
#===============================================================================
#----------------
# Plot M
mat = M.toarray()
#----------------
fig,ax = plt.subplots(1,1)
ax.set_title("Tensor-product mass matrix M")
im = ax.matshow(mat, norm=colors.LogNorm(), cmap='hot_r')
cb = fig.colorbar(im, ax=ax)
fig.show()
#----------------
# Plot M'
mat = Mp.toarray()
#----------------
fig,ax = plt.subplots(1,1)
ax.set_title("C^1 mass matrix M' (projection of M)")
im = ax.matshow(mat, norm=colors.LogNorm(), cmap='hot_r')
cb = fig.colorbar(im, ax=ax)
fig.show()
#----------------
# Plot S
mat = S.toarray()
#----------------
fig,ax = plt.subplots(1,1)
ax.set_title("Tensor-product stiffness matrix S")
norm = colors.SymLogNorm(linthresh=1.0e-8, vmin=mat.min(), vmax=mat.max())
im = ax.matshow(mat, norm=norm, cmap='seismic')
cb = fig.colorbar(im, ax=ax)
fig.show()
#----------------
# Plot S'
mat = Sp.toarray()
#----------------
fig,ax = plt.subplots(1,1)
ax.set_title("C^1 stiffness matrix S' (projection of S)")
norm = colors.SymLogNorm(linthresh=1.0e-6, vmin=-mat.max(), vmax=mat.max())
im = ax.matshow(mat, norm=norm, cmap='seismic')
cb = fig.colorbar(im, ax=ax)
fig.show()