# Usage of FunctionAssigner

**URL:** <https://fenicsproject.discourse.group/t/usage-of-functionassigner/4868>\
**Category:** Uncategorized\
**Created:** [January 8, 2021, 4:06pm UTC](https://fenicsproject.discourse.group/t/usage-of-functionassigner/4868 "2021-01-08T16:06:20Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Nico\_Su](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nico_su/32/1123_2.png) [@Nico\_Su](https://fenicsproject.discourse.group/u/Nico_Su)\
**Post date:** [January 8, 2021, 4:06pm UTC](https://fenicsproject.discourse.group/t/usage-of-functionassigner/4868/1 "2021-01-08T16:06:20Z")

</div>

Hi, i am struggling to use the FunctionAssigner, i used an example from the following link, but i can’t seem to get the matching dofs.  
Link: [https://bitbucket.org/fenics-project/dolfin/raw/ec57db53f2b13f1768214829e8b4f80fc32205cf/python/demo/undocumented/sub-function-assignment/demo\_sub-function-assignment.py](https://bitbucket.org/fenics-project/dolfin/raw/ec57db53f2b13f1768214829e8b4f80fc32205cf/python/demo/undocumented/sub-function-assignment/demo_sub-function-assignment.py)

```auto
from dolfin import *
import matplotlib.pyplot as plt

parameters['allow_extrapolation'] = True

height = 1.0
width = 1.0
length = 1.0
mesh = BoxMesh(Point(0.0, 0.0, 0.0), Point(length,width,height), 12, 12, 12)

## Create submesh ##

marker = MeshFunction("size_t", mesh, mesh.topology().dim() - 1, 0)
for f in facets(mesh):
    marker[f] = height - DOLFIN_EPS < f.midpoint().z() < height + DOLFIN_EPS
    
submesh = MeshView.create(marker, 1)

V = VectorFunctionSpace(mesh, 'CG', 2)

X = FiniteElement('CG', submesh.ufl_cell(), 2)
Y = FiniteElement('CG', submesh.ufl_cell(), 2)
Z = X * Y
S = FunctionSpace(submesh, Z)

T = FunctionSpace(mesh, 'CG', 2)

v = Function(V)

S_1 = Function(S)
S_11, S_12 = S_1.split()

T_S_1 = interpolate(S_11, T)
T_S_2 = interpolate(S_12, T)
#next line results in an error
assigner = FunctionAssigner(V, [T, T])
assigner.assign(v, [T_S_1, T_S_2])
```

Note that the space T is only there because i need the functionspaces to “live” on the same mesh. Interpolating the function in another mesh is so far no problem, however the functionAssigner creates following error message:

```auto
*** -------------------------------------------------------------------------
*** Error: Unable to create function assigner.
*** Reason: Expected the same number of sub spaces in the receiving FunctionSpace as the number of assigning FunctionSpaces.
*** Where: This error was encountered inside FunctionAssigner.cpp.
*** Process: 0
```

---

_[View the full topic](https://fenicsproject.discourse.group/t/usage-of-functionassigner/4868)._
