Iterate connected mesh entities in parallel

I was thinking something in this fashion:

import dolfin as df
class top(df.SubDomain):
    def inside(self, x, on_boundary):
        return x[2] > 1-1e-6 and on_boundary

mesh = df.UnitCubeMesh(10,10,10)
mesh.init()
mf = df.MeshFunction("size_t", mesh, mesh.topology().dim()-1)
mf.set_all(0)
top().mark(mf, 1)
# Custom measure for top plane, as the normal at sharp corners are really well defined.
dTop = df.ds(domain=mesh, subdomain_data=mf, subdomain_id=1)
V = df.FunctionSpace(mesh, "Lagrange", 2)
z = df.Function(V, name="z")
p,q = df.TrialFunction(V), df.TestFunction(V)
h = df.FacetArea(mesh)
n = df.FacetNormal(mesh)
L = df.assemble(n[2]*q*dTop)
A = df.assemble(p*q*dTop,keep_diagonal=True)
A.ident_zeros()
df.solve(A, z.vector(), L)
df.XDMFFile(df.MPI.comm_world, "z.xdmf").write(z)

1 Like