CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Fluent & matlab (https://www.cfd-online.com/Forums/fluent/64219-fluent-matlab.html)

Fabio May 4, 2009 04:23

Fluent & matlab
 
Hi all' i would like to export some data of my simulation to matlab, i've choosen the ascii format is that correct? Thanks in advance.

sbaffini May 4, 2009 05:15

Hi,

that's the right choice but in that way you have no control
on the format.

You could consider the following UDF:

/************************************************** ********************
UDF for output
************************************************** ********************/
#include "udf.h"
DEFINE_ON_DEMAND(output)
{
Domain *d;
real x[ND_ND];
real x0, y0, z0, u, v, w;
real p;
FILE *fp;
Thread *t;
cell_t c;
d = Get_Domain(1);
fp = fopen("data.txt","w");
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_CENTROID(x,c,t);
ND_SET(x0, y0, z0, x[0], x[1], x[2]);
ND_SET(u, v, w, C_U(c, t), C_V(c, t), C_W(c, t));
p = C_P(c,t);
fprintf(fp, "%14.12f %14.12f %14.12f ", x0, y0, z0);
fprintf(fp, "%18.16f %18.16f %18.16f %18.16f\n", u, v, w, p);
}
end_c_loop(c,t)
}
fclose(fp);
}

however, not all the variables available through the "export" gui command
are available in a UDF so the export in ASCII could be your only choice.

Regards

Fabio May 4, 2009 11:13

Thank for the answer, if i have understood well you use the UDF to choose wich varible to export.
I have done this through the menu provided in fluent under File\rightarrowExport...
I'm interest in some DPM variables ti plot as an integral in the time variable.

Fabio July 24, 2009 04:38

Hi, which is the easyest wat to read an ASCII file which contains a text header. I need them to do a plot 2D or 3D i haven't decided yet. At the moment i'm using MATLAB, any other way?
Thanks in advance.

divyatman July 24, 2009 06:42

you can use the software Origin. it has an option to import ASCII files and a GUI for plotting all kind of graphs

Fabio August 24, 2009 13:16

Hi, after a bit of time i'm done with calculating the integral in MATALAB. Now i got a 2830x6 matrix, where columns 2 to 4 are the coordinates of the nodes on the control surface mesh, column 6 is the integrated quantity. I would like to make a contour plot, by assigning the proper value to each node, but i'm not able to get back the original circular shape of the surface that i got in FLUENT when i have solved the case. Do you got any advice to postprocess my result in the correct way?

If something is not clear i will try to explain better.

P.S. The problem is that in MATLAB i'm non able to take the coordinates couple by couple and assign the proper value to the node represented by them, more simply get the positions of the nodes in the proper way under MATLAB.


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