Imposing two different boundary conditions on some sides of a square

You can store the function in a temporary vector and then add them together:

tmp = u.vec.CreateVector()
tmp.data = u.vec
u.Set(x,definedon=mesh.Boundaries("Bottom"))
u.vec.data += tmp

If they have both values on the same boundaries then you only want to set these values:


setdofs = BitArray(V.ndof)
setdofs.Clear()
for el in V.Elements(BND):
    if el.mat in ("Top","Right"):
        for dof in el.dofs:
            setdofs.Set(dof)

tmp = u.vec.CreateVector()
tmp.data = u.vec
u.Set(x,definedon=mesh.Boundaries("Bottom"))
for dnr in range(V.ndof):
    if setdofs[dnr]:
        u.vec[dnr] = tmp[dnr]

Best
Christopher