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

Quick OpenFoam to MatLab lesson plz :)

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By cves

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 16, 2010, 04:46
Default Quick OpenFoam to MatLab lesson plz :)
  #1
Senior Member
 
Rickard
Join Date: May 2010
Location: Lund, Skåne, Sweden
Posts: 143
Rep Power: 16
Rickard.Solsjo is on a distinguished road
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
Rickard.Solsjo is offline   Reply With Quote

Old   July 16, 2010, 05:37
Default
  #2
New Member
 
Christian
Join Date: Feb 2010
Location: Payerne, Switzerland
Posts: 9
Rep Power: 16
cves is on a distinguished road
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
Pravin Kadu likes this.
cves is offline   Reply With Quote

Old   July 16, 2010, 06:12
Default
  #3
Senior Member
 
Rickard
Join Date: May 2010
Location: Lund, Skåne, Sweden
Posts: 143
Rep Power: 16
Rickard.Solsjo is on a distinguished road
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.
Rickard.Solsjo is offline   Reply With Quote

Old   February 15, 2011, 06:11
Default
  #4
Senior Member
 
Suresh kumar Kannan
Join Date: Mar 2009
Location: Luxembourg, Luxembourg, Luxembourg
Posts: 129
Rep Power: 17
kumar is on a distinguished road
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
kumar is offline   Reply With Quote

Old   February 15, 2011, 06:22
Default exporting data
  #5
Senior Member
 
Rickard
Join Date: May 2010
Location: Lund, Skåne, Sweden
Posts: 143
Rep Power: 16
Rickard.Solsjo is on a distinguished road
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
Rickard.Solsjo is offline   Reply With Quote

Old   October 24, 2011, 07:00
Default
  #6
MMK
New Member
 
Join Date: Jan 2011
Posts: 9
Rep Power: 15
MMK is on a distinguished road
Quote:
Originally Posted by Rickard.Solsjo View Post
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

);
MMK is offline   Reply With Quote

Old   October 26, 2020, 12:58
Default
  #7
Senior Member
 
Join Date: Jul 2019
Posts: 148
Rep Power: 7
Bodo1993 is on a distinguished road
Quote:
Originally Posted by Rickard.Solsjo View Post
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,
If I have extracted a surface, do I have to use griddata in matlab to draw the contour surface? Thanks.
Bodo1993 is offline   Reply With Quote

Reply


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 - Quick way to delete previous calculation & HowTo get access to variables kriz OpenFOAM 12 March 6, 2023 04:20
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06:36
OpenFOAM command from inside MATLAB sega OpenFOAM Post-Processing 18 September 25, 2012 08:35
Modified OpenFOAM Forum Structure and New Mailing-List pete Site News & Announcements 0 June 29, 2009 06:56
OpenFOAM Debian packaging current status problems and TODOs oseen OpenFOAM Installation 9 August 26, 2007 14:50


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