In [2]:
from dolfin import *
import numpy
nn = 1
mesh = UnitCubeMesh(int(nn),int(nn),int(nn))
order = 1
parameters['reorder_dofs_serial'] = False
Magnetic = FunctionSpace(mesh, "N1curl", order)
Lagrange = FunctionSpace(mesh, "CG", order)
print Magnetic.dim()
def boundary(x, on_boundary):
        return on_boundary


DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
19

In [6]:
B = BoundaryMesh(Magnetic.mesh(),"exterior",False)
numpy.sort(B.entity_map(1).array().astype("float_","C"))


Out[6]:
array([  2.,   4.,   5.,   7.,  11.,  12.,  13.,  15.])

In [13]:
E = EdgeFunctionBool(mesh)
print E.array()
VertexBoundary = numpy.zeros(mesh.num_edges())
VertexBoundary[E.array()] = 1
print VertexBoundary


[False False False False False False False False  True  True  True  True
 False False False False]
[ 0.  0.  0.  0.  0.  0.  0.  0.  1.  1.  1.  1.  0.  0.  0.  0.]

In [14]:
B = BoundaryMesh(Magnetic.mesh(),"exterior",False)
print numpy.sort(B.entity_map(0).array().astype("float_","C"))
bb = numpy.sort(B.entity_map(0).array().astype("float_","C"))
print numpy.sort(B.entity_map(1).array().astype("float_","C"))


[  0.   1.   2.   3.   4.   5.   9.  10.  14.  15.  19.  20.  21.  22.  23.
  24.]
[  2.   4.   7.  11.  13.  15.  20.  27.  33.  40.  45.  46.  49.  52.  53.
  55.]

In [33]:
B = BoundaryMesh(Magnetic.mesh(),"exterior")
B.entity_map(0).array()


Out[33]:
array([ 0,  1,  4, 10,  9,  3, 12,  2,  5, 14, 11,  7,  6, 16, 15,  8, 17,
       19, 18, 22, 21, 23, 20, 25, 24, 26], dtype=uint64)

In [2]:
plot(mesh)


Out[2]:
<dolfin.cpp.io.VTKPlotter; proxy of <Swig Object of type 'std::shared_ptr< dolfin::VTKPlotter > *' at 0x4a6d720> >

In [33]:
b = SparsityPatternBuilder()

In [2]:
B = EdgeFunctionBool(mesh)

In [2]:
B = BoundaryMesh(mesh,"exterior")

In [3]:
bb = B.entity_map(2).array()
print bb


[ 0  3  4  6  7  9 10 12 13 15 16 17]

In [3]:
B = BoundaryMesh(mesh,"exterior")
bb = B.entity_map(2).array()
k = 0
kk = 0
VertexBoundary = numpy.zeros(3*bb.size)
for i in range(bb.size):
    face = Face(mesh,bb[i])
    
    print face.index()
    print face.entities(0)


0
[1 3 7]
3
[0 1 3]
4
[1 5 7]
6
[0 1 5]
7
[4 5 7]
9
[0 4 5]
10
[2 3 7]
12
[0 2 3]
13
[4 6 7]
15
[0 4 6]
16
[2 6 7]
17
[0 2 6]

In [33]:
%timeit
B = BoundaryMesh(mesh,"exterior")
bb = B.entity_map(2).array()
k = 0
kk = 0
VertexBoundary = numpy.zeros(3*bb.size)
for face in faces(mesh):
        if face.index() == bb[k]:
            k = k+1
#             print "\nface", face.index()
            for edge in edges(face):
#                 print "      edge", edge.index()
                VertexBoundary[kk] = edge.index()
                kk = kk+1
# VertexBoundary

In [47]:
V = numpy.sort(VertexBoundary)
V


Out[47]:
array([  2.,   2.,   4.,   4.,   5.,   5.,   7.,   7.,   8.,   8.,  10.,
        10.,  11.,  11.,  13.,  13.,  14.,  14.,  16.,  16.,  17.,  17.,
        18.,  18.,  19.,  19.,  20.,  20.,  21.,  21.,  23.,  23.,  24.,
        24.,  25.,  25.,  26.,  26.,  27.,  27.,  29.,  29.,  31.,  31.,
        33.,  33.,  35.,  35.,  37.,  37.,  40.,  40.,  41.,  41.,  42.,
        42.,  43.,  43.,  44.,  44.,  45.,  45.,  46.,  46.,  47.,  47.,
        48.,  48.,  49.,  49.,  51.,  51.,  52.,  52.,  54.,  54.,  55.,
        55.,  56.,  56.,  60.,  60.,  61.,  61.,  62.,  62.,  63.,  63.,
        64.,  64.,  65.,  65.,  67.,  67.,  68.,  68.,  69.,  69.,  70.,
        70.,  71.,  71.,  72.,  72.,  74.,  74.,  75.,  75.,  76.,  76.,
        77.,  77.,  78.,  78.,  80.,  80.,  81.,  81.,  84.,  84.,  85.,
        85.,  86.,  86.,  87.,  87.,  88.,  88.,  89.,  89.,  90.,  90.,
        91.,  91.,  92.,  92.,  94.,  94.,  95.,  95.,  96.,  96.,  97.,
        97.])

In [48]:
V[::2]


Out[48]:
array([  2.,   4.,   5.,   7.,   8.,  10.,  11.,  13.,  14.,  16.,  17.,
        18.,  19.,  20.,  21.,  23.,  24.,  25.,  26.,  27.,  29.,  31.,
        33.,  35.,  37.,  40.,  41.,  42.,  43.,  44.,  45.,  46.,  47.,
        48.,  49.,  51.,  52.,  54.,  55.,  56.,  60.,  61.,  62.,  63.,
        64.,  65.,  67.,  68.,  69.,  70.,  71.,  72.,  74.,  75.,  76.,
        77.,  78.,  80.,  81.,  84.,  85.,  86.,  87.,  88.,  89.,  90.,
        91.,  92.,  94.,  95.,  96.,  97.])