CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   fluent udf, saving data in udf (http://www.cfd-online.com/Forums/fluent-udf/76462-fluent-udf-saving-data-udf.html)

mohsen zendehbad May 26, 2010 09:08

fluent udf, saving data in udf
 
HI, some where in my udf, when a condition happens, i should make the fluent save the case and data file, is it possible?

in other words, what is the udf command to have fluent save the case and data files?

MERCI
MZ

sosososo1114 May 26, 2010 09:41

Yes, it is . You can just use DEFINE_RW_FILE macro to write or read a case/data file. But I get used to using journal files or scheme files. You can also use the autosave commend in the file menue bar to write case&data automatically. Or u can use solve->excute-commends to do so.

Randre May 26, 2010 10:09

You can write a file with DEFINE_EXECUTE_AT_END, with a search in google i've found the following UDF which saves the data of a moving object:

DEFINE_EXECUTE_AT_END (execute_at_end)
{

FILE * fp; /* Declaring file variable */
real TH0, th1, TH2;

/* record the kinematic data in the file */
fp = fopen ("Motion.txt", "a"); /* Open a file to add data to the end */

/* Format output data file */

fprintf (fp, "% E", CURRENT_TIME); /* Current time in */
fprintf (fp, "% E% E% E", DT_CG (dt)[0],DT_CG(dt)[1], DT_CG(dt)[2]); /* center of gravity position */
fprintf (fp, "% E% E% E", DT_VEL_CG(dt)[0], DT_VEL_CG(dt)[1], DT_VEL_CG(dt)[2]); /* Speed the center of gravity, m / s */
TH0 = DT_THETA (dt) [0] * 180.0 / M_PI;
th1 = DT_THETA (dt) [1] * 180.0 / M_PI;
TH2 = DT_THETA (dt) [2] * 180.0 / M_PI;
fprintf (fp, "% E% E% E", TH0, th1, TH2); /* Angular position, degrees */
fprintf (fp, "% E% E % E\n", DT_OMEGA_CG(dt)[0], DT_OMEGA_CG (dt)[1], DT_OMEGA_CG (dt)[2]); /* Angular velocity, rad / s */

fclose (fp); /* Closing the file */
}

Hope It helps

mohsen zendehbad May 29, 2010 03:36

Dear Friends:
This is not what i want. when you save your case and data file, you create a *.cas and *.dat file. what i want is to create these files when a condition happens in my solution procedure; some thing like this:

DEFINE_EXECUTE_AT_END()
{
if (condition==OK)
{
/*save the case and data file for future postprocessing*/
}
}

Stephanie April 4, 2011 11:21

Hi,

I would like the same thing as mohsen zendehbad,
DEFINE_EXECUTE_AT_END()
{
if (condition==OK)
{
/*save the case and data file for future postprocessing*/
}
}

does anyone get a solution? Or know another way of doing it?
Thanks.

macfly October 18, 2012 21:50

Quote:

Originally Posted by Stephanie (Post 302159)
DEFINE_EXECUTE_AT_END()
{
if (condition==OK)
{
/*save the case and data file for future postprocessing*/
}
}


Dear all,

Anybody has the solution to this? It would be much appreciated!

Regards,
François

eng_s_sadeghi October 20, 2012 13:17

You can write a UDF (using DEFINE_AT_END) for writing special data in a text file whenever you want.

macfly October 20, 2012 14:22

Hi Saeed,

By "/*save the case and data file for future postprocessing*/", we mean saving everything just like we do in the GUI with File\Write\Case and Data...

I don't want to have to specify every variable and parameters (more than 100!) that I want to save in 6 domains that have about 500 surfaces...

François

Dorit December 5, 2012 01:00

conditional case & data file writing
 
Quote:

Originally Posted by macfly (Post 387685)
Hi Saeed,

By "/*save the case and data file for future postprocessing*/", we mean saving everything just like we do in the GUI with File\Write\Case and Data...

I don't want to have to specify every variable and parameters (more than 100!) that I want to save in 6 domains that have about 500 surfaces...

François

Hi Francois,

This can be done but you'll need to define scheme variables for that:

1) in Fluent main window: (rp-var-define 'var_name 0 'integer #f)
2) in UDF
if (condition==ok)
{write_data = 1;}
else
{write_data = 0;}
RP_Set_Integer ("var_name", write_data);
3) in Fluent -> Calculation Activities -> Execute Commands -> Command:
(if (= (%rpgetvar 'var_name) 1 (ti-menu-load-string (format #f "fi wcd your_case_name.cas.gz")))
use your_case_name_%t if you want to append file name with time step.

Hope it helps!
Dorit

macfly December 5, 2012 08:05

Thanks a lot Dorit, it looks good! I'll try it.

François

Kanarya February 26, 2013 05:38

Hi
I am using DEFINE_EXECUTE_AT_END in parallel to save outlet flow but it doesnt work properly.in serial I dont have any problem do you think it is because of the function or there is other reason?

thanks in advance

chandrasekhar March 21, 2014 12:29

Hi
i would like to run Ansys Fluent each time for a different value of the boundary condition at a wall(say). right now what i am doing is using the modifications window in ansys fluent. i would like to know if there is another way. i checked out the parameter tool but from what i have read i have to manually run the case each time for a different parameter(different value of the bc). is there a udf or scheme command which can change the boundary condition each time , run the case , save the case and data file respectively and run again for a different boundary condition and so on. Any help on this would be appreciated. Many thanks for replying.

with regards


Quote:

Originally Posted by eng_s_sadeghi (Post 387674)
You can write a UDF (using DEFINE_AT_END) for writing special data in a text file whenever you want.


Kanarya March 21, 2014 12:35

Hi,
I think you should use UDF. take a look on DEFINE_PROFILE function.
I hope it helps,
good luck!
kanarya

chandrasekhar March 21, 2014 16:36

Hi
thanks for the reply. i checked out the profile macro, but i have to change the bc, save the case and data file and run the simulation with different bc. i just saw a video of the do loop in scheme program for fluent that i think should work for my case.

with regards


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