I’m trying to figure out how to best set Dirichlet conditions on interior DoF. For DoF that are on interior facets I can define the mesh function accordingly. Is there a direct way to set interior DoF to a value?
Hi, consider
from dolfin import *
mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, 'CG', 1)
f = interpolate(Expression('x[0]+x[1]', degree=1), V)
# Where dofs will be constrained
facet_f = MeshFunction('size_t', mesh, mesh.topology().dim()-1, 0)
CompiledSubDomain('near(x[0], x[1])').mark(facet_f, 1)
dS = Measure('dS', domain=mesh, subdomain_data=facet_f)
# Before
print(assemble(avg(f)*dS(1)))
# Apply bcs
bcs = DirichletBC(V, Constant(0), facet_f, 1)
bcs.apply(f.vector())
# After
print(assemble(avg(f)*dS(1)))