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

Exporting output from FEniCS as a matrix

0 votes

Hello Fellow Members,

I am solving a 2D wave equation and saving the solution in pvd format. I then open the pvd/ pvtu output file in Paraview, and export the solution vector to .csv format for a particular time step, which is then read by MATLAB and imported as a matrix. Lets say the time step is 20th time step. My code runs many times in a loop, for different input values of physical parameters, thereby saving solutions for each run in a different folder. So, it is not convenient to open each folder and follow the process mentioned above.

Is there a way to shorten this process? Any help is highly appreciated.

The loop at the end of the code looks like this:

file = File("displacement.pvd")
while t <= T:
  t += dt
  solver.solve()
  update(u)
  file << u
asked Oct 31, 2016 by Chaitanya_Raj_Goyal FEniCS User (4,150 points)
edited Nov 1, 2016 by Chaitanya_Raj_Goyal

1 Answer

+2 votes
 
Best answer

You have three options

#1 Use matplotlib/pylab to achieve whatever you are doing in MATLAB.
#2 Export the csv file directly from python.
#3 Paraview allows you to record your actions as a python script, so you cam automate the csv creation.

answered Nov 1, 2016 by KristianE FEniCS Expert (12,900 points)
selected Nov 3, 2016 by Chaitanya_Raj_Goyal
...