- changed version to 2016.2
Function copy constructor not working
Issue #792
invalid
Hello, I'm using fenics2016.2 with Ubuntu 16.04.
Using the copy constructor of a Function leads to the following error:
mesh = UnitCubeMesh(1,1,1)
V = FunctionSpace(mesh, "CG", 1)
u = Function(V)
v = Function(u)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-37-95b245268c8a> in <module>()
----> 1 w = Function(v)
/usr/lib/python2.7/dist-packages/dolfin/functions/function.pyc in __init__(self, *args, **kwargs)
260 if len(args) == 1:
261 # Copy constructor used to be here
--> 262 raise RuntimeError("Use 'Function.copy(deepcopy=True)' for copying.")
263 elif len(args) == 2:
264 i = args[1]
RuntimeError: Use 'Function.copy(deepcopy=True)' for copying.
A workaround is using v = Function(V, u.vector(),copy)
or v = Function(V, u)
, but the first is intended for internal library use only, and the latter is not documented (but seems to work).
greetings Florian
Comments (3)
-
reporter -
- changed status to invalid
It was conscious choice to remove copy initializer in Python interface. As the error message suggest do
v = u.copy(deepcopy=True)
, it works. -
Account Deleted how to remove it
- Log in to comment