Dear all,
I am trying to solve a boundary problem. Thanks to the answer to a previous question of mine, I now know how to apply a boundary condition in the interior of the domain to a vector:
from dolfin import *
mesh = RectangleMesh(0, 0, 1, 1, 10, 10)
V = FunctionSpace(mesh, "CG", 1)
# initialize mesh connectivity so that Facet.exterior() works
mesh.init()
# define the interior of the domain by looking at each facets
facet_domains = FacetFunction('size_t', mesh)
facet_domains.set_all(0)
for f in facets(mesh):
if any(ff.exterior() for ff in facets(f)):
facet_domains[f] = 1
bc_in = DirichletBC(V, Constant(-1.0), facet_domains, 0)
u = Function(V)
bc_in.apply(u.vector())
Unfortunately, I am now trying the same approach on a linear variational system defined on the boundary of the domain and it does not work:
from dolfin import *
mesh = UnitSquareMesh(10, 10)
V = FunctionSpace(mesh, "CG", 1)
# initialize mesh connectivity so that Facet.exterior() works
mesh.init()
# define the interior of the domain by looking at each facets
facet_domains = FacetFunction('size_t', mesh)
facet_domains.set_all(0)
for f in facets(mesh):
if any(ff.exterior() for ff in facets(f)):
facet_domains[f] = 1
bc_in = DirichletBC(V, Constant(-1.0), facet_domains, 0)
u, v = TestFunction(V), TrialFunction(V)
a = u*v*ds
L = Constant(1.)*v*ds
w = Function(V)
solve(a == L, w, bcs=bc_in)
plot(w, axes=True)
interactive()
This script produces the following message in the terminal:
Solving linear variational problem.
UMFPACK problem related to call to numeric
*** Warning: UMFPACK reports that the matrix being solved is singular.
UMFPACK problem related to call to solve
*** Warning: UMFPACK reports that the matrix being solved is singular.
And here is the resulting plot:
It looks like bc_in has not been applied on the whole interior but only on a set of facets immediately below the domain boundary... I guess I am still missing something important in the way boundary conditions and facets are working... Can somebody help me please ? Thanks !