|
[Sponsors] |
May 26, 2010, 10:08 |
fluent udf, saving data in udf
|
#1 |
Member
MOHSEN Zendehbad
Join Date: Aug 2009
Posts: 35
Rep Power: 17 |
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 |
|
May 26, 2010, 10:41 |
|
#2 |
Member
Hongjin Wang
Join Date: Mar 2010
Posts: 37
Rep Power: 16 |
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.
|
|
May 26, 2010, 11:09 |
|
#3 |
New Member
Join Date: Mar 2010
Posts: 19
Rep Power: 16 |
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 |
|
May 29, 2010, 04:36 |
|
#4 |
Member
MOHSEN Zendehbad
Join Date: Aug 2009
Posts: 35
Rep Power: 17 |
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*/ } } |
|
April 4, 2011, 12:21 |
|
#5 |
New Member
Join Date: Apr 2011
Posts: 1
Rep Power: 0 |
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. |
|
October 18, 2012, 22:50 |
|
#6 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
||
October 20, 2012, 14:17 |
|
#7 |
Member
Join Date: Mar 2011
Posts: 64
Rep Power: 15 |
You can write a UDF (using DEFINE_AT_END) for writing special data in a text file whenever you want.
__________________
Saeed Sadeghi Ansys Fluent CFD Consultant |
|
October 20, 2012, 15:22 |
|
#8 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
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 |
|
December 5, 2012, 01:00 |
conditional case & data file writing
|
#9 | |
New Member
Join Date: Mar 2010
Posts: 25
Rep Power: 16 |
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 |
||
December 5, 2012, 08:05 |
|
#10 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
Thanks a lot Dorit, it looks good! I'll try it.
François |
|
February 26, 2013, 05:38 |
|
#11 |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
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 |
|
March 21, 2014, 12:29 |
|
#12 |
New Member
Chandrasekhar
Join Date: Oct 2013
Location: new jersey
Posts: 24
Rep Power: 13 |
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 |
|
March 21, 2014, 12:35 |
|
#13 |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
Hi,
I think you should use UDF. take a look on DEFINE_PROFILE function. I hope it helps, good luck! kanarya |
|
March 21, 2014, 16:36 |
|
#14 |
New Member
Chandrasekhar
Join Date: Oct 2013
Location: new jersey
Posts: 24
Rep Power: 13 |
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 |
|
August 3, 2016, 08:23 |
|
#15 |
New Member
mostafa
Join Date: Jun 2013
Posts: 22
Rep Power: 13 |
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. |
|
June 14, 2017, 00:23 |
|
#16 | |
New Member
Duan Jiawei
Join Date: May 2016
Posts: 4
Rep Power: 10 |
Quote:
(if (= (%rpgetvar 'var_name) 1) (ti-menu-load-string (format #f "fi wcd your_case_name.cas"))) |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF to record FLUENT Solver variables... | mariachi | Fluent UDF and Scheme Programming | 11 | September 24, 2019 01:07 |
accessing solver data with UDF macros | Dushan | FLUENT | 1 | April 22, 2017 22:05 |
UDF in Fluent | subha_meter | Main CFD Forum | 0 | October 18, 2009 00:54 |
fluent UDF external library lapack problem | Rick | FLUENT | 0 | May 7, 2008 11:16 |
UDF of Zimont model in fluent | Z | Main CFD Forum | 0 | February 17, 2005 04:07 |