Skip to content

Applying DirichletBC on component of a VectorFunction that is in a mixed function space does not work #920

@florianwechsung

Description

@florianwechsung

I tried to adapt this mail in the mailinglist to the Stokes equations. I would like to apply Dirichlet BCs on only one component of the velocity field. However, in that case the solver fails (failed to converge after 10000 iterations).

I have slightly adapted my use case to illustrate the problem.

from firedrake import *
# Load mesh
mesh = UnitSquareMesh(10, 10)

# Define function spaces
V = VectorFunctionSpace(mesh, "CG", 2)
Q = FunctionSpace(mesh, "CG", 1)
W = V * Q

applyBcsComponentWise = True
if applyBcsComponentWise:
    bc0 = DirichletBC(W.sub(0).sub(0), 0, [3, 4])
    bc1 = DirichletBC(W.sub(0).sub(1), 0, [3, 4])
    bc2 = DirichletBC(W.sub(0).sub(0), 1, 1)
    bc3 = DirichletBC(W.sub(0).sub(1), 0, 1)
    bcs = [bc0, bc1, bc2, bc3]
else:
    bc0 = DirichletBC(W.sub(0), Constant((0.0, 0.0)), [3, 4])
    bc1 = DirichletBC(W.sub(0), Constant((1.0, 0.0)), 1)
    bcs = [bc0, bc1]

# Define variational problem
(u, p) = TrialFunctions(W)
(v, q) = TestFunctions(W)
f = Constant((0.0, 0.0))
a = inner(grad(u), grad(v))*dx + div(v)*p*dx + q*div(u)*dx
L = inner(f, v)*dx

U = Function(W)
solve(a == L, U, bcs=bcs)

for both values of the bool applyBcsComponentWise this snippet should produce the same result. However, for applyBcsComponentWise = True, the solver runs out of iterations. According to @wence- , to many entries in the matrix are zero'd.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions