CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF saving data to a text file (https://www.cfd-online.com/Forums/fluent-udf/117056-udf-saving-data-text-file.html)

fleure_Jasmin May 1, 2013 06:29

UDF saving data to a text file
 
Hello everyone,
I'm working on a case of particle injected into a flow and subjected to ultrasound radiation force. I then modeled this force as body force and I introduced it in fluent using Udf where the variable returned is named radforce. The problem is that I can’t see this force in fluent console even if I add this line: Message (‘’ force: %g\n ‘’,radforce) ;
I also tried to write force calculated data in a text file, but nothing works the text file which is in the same folder as the case and the data is empty.
BODY_FORCE(…)
{ FILE *fp;
real radforce;
…/*calcule of radiation force*/
…
if(NULL == (pf = fopen("data.txt","w")))
Error("Could not open file for append!\n");

fprintf(pf,"%e\n",radforce);
fclose(pf);


If someone has an idea and can help I will be really grateful.
Thank you very much J

blackmask May 1, 2013 07:53

Why fp appeared in the declaration section
FILE *fp;
but pf is used in the following
pf = ...
fprintf(pf...) ?

No error during compilation?

fleure_Jasmin May 1, 2013 09:06

Oh thank you Blackmask but it was just a typo when writing this message but the file is fp :)

fleure_Jasmin May 1, 2013 09:10

actually the problem is in the compilation :(


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