re-formulating function space from u.vector().array()
hi, i'm quite new to FEniCS so i apologise if this is a silly question.
I have as an output to a program the solution field U = u.vector().array(), i.e. it exists as a numpy array and is not a function object anymore.
I would like to use it as an input to another program, but am not sure how to convert it back into a function object - i can't just use interpolate(U,V) since U is not a function or expression but is a numpy array right? Hence, how would i go about doing this?
Thanks!
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Johan Hake
- Solved:
- 2013-04-05
- Last query:
- 2013-04-05
- Last reply:
- 2013-04-05
|
#1 |
Several ways:
1) Either save the function instead of the numpy array
File("u.xml.gz") << u
other program:
File("u.xml.gz") >> u1
2) Save the numpy array:
u.vector(
other program:
u1.vector()[:] = numpy.fromfile(
Also: u and u1 need to be in the same FunctionSpace.
Johan
On 04/04/2013 11:21 PM, nicole t wrote:
> New question #225909 on DOLFIN:
> https:/
>
> hi, i'm quite new to FEniCS so i apologise if this is a silly question.
>
> I have as an output to a program the solution field U = u.vector().array(), i.e. it exists as a numpy array and is not a function object anymore.
>
> I would like to use it as an input to another program, but am not sure how to convert it back into a function object - i can't just use interpolate(U,V) since U is not a function or expression but is a numpy array right? Hence, how would i go about doing this?
>
> Thanks!
>
nicole t (nicole12) said : | #2 |
Thanks Johan Hake, that solved my question.