コード例 #1
0
 def __init__(self, V, key):
     FEniCSToolsDofMapPlotter.__init__(self, V)
     self.plot()
     assert len(self.plots) == 1
     assert key in ("C", "T", "V", "D")
     if key in ("C", "T", "V"):
         self.plots[0].mesh_entity_handler.__call__(Event(key))
     elif key in ("D", ):
         self.plots[0].dof_handler.__call__(Event(key))
     self.ax = self.plots[0].mesh_entity_handler.axes
コード例 #2
0
def test_DofMapPlotter():
    '''Test logic used in DofMapPlotter by comparing its string representation
    with FunctionSpace.print_dofmap.'''

    command =\
        '''
from dolfin import * ;
mesh = UnitSquareMesh(1, 1);
S = FunctionSpace(mesh, 'CG', 1);
V = VectorFunctionSpace(mesh, 'CR', 1);
T = TensorFunctionSpace(mesh, 'DG', 0);
M = MixedFunctionSpace([S, V, T]);
M.print_dofmap()
        '''
    # Get output of FunctionSpace.print_dofmap (only print to terminal)
    # Pull back
    # This is run two times just in case FFC sees the spaces for the first time
    # in which case there are some messages printed to terminal and these
    # screw up with the test.
    for i in range(2):
        process = subprocess.Popen(['python', '-c', command],
                                stdout=subprocess.PIPE)
        dolfin_out, _ = process.communicate()
        # print dolfin_out

    # Run the command here to create spaces etc.
    exec(command)

    dmp = DofMapPlotter(M)
    dmp_out = dmp.__str__()

    # The string should match (can't make simple == for strings to work)
    maps_match = all(x == y for x, y in zip(dmp_out, dolfin_out))

    # Visual check
    # dmp_lines = dmp_out.split('\n')
    # dolfin_lines = dolfin_out.split('\n')
    # for dmp_line, dolfin_line in zip(dmp_lines, dolfin_lines):
    #     print dmp_line, ' vs. ', dolfin_line

    nose.tools.assert_true(maps_match)
コード例 #3
0
def test_DofMapPlotter():
    '''Test logic used in DofMapPlotter by comparing its string representation
    with FunctionSpace.print_dofmap.'''

    command =\
        '''
from dolfin import * ;
mesh = UnitSquareMesh(1, 1);
S = FunctionSpace(mesh, 'CG', 1);
V = VectorFunctionSpace(mesh, 'CR', 1);
T = TensorFunctionSpace(mesh, 'DG', 0);
M = MixedFunctionSpace([S, V, T]);
M.print_dofmap()
        '''
    # Get output of FunctionSpace.print_dofmap (only print to terminal)
    # Pull back
    # This is run two times just in case FFC sees the spaces for the first time
    # in which case there are some messages printed to terminal and these
    # screw up with the test.
    for i in range(2):
        process = subprocess.Popen(['python', '-c', command],
                                   stdout=subprocess.PIPE)
        dolfin_out, _ = process.communicate()
        # print dolfin_out

    # Run the command here to create spaces etc.
    exec(command)

    dmp = DofMapPlotter(M)
    dmp_out = dmp.__str__()

    # The string should match (can't make simple == for strings to work)
    maps_match = all(x == y for x, y in zip(dmp_out, dolfin_out))

    # Visual check
    # dmp_lines = dmp_out.split('\n')
    # dolfin_lines = dolfin_out.split('\n')
    # for dmp_line, dolfin_line in zip(dmp_lines, dolfin_lines):
    #     print dmp_line, ' vs. ', dolfin_line

    assert maps_match
コード例 #4
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()
コード例 #5
0
from dolfin import *

# Define domain and create mesh
#domain2d = Rectangle(Point(-1, -1), Point(1, 1))
#domain3d = Box(-1, -1, -1, 1, 1, 1)
mesh = RectangleMesh(Point(0, 0), Point(1, 1), 10, 10)
#mesh = Mesh(domain2d, 3)

# Create function space
V = VectorElement('CR', mesh.ufl_cell(), 1)
Q = FiniteElement('DG', mesh.ufl_cell(), 0)
S = FiniteElement('DG', mesh.ufl_cell(), 1)
M = FunctionSpace(mesh, MixedElement([V, Q, S]))

# Create DofMapPlotter for the space
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)
コード例 #6
0
from dolfin import *

# Define domain and create mesh
#domain2d = Rectangle(Point(-1, -1), Point(1, 1))
#domain3d = Box(-1, -1, -1, 1, 1, 1)
mesh = RectangleMesh(Point(0, 0), Point(1, 1), 10, 10)
#mesh = Mesh(domain2d, 3)

# Create function space
V = VectorElement('CR', mesh.ufl_cell(), 1)
Q = FiniteElement('DG', mesh.ufl_cell(), 0)
S = FiniteElement('DG', mesh.ufl_cell(), 1)
M = FunctionSpace(mesh, MixedElement([V, Q, S]))

# Create DofMapPlotter for the space
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)