Usage of FunctionAssigner

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

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:

*** -------------------------------------------------------------------------
*** 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

As you are working with a 3 dimensional mesh, the vector function space has three components:

T_S_1 = interpolate(S_11, T)
T_S_2 = interpolate(S_12, T)
T_s_0 = Function(T) # Function containing 0 values
assigner = FunctionAssigner(V, [T, T, T])
assigner.assign(v, [T_S_1, T_S_2, T_s_0])
1 Like