This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

mixed space assignment

+2 votes

Hi,

We have:

V = FunctionSpace(...)
W = FunctionSpace(...)
U = V * W

my function is:

p = Function(U)

Now I split p as follows:

(e,f) = p.split()

Now I want to change e and f, then assign them back into p:

assign(p.sub(0), e)
assign(p.sub(1), f)

but when I do this I get the following error:

TypeError: list of Function expected

How can we do such an assignment?

related to an answer for: MixedFunctionSpace - update a subfunction
asked Mar 22, 2016 by babak FEniCS Novice (380 points)

Same problem here... I though I had it...
V is a MixedFunctionSpace consisting of a Lagrage Space (index _phi) and a Nédélec space (index _rz).

H = dolfin.Function(self.V)
dolfin.assign( H, [
       self.grad_rz(ResultEField_rz)/(2*np.pi*f_res*mu0),
       self.curl_rz(ResultEField_rz, ResultEField_phi, m)/ (2*np.pi*f_res*mu0)
       ] )

*) grad_rz and curl_rz are my implementations of grad and curl for the given symmetry. curl_rz takes an argument m which is an integer.

...