On Wed, 29 Jan 2014 11:35:35 -0800 Nikolaus Rath <[email protected]> wrote:
> Hello, > > I'm trying to set a function to zero everyone except on the mesh > boundary. I have come up with this code: > > from dolfin import * > mesh = UnitCubeMesh(16, 16, 16) > bmesh = BoundaryMesh(mesh, 'exterior') > boundary_points = bmesh.entity_map(0).array() > V = FunctionSpace(mesh, 'Lagrange', 1) > g = Function(V) > g.vector()[boundary_points] = 1 > plot(g, mesh, interactive=True) > > However, when looking at the plot, only about half the boundary cells > seem colored. > > What am I doing wrong? There is generally no guarantee that DOFs (indeces of vector) are indexed as some mesh entities (here vertices). You should use higher-level DOLFIN tools to do such (any) things rather then messing up with DOFs directly. Here, appropriate tools are MeshIterators, MeshFunctions and DirichletBC. These kind of questions should be better asked on fenicsproject.org/qa after consulting fenicsproject.org/support which would suggest you to search resources where very similar questions were answered many times before. Jan > > Thanks, > Nikolaus > > _______________________________________________ > fenics mailing list > [email protected] > http://fenicsproject.org/mailman/listinfo/fenics _______________________________________________ fenics mailing list [email protected] http://fenicsproject.org/mailman/listinfo/fenics
