This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Import Solution

0 votes

Hi,

I'm working with a Navier-Stokes fluid, and I need to do several calculations using the same solution. So, I would like to know if there exist a way to import a solution to a mesh function previously stored in a vtk or xdmf file, preferably using a Python interface for FeniCS.

Thanks in advice!

asked Mar 9, 2016 by felipe_galarce FEniCS User (1,190 points)

1 Answer

+2 votes
 
Best answer

If u is your solution, maybe use the hdf5 format can be useful for what you wants:

# Save solution
output_file = HDF5File(mesh.mpi_comm(), "u.h5", "w")
output_file.write(u, "solution")
output_file.close()

# Load solution
U = Function(V)
input_file = HDF5File(mesh.mpi_comm(), "u.h5", "r")
input_file.read(U, "solution")
input_file.close()

(this also works in parallel).

answered Mar 9, 2016 by hernan_mella FEniCS Expert (19,460 points)
selected Mar 11, 2016 by felipe_galarce
...