Hello,
I have an issue with copying the values of a function when using mixed finite elements.
I define my function spaced as
O = VectorFunctionSpace(mesh, 'P', 2, dim=2)
Q = FunctionSpace(mesh, 'P', 1)
and the mixed space as
P_v = VectorElement('P', triangle, 2)
P_w = FiniteElement('P', triangle, 1)
element = MixedElement([P_v, P_w])
V_vw = FunctionSpace(mesh, element)
I define the following functions
vw_ = Function(V_vw)
v_, w_ = split(vw_)
v_dummy = Function(O)
w_n_1 = Function(Q)
w_n_2 = Function(Q)
I in a time loop, I have the following : I obtain the solution of a mixed variational problem and stored it into vw_
with
solve(A1, vw_.vector(), b1, 'bicgstab', 'hypre_amg')
Then I want to
- copy the numerical values of the function
w_n_1
intow_n_2
- copy the numerical values of the function
w_
intow_n_1
If I do
w_n_2.assign(w_n_1)
v_temp, w_n_1 = vw_.split()
This works in the first step of the time loop, but in the second step I get the error message
Traceback (most recent call last):
File "navier_stokes_membrane.py", line 292, in <module>
w_n_2.assign(w_n_1)
File "/usr/local/lib/python3.6/dist-packages/dolfin/function/function.py", line 408, in assign
self._cpp_object._assign(rhs._cpp_object)
RuntimeError:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to initialize vector of degrees of freedom for function.
*** Reason: Cannot re-initialize a non-empty vector. Consider creating a new function.
*** Where: This error was encountered inside Function.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 74d7efe1e84d65e9433fd96c50f1d278fa3e3f3f
*** -------------------------------------------------------------------------
What am I doing wrong ?
Thank you