This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

dof of one part of the boundary

+1 vote

Hello,

I want to get the dofs of the left part of a boundary.

  1. when I compute bmesh, I can not access to the dof??

I want to plot the boundary :

  1. If I plot bmesh, I get only one line and not the whole boundary.

Thanks by advance,
Stéphane

initialisation

from dolfin import *
mesh = UnitSquareMesh(32, 32)

V = VectorFunctionSpace(mesh, "Lagrange", 1)

Sub domain for clamp at left end

def left(x, on_boundary):
return x[0] < DOLFIN_EPS and on_boundary

Sub domain for rotation at right end

def right(x, on_boundary):
return x[0] > 1 - DOLFIN_EPS and on_boundary

Create mesh function over the cell facets

boundary_subdomains = MeshFunction("size_t", mesh, mesh.topology().dim() - 1)
boundary_subdomains.set_all(0)
AutoSubDomain(left).mark(boundary_subdomains, 1)
AutoSubDomain(right).mark(boundary_subdomains, 2)

boundary mesh

bmesh = BoundaryMesh(mesh,'exterior')

plot(bmesh)

asked Mar 28, 2017 by stephanepa FEniCS Novice (350 points)

1 Answer

+2 votes

Answering to your first question, you can obtain the dofs of the left boundary doing something like this:

from numpy import where

ff = FacetFunction("size_t", mesh)
AutoSubDomain(left).mark(ff, 1)

u = Function(V)
bc = DirichletBC(V, Constant((1.0, 1.0)), ff, 1)
bc.apply(u.vector())

left_dofs = where(u.vector()==1.0)[0]
answered Mar 28, 2017 by hernan_mella FEniCS Expert (19,460 points)
...