Function.assign in Dolfinx

Hi there,

Is there an equivalent to function.assign() method in dolfinx?
Would something along the lines of
receiver_function=function_to_be_assigned.copy() do the trick?

Many thanks

See for instance:

Or

1 Like

Thank you!
What if the assignment holds only for a subfunction as below in dolfin?

assign(V1function, V2function.sub(0))

I have tried the below which returned ‘NotImplementedError: Cannot take length of non-vector expression.’

space_0, map_0 = V2function.sub(0).collapse()
        V1function.x.array[:]=np.arange(len(map_0))

I dont follow. Please make a minimal code example that produces this error message. It is not clear what V1function and V2function is.

Sorry for the confusion. I was manipulating a function that defined three fields (V2function), of which I wanted to assign only one to another function (V1function).
I solved it using:

V1function.x.array[:] = V2function.sub(0).collapse().x.array

Many thanks