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 |
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.
|
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 |
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*/ } } |
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. |
Quote:
Dear all, Anybody has the solution to this? It would be much appreciated! Regards, François |
You can write a UDF (using DEFINE_AT_END) for writing special data in a text file whenever you want.
|
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 |
conditional case & data file writing
Quote:
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 |
Thanks a lot Dorit, it looks good! I'll try it.
François |
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 |
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:
|
Hi,
I think you should use UDF. take a look on DEFINE_PROFILE function. I hope it helps, good luck! kanarya |
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 |
hi Dorit.
i read your nswer, it was very very helpful, and it was actually the only way to write data meanwhile of calculation based on the happening of a condition. but would you give a very simple example to do this. because i think you used of some abbreviations in your answer ("fi wcd"). also i think you missed a ")" if if statement. |
Quote:
(if (= (%rpgetvar 'var_name) 1) (ti-menu-load-string (format #f "fi wcd your_case_name.cas"))) |
All times are GMT -4. The time now is 23:30. |