For the first question, see: Access function in time dependent XDMFFile which will refer you to the FunctionAssigner
-function.
For the second question, consider this minimal example:
from dolfin import *
mesh = UnitSquareMesh(2,1)
mf = MeshFunction("size_t", mesh, mesh.topology().dim()-1, 0)
class left(SubDomain):
def inside(self, x, on_boundary):
return x[0]<1e-10 and on_boundary
left().mark(mf, 1)
P3 = FiniteElement('P', mesh.ufl_cell(), 2)
ele = MixedElement([P3,P3,P3])
VV = FunctionSpace(mesh, ele)
#Define test functions
vv1,vv2,vv3 = TestFunction(VV)
#Define problem to solve
uu = Function(VV)
phi,bound_s,bound_ns = split(uu)
#Define initial and boundary conditions
u_n = Function(VV) #Automatically sets to zero
phi_n,bound_s_n,bound_ns_n = split(u_n)
V0,V1,V2 = VV.split()
V0 = V0.collapse()
v0 = Function(V0)
v0.interpolate(Expression("1-x[0]+x[1]",degree=1))
# Setting values for part of boundy of subspace_vector
init_bc = DirichletBC(VV.sub(0), v0, mf, 1)
init_bc.apply(u_n.vector())
print("u_n", u_n.vector().get_local())
print("sub-vector:", u_n.split(deepcopy=True)[0].vector().get_local())
# Setting bc for whole boundary
full_bc = DirichletBC(VV, Expression(("1-x[0]","1-x[0]","1-x[0]"),degree=1), "on_boundary")
full_bc.apply(u_n.vector())
print("Full space", u_n.vector().get_local())