CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   UDF for writing txt. file (http://www.cfd-online.com/Forums/fluent/46809-udf-writing-txt-file.html)

manu December 12, 2007 12:45

UDF for writing txt. file
 
in a UDF, what is the command to write the value of a variable in a txt. file ???

Greg December 12, 2007 15:25

Re: UDF for writing txt. file
 
Hi,

this UDF writes the Temperature of each cell of a fluid domain (with ID 12) to a text file.

Greg

--------------------------------------------------

#include "udf.h"

FILE *fout;

DEFINE_ON_DEMAND(test)

{

Thread *t;

Domain *domain;

cell_t c;

domain = Get_Domain(1);

t=Lookup_Thread(domain,12);

fout = fopen("test.txt", "w");

begin_c_loop(c,t)

{

fprintf(fout, "Temperature at %d: %g \n",c,C_T(c,t));

}

end_c_loop(c,t)

fclose(fout);

}

manu December 13, 2007 07:19

Re: UDF for writing txt. file
 
Thanks a lot


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