So I'm trying to simply set a function equal to zero where I have set a CellFunction equal to zero:
from fenics import *
from numpy import where
mesh = UnitCubeMesh(10,10,10)
Q = FunctionSpace(mesh, 'CG', 1)
f = Function(Q)
c = CellFunction('size_t', mesh, 0)
c[-1] = 1
dofmap = Q.dofmap()
cells = where(c.array() == 1)[0]
dofs = []
for i in cells:
dofs.extend(dofmap.cell_dofs(i))
dofs = list(set(dofs))
print MPI.rank(mpi_comm_world()), "dofs:", dofs
f.vector()[dofs] = 1.0
This works in serial, but in parallel I get a
IndexError: expected indices to be in [0..333]
IndexError: expected indices to be in [0..333]
IndexError: expected indices to be in [0..350]
I'm trying to find a local-to-global mapping, which is what I think I need to relate the dofmap.cell_dofs back to local vertices, right?