- changed status to invalid
Function assign is confusing or does not work for MixedFunctionSpace and split
Issue #235
invalid
from dolfin import *
mesh = UnitIntervalMesh(10)
Q = FunctionSpace(mesh,'CG',1)
W = MixedFunctionSpace([Q,Q])
f = Function(W)
f_0,f_1 = f.split(deepcopy=False)
g = Function(W)
g.vector()[:] = 0.0
f.assign(g)
plot(f_0,title='f_0 should be 0.0')
g.vector()[:] = 1.0
f.assign(g)
plot(f_1,title='f_1 should be 1.0 but is still 0.0')
plot(f[1], title='f[1] is 1.0')
f.vector()[:] = 2.0
plot(f_0, title="f_0 is should be 2.0 (assigning vector with scalar")
Comments (5)
-
-
reporter really? how do you rescale the plot?
-
I was wrong. The correct reason is that
f.assign(g)
breaksf_0
,f_1
pointers tof
. This is howFunction.assign
is designed. You should dof.assign(g); f_0, f_1 = f.split()
Nevertheless,
f_0
,f_1
could be invalidated so that referring to them in any way would raise an error. But this could be tricky to implement. -
reporter Ok then I should only do vector assignments if I want to keep the pointers like
f.vector()[:] = g.vector()
-
Yes.
- Log in to comment
You need to rescale your plots.