CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

From OpenFOAM to LaTeX

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 2 Post By dkxls

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 14, 2014, 10:36
Default From OpenFOAM to LaTeX
  #1
New Member
 
Guido Bonalumi
Join Date: Dec 2013
Posts: 16
Rep Power: 12
guido.bonalumi is on a distinguished road
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.
guido.bonalumi is offline   Reply With Quote

Old   October 14, 2014, 11:00
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
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 python-vtk 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.
alexeym is offline   Reply With Quote

Old   October 14, 2014, 11:15
Default
  #3
New Member
 
Guido Bonalumi
Join Date: Dec 2013
Posts: 16
Rep Power: 12
guido.bonalumi is on a distinguished road
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.
guido.bonalumi is offline   Reply With Quote

Old   October 14, 2014, 12:52
Default
  #4
Senior Member
 
dkxls's Avatar
 
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19
dkxls will become famous soon enough
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 vector-graphics (i.e. PDFs).
apple-tree and ssss like this.
dkxls is offline   Reply With Quote

Old   October 16, 2014, 18:45
Default
  #5
New Member
 
Guido Bonalumi
Join Date: Dec 2013
Posts: 16
Rep Power: 12
guido.bonalumi is on a distinguished road
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.
guido.bonalumi is offline   Reply With Quote

Old   October 17, 2014, 01:00
Default
  #6
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Quote:
Originally Posted by guido.bonalumi View Post
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.
A bunch of explanations:

http://tex.stackexchange.com/questio...use-pdf-or-eps
alexeym is offline   Reply With Quote

Old   October 17, 2014, 05:02
Default
  #7
New Member
 
Guido Bonalumi
Join Date: Dec 2013
Posts: 16
Rep Power: 12
guido.bonalumi is on a distinguished road
From this discussion .PDF seems better, but I still have a doubt. Quoting from this discussion:
Lev Bishop:
Quote:
Pdftex will include PDF files directly without making any changes (except for unifying fonts, and even that can be disabled if needed), so you can have complete control over the final result by generating a PDF which is exactly as you want it (assuming your image editing software gives you control over image encoding lossiness, colour spaces, etc).
mforbes
Quote:
One advantage of EPS figures is the ability to use the psfrag package to replace axis labels etc. with properly LaTeXed versions generated with the same fonts etc. as your main document. I used to generate all my plots with matplotlib or MATLAB using this feature. Matplotlib's support for this is broken, but it instead provides a usetex option that allows you to embed LaTeX generated the labels directly in PDF files which I now use exclusively.
Probably I get it wrong but to me they are saying the same thing. Am I wrong? I would like to have the same font everywhere if it is possible.
guido.bonalumi is offline   Reply With Quote

Old   October 17, 2014, 05:48
Default
  #8
Senior Member
 
dkxls's Avatar
 
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19
dkxls will become famous soon enough
I don't see any reason why one would even considering .eps. You either have to convert every singel eps-file 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 tool-set that fit's your needs the best!
dkxls is offline   Reply With Quote

Old   October 17, 2014, 08:01
Default
  #9
New Member
 
Guido Bonalumi
Join Date: Dec 2013
Posts: 16
Rep Power: 12
guido.bonalumi is on a distinguished road
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.
guido.bonalumi is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenFOAM - Validation of Results Ahmed OpenFOAM Running, Solving & CFD 10 May 13, 2018 18:28
ESI-OpenCFD Releases OpenFOAM v2.2.0 opencfd OpenFOAM Announcements from ESI-OpenCFD 13 March 30, 2013 16:52
OpenFOAM 1.6.x, 1.7.0 and 1.7.x are not fully prepared to work with gcc-4.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


All times are GMT -4. The time now is 15:53.