Function assignment
Hello,
could you please provide some clarification about assignment of functions in dolfin (C++). I have a function w defined on a mixed space W = V*Q and I'd like to do the following:
a) Initialize u (defined on V) and p (defined on Q).
b) In a loop, solve for w and update function u as u <- w[0]. I need this because u is a coefficient in my weak form.
The only way I was able to compile my code for the moment was to do
Function u = w[0]; // For part a)
I imagine that the object 'Function' holds nodal values over the mesh. Is the assignment above just a shallow copy (i.e. u and w[0] point to the same data in memory), or deep copy? I need u to hold its own data. How can I do this correctly? Maybe using 'interpolate' ?
Suppose I have a bilinear form a with coefficient u0 and I say
a.u0 = u;
u = w[0];
Does this actually change the values seen by a.u0 ?
For part b, I do for the moment
u.interpolate(
When I make my iterative loop, I see that the residuals printed by the linear solver in each iteration are precisely the same, therefore I think that I did not actually update u (which my weak form depends on) by w[0]. I'm wondering if this is the effect of the 'shallow copy issue' when I wrote
Function u = w[0];
Unfortunately I don't know how to do it otherwise.
Could anyone please explain this?
Thank you very much.
Martin Vymazal
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Garth Wells
- Solved:
- Last query:
- Last reply: