# Initial Conditions for mixed Element

**URL:** <https://fenicsproject.discourse.group/t/initial-conditions-for-mixed-element/2032>\
**Category:** Uncategorized\
**Created:** [December 2, 2019, 6:45pm UTC](https://fenicsproject.discourse.group/t/initial-conditions-for-mixed-element/2032 "2019-12-02T18:45:26Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [August 12, 2020, 10:45am UTC](https://fenicsproject.discourse.group/t/initial-conditions-for-mixed-element/2032/10 "2020-08-12T10:45:39Z")

</div>

For the first question, see: [Access function in time dependent XDMFFile](https://fenicsproject.discourse.group/t/access-function-in-time-dependent-xdmffile/359/14) which will refer you to the `FunctionAssigner`-function.  
For the second question, consider this minimal example:

```auto
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())

```

---

_[View the full topic](https://fenicsproject.discourse.group/t/initial-conditions-for-mixed-element/2032)._
