Using temporaries results in crash
As said in the Q&A without any feedback, if I use a temporary the assembly dies with the following exception:
#!
*** -------------------------------------------------------------------------
*** Error: Unable to evaluate expression.
*** Reason: Missing eval() function (must be overloaded).
*** Where: This error was encountered inside Expression.cpp.
*** Process: unknown
***
*** DOLFIN version: 1.5.0
*** Git changeset: f467b66dcfd821ec20e9f9070c7cef5a991dbc42
*** -------------------------------------------------------------------------
A simple code as this is sufficient to see how it can die:
dolfin::Constant c(3.1415);
lhs.C0000 = dolfin::Constant(3.1415); // DIE
lhs.C0000 = c; // LIVE
It seems that coefficient assigners in a form use the address of a given constant reference in operator=
. As said in the Q&A, this results in errors even with a DirichletBC
.
A workaround is to duplicate everything with local variables, but you know better than me that this is error-prone.
I've attached an example, but I might have misunderstood how I need to use Fenics.
Thanks!
Comments (5)
-
-
reporter Good to hear! Does this also imply that I cannot use containers to assign coefficients?
-
You can use containers, as long as the containers hold
std::shared_ptr
s to the coefficients. -
- changed status to resolved
-
- removed milestone
Removing milestone: 1.7 (automated comment)
- Log in to comment
This is fixed in the development version, which requires coefficients attached to forms to be shared pointers.