CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Quick OpenFoam to MatLab lesson plz :) (http://www.cfd-online.com/Forums/openfoam/78252-quick-openfoam-matlab-lesson-plz.html)

Rickard.Solsjo July 16, 2010 03:46

Quick OpenFoam to MatLab lesson plz :)
 
Hey fellow Foamers,
I want to transfer my data from OpenFoam to MatLab in order to do plots of correlations for fuel-distribution and penetration depth aso,
Do I need plugin-programs for MatLab or anything similar?
Also how do I load it into MatLab and how is the data read ? I have a refined Mesh so there are more cells in one direction than the other, does it read x - axis before y - axis etc....?

I would really appreciate the help

Thx
R

cves July 16, 2010 04:37

Hello,

Just export your OpenFOAM data in any text format (.txt, .csv, ...).

Then there are many different possibility in matlab to read a text file but the most famous are "load" and "textscan".

Load is really easy to use but no so powerfull. Indeed, your text file must be a rectangular matrix without header...

So for me textscan is the best because you can go through your whole file and import every data that you are interested in. All the possibility are really well explained in the matlab help for texscan.

Best regards,

Christian

Rickard.Solsjo July 16, 2010 05:12

Okay thx !

I was curious since I just tried to plot the velocity (i think it was) and the output was pretty strange. I got the magnitude as a function of the grid points. Ill try to plot it as a function of time.

kumar February 15, 2011 06:11

Hello Rickard and Christian,
I am using interFoam for jet breakup studies. I want to use Matlab for perofrming some statistics on breakup length based on time. So i want to read the output of alpha1 into matlab.

From what I understood from your post, i will have to load the certain time step output of openfoam output in paraFoam and then load alpha1 and surface and then switch to spreadsheet view and then export that data into .txt or .csv file.

This gives me the alpha1 with respect to points (alpha1 x y z).

But i have hundreds of time steps and do I have to load each time step in paraFoam and export it in .csv format.

Is there any other way to export the data into .csv format.

regards
K.Suresh kumar

Rickard.Solsjo February 15, 2011 06:22

exporting data
 
Hey Kumar
Basically what I did was to use sampleDict to choose the plane/surface I want to study.
For instance, when I want to observe my jet penetration length , i assumed that the maximum penetration distance was along the central propagating axis.
Therefore this was the plane I extracted using sampleDict
It looked something like: plane (-0.01 0 0)
normal (0 0 -1)
since my injection is in the negative z-axis
Using sampleDict I just used
sample -time . . . . input time (see you dont need all the output time)

Also you dont need paraview or anything. I hope you chose your output as ascii
Ask if you need more help

MMK October 24, 2011 06:00

Quote:

Originally Posted by Rickard.Solsjo (Post 295300)
Hey Kumar
Basically what I did was to use sampleDict to choose the plane/surface I want to study.
For instance, when I want to observe my jet penetration length , i assumed that the maximum penetration distance was along the central propagating axis.
Therefore this was the plane I extracted using sampleDict
It looked something like: plane (-0.01 0 0)
normal (0 0 -1)
since my injection is in the negative z-axis
Using sampleDict I just used
sample -time . . . . input time (see you dont need all the output time)

Also you dont need paraview or anything. I hope you chose your output as ascii
Ask if you need more help


Hi, I am new to foam please can you tell me how to put these changes in the sampleDict. For example I have a following sampleDict


FoamFile
{
version 2.0;
format ascii;
class dictionary;
location system;
object sampleDict;
}

//-----------------------------sampleDict----------------------------------
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object sampleDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

interpolationScheme cellPoint;

setFormat raw;

sets
(
location1
{
type midPoint;
axis z;
start (0.0 0.00 0.0);
end (0.0 0.0 -0.205);
}
);

surfaces ();

fields
(

U

);


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