CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   How to get each cell value into a text file (http://www.cfd-online.com/Forums/fluent/37077-how-get-each-cell-value-into-text-file.html)

Wiroon June 28, 2005 02:51

How to get each cell value into a text file
 
Dear All,

I am considering mixing of two components inside a 2D-closed geometry where I move its sidewall to trigger internal recirculation. I want to calculate deviation change of concentration with time to evaluate mixing intensity. However, I don't know how to get a value of cell concentration cnd cell grid size from each cell into a file for deviation calculation. Is there a function in Fluent that helps calculating deviation? If anyone knows, please help me.

peter June 28, 2005 10:14

Re: How to get each cell value into a text file
 
To put each cell centroid, species mass fractions and cell volume into a text file, try to compile and then hook as an execute at end UDF something like the following:

DEFINE_EXECUTE_AT_END(All_Out)

{ Domain *dom= Get_Domain(1); /* returns fluid domain pointer */

int index0=0;

int index1=1;

real c0;

real c1;

real cv;

Thread *c_thread ;

real x[ND_ND];

cell_t c;

FILE *fp; /* define a local pointer fp of type FILE */

fp = fopen("data.txt","a"); /* open a file named data.txt in

append mode and assign it to fp */

thread_loop_c(c_thread, dom) /*loops over all cell threads in domain*/

{

begin_c_loop(c, c_thread) /* loops over cells in a cell thread */

{

c0=C_YI(c,c_thread,index0);

c1=C_YI(c,c_thread,index1);

cv=C_VOLUME(c,c_thread);

C_CENTROID(x,c,c_thread);

fprintf(fp, "%g %g %g %g %g\n", x[0], x[1], c0, c1, cv);

}

end_c_loop(c, c_thread)

}

fclose(fp); /* close the file pointed to by fp */

}

Wiroon June 28, 2005 10:35

Re: How to get each cell value into a text file
 
Dear Peter, Thank you very much for your kind help. I will try to understand the program first and then use it in my simulation.


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