
[Sponsors] 
October 14, 2014, 10:36 
From OpenFOAM to LaTeX

#1 
New Member
Guido Bonalumi
Join Date: Dec 2013
Posts: 16
Rep Power: 5 
Hi everyone,
I am going to write my thesis with LaTex and I am looking for some advices. In particular I am interested in the best solution to plot my results. I am not so expert with OpenFOAM so usually I look at my results through Paraview and when necessary I extract them with some tools like slices, plot over lines, etc. It worked quite well until now, but I do not know how to plot fields, in particular velocity and pressure fields. Extracting values with slices was easy but plotting them with Octave not so much. Here you can read about my problems: http://octave.1599824.n4.nabble.com/....html#a4666945 So now I am here to ask which is the best way to do the job. Which is the best solution to plot OpenFOAM data with LaTex? I able to plot residuals and easy plots, but I am not able to plot fields. I have read about the sample utility but I am not sure that is the best solution. Can anybody help me? Thanks in advance. 

October 14, 2014, 11:00 

#2 
Senior Member
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,652
Rep Power: 27 
Hi,
the best solution is the one that works for you. I would propose to use matplotlib for slice plots. You sample data with sample utility, save it as VTK, then read this data with pythonvtk and plot with matplotlib (here is an example). If you prefer Octave, there is Octaviz package. Though it's no longer supported and I'm not quite sure about its ability to save vector graphics. 

October 14, 2014, 11:15 

#3 
New Member
Guido Bonalumi
Join Date: Dec 2013
Posts: 16
Rep Power: 5 
First of all thank you for your reply.
I think I have explained my self wrong. Actually what I am looking is a little bit different. I want to give the data directly to LaTex and create the plots with it, using packages like pgfplots, instead of importing in it images realized with other programs. I use Octave because for some plots I think I will need to modify the data before plotting them. For sure I am not the first one with this problem and I was looking for someone more expert than me who knows which is the best way to plot OpenFOAM data directly with LaTeX. 

October 14, 2014, 12:52 

#4 
Senior Member
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 12 
Actually alexeym was recommending you an very powerful alternative to Octave: Python
matplotlib is a very powerful plotting library for python/numpy. I don't think there is much you can do in octave/matlab that you couldn't do with python/numpy/matplotlib. Actually, I would rather say it's the other way round, python, especially when combined with vtk has much better plotting and data handling capabilities than octave/matlab. Especially when you are dealing with large data, there are not many alternatives to a combination of python and ParaView/VTK. (Of course Visit and MayaVi would be two good examples for alternatives ). Concerning LaTeX: I either export vector graphics from matplotlib/ParaView (mostly PDF) or export the plots as TikZ/PGF directly. See e.g. here: https://github.com/nschloe/matplotlib2tikz Or the corresponding matlab version here (never used that one though): https://github.com/nschloe/matlab2tikz I should mention that I use TikZ/PGF only for line plots, not for 2D or 3D plots. I don't really see a point in that, since ParaView and matplotlib can both export high quality vectorgraphics (i.e. PDFs). 

October 16, 2014, 18:45 

#5 
New Member
Guido Bonalumi
Join Date: Dec 2013
Posts: 16
Rep Power: 5 
Thank you very much for your advices and your kindness.
Unfortunately I do not have enough time to learn python now and I am looking for a quicker solution combining my knowledges about Octave, Paraview and LaTeX. At the moment my biggest preoccupation involves the 2D plots (velocity and pressure fields) because I should be able to realize all the other graphs (1D) directly with LaTeX. For what I have understood you are suggesting to export vector graphics from Paraview and import them with LaTeX. I have no reason to doubt about your solution and it is what I did until now. But why PDF? Generally I use .eps file. Do you think PDF is a better format? Just asking. I really know anything about this kind of stuff. 

October 17, 2014, 01:00 

#6  
Senior Member
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,652
Rep Power: 27 
Quote:
http://tex.stackexchange.com/questio...usepdforeps 

October 17, 2014, 05:02 

#7  
New Member
Guido Bonalumi
Join Date: Dec 2013
Posts: 16
Rep Power: 5 
From this discussion .PDF seems better, but I still have a doubt. Quoting from this discussion:
Lev Bishop: Quote:
Quote:


October 17, 2014, 05:48 

#8 
Senior Member
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 12 
I don't see any reason why one would even considering .eps. You either have to convert every singel epsfile to a pdf or use latex>dvi>pdf, who does that anymore?
Besides, .eps files can become unhandy for surface or contour plots, since they are typically bigger in size than .pdf (though this largely depends on what you are actually plotting). About the fonts, I don't see any problems on that end, I also use same fonts throughout the entire document, needs every now and then some adjustments but nothing too fancy. After all, you have to find the toolset that fit's your needs the best! 

October 17, 2014, 08:01 

#9 
New Member
Guido Bonalumi
Join Date: Dec 2013
Posts: 16
Rep Power: 5 
Ok thank you very much! I will give it a try. I just have to understand how I can change the font from the .PDF to have the same font everywhere.


Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
ESIOpenCFD Releases OpenFOAM v2.2.0  opencfd  OpenFOAM Announcements from ESIOpenCFD  13  March 30, 2013 17:52 
OpenFOAM  Validation of Results  Ahmed  OpenFOAM Running, Solving & CFD  9  June 22, 2011 18:59 
OpenFOAM 1.6.x, 1.7.0 and 1.7.x are not fully prepared to work with gcc4.5.x  wyldckat  OpenFOAM Bugs  18  October 21, 2010 05:51 
Summer School on Numerical Modelling and OpenFOAM  hjasak  OpenFOAM  5  October 12, 2008 13:14 
The OpenFOAM extensions project  mbeaudoin  OpenFOAM  16  October 9, 2007 09:33 