As I mentioned earlier, it is only the test function for the space that you apply the bc to that vanishes.
I.e. the statements you are mentioning are true.
This is then enforced in a linear or non-linear problem by modifying rows and columns of the matrix, as described earlier.
The property that a TestFunction disappears when a Dirichlet condition is applied is up to the implementation, but either implementation (Legacy Dolfin or DOLFINx) will enforce this in some way or another.
You can easily test this with:
import numpy as np
import dolfin
class Left(dolfin.SubDomain):
def inside(self, x, on_boundary):
return on_boundary and dolfin.near(x[0], 0.0)
class Right(dolfin.SubDomain):
def inside(self, x, on_boundary):
return on_boundary and dolfin.near(x[0], 1.0)
left = Left()
right = Right()
mesh = dolfin.UnitIntervalMesh(4)
facets = dolfin.MeshFunction("size_t", mesh, 0)
left.mark(facets, 1)
right.mark(facets, 2)
el = dolfin.FiniteElement("Lagrange", mesh.ufl_cell(), 1)
me = dolfin.MixedElement([el, el])
V = dolfin.FunctionSpace(mesh, me)
u_a, u_b = dolfin.TrialFunctions(V)
v_a, v_b = dolfin.TestFunctions(V)
dx = dolfin.dx
ds = dolfin.Measure("ds", domain=mesh, subdomain_data=facets)
a = dolfin.inner(u_a, v_a) * dx + dolfin.inner(u_b, v_b) * dx
bc_a = dolfin.DirichletBC(V.sub(0), dolfin.Constant(1), left)
bc_b = dolfin.DirichletBC(V.sub(1), dolfin.Constant(1), right)
bcs = [bc_a, bc_b]
A = dolfin.assemble(a)
[bc.apply(A) for bc in bcs]
# A2 should be equivalent to A
a2 = a + dolfin.inner(u_a, v_b) * ds(2) + dolfin.inner(u_b, v_a) * ds(1)
A2 = dolfin.assemble(a2)
[bc.apply(A2) for bc in bcs]
np.testing.assert_allclose(A.array(), A2.array())
print(A.array() - A2.array())
# A3 should be different from A
a3 = a + dolfin.inner(u_a, v_b) * ds(1) + dolfin.inner(u_b, v_a) * ds(2)
A3 = dolfin.assemble(a3)
[bc.apply(A3) for bc in bcs]
print(A.array() - A3.array())
yielding
[[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]
[[ 0. -1. 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[ 0. 0. 0. 0. 0. 0. 0. 0. -1. 0.]]