Esempio n. 1
0
from dolfin import *
from fenicstools import DofMapPlotter
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()

mesh = UnitSquareMesh(5, 5)
V = FunctionSpace(mesh, 'CG', 1)
if rank == 0:
    dmp = DofMapPlotter(V)
    print(
        """Pressing C, E, v with mouse hovering over cells 0 and 1 and d with mouse over cell 40 and 41 will light up cell and edge indices for the entire mesh and vertex and dof indices in cells 0, 1 and 40, 41 respectively. Thus we see that first mesh vertex is located at [0, 0] while the first dof is located at [0, 1]. The assignement u.vector[0] thus modifies the function's value at [0, 1]."""
    )
    dmp.plot()
    dmp.show()
Esempio n. 2
0
dmp = DofMapPlotter(M)

# See how many dofmaps can be plotted
n_dofmaps = dmp.num_dofmaps()
# M is represented by signature [gdim, 1, 1] so there are gdim + 2 dofmaps

# Create plot which will show all dofmaps. Use global ordering scheme for dofs
# and mesh entities. plot(order='local') to switch to local ordering scheme
dmp.plot()
#dmp.show()   # Comment out to
#exit()       # showcase other capabilities

# Create plot which will show only dofs of single dofmap
for i in range(n_dofmaps):
    dmp.plot(component=i)

# Plot dofmaps of first component of V and Q, S
dmp.plot(component=[0, n_dofmaps-2, n_dofmaps-1])

# Access dofmaps by subspaces
n_subspaces = dmp.num_subspaces()
for sub in range(n_subspaces):
    dmp.plot(sub=sub)

# Give plot xkcd flavor
dmp_xkcd = DofMapPlotter(M, options={'xkcd': True})
dmp_xkcd.plot()

# Show the plots
dmp.show()