CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

fluent udf, saving data in udf

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   May 26, 2010, 09:08
Default fluent udf, saving data in udf
  #1
Member
 
MOHSEN Zendehbad
Join Date: Aug 2009
Posts: 35
Rep Power: 7
mohsen zendehbad is on a distinguished road
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
mohsen zendehbad is offline   Reply With Quote

Old   May 26, 2010, 09:41
Default
  #2
Member
 
Hongjin Wang
Join Date: Mar 2010
Posts: 37
Rep Power: 7
sosososo1114 is on a distinguished road
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.
sosososo1114 is offline   Reply With Quote

Old   May 26, 2010, 10:09
Default
  #3
New Member
 
Join Date: Mar 2010
Posts: 19
Rep Power: 7
Randre is on a distinguished road
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
Randre is offline   Reply With Quote

Old   May 29, 2010, 03:36
Default
  #4
Member
 
MOHSEN Zendehbad
Join Date: Aug 2009
Posts: 35
Rep Power: 7
mohsen zendehbad is on a distinguished road
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*/
}
}
mohsen zendehbad is offline   Reply With Quote

Old   April 4, 2011, 11:21
Default
  #5
New Member
 
Join Date: Apr 2011
Posts: 1
Rep Power: 0
Stephanie is on a distinguished road
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.
Stephanie is offline   Reply With Quote

Old   October 18, 2012, 21:50
Default
  #6
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Laval University, Canada
Posts: 366
Rep Power: 8
macfly is on a distinguished road
Quote:
Originally Posted by Stephanie View Post
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
macfly is offline   Reply With Quote

Old   October 20, 2012, 13:17
Default
  #7
Member
 
eng_s_sadeghi's Avatar
 
Join Date: Mar 2011
Posts: 64
Rep Power: 6
eng_s_sadeghi is on a distinguished road
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
eng_s_sadeghi is offline   Reply With Quote

Old   October 20, 2012, 14:22
Default
  #8
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Laval University, Canada
Posts: 366
Rep Power: 8
macfly is on a distinguished road
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
macfly is offline   Reply With Quote

Old   December 5, 2012, 01:00
Default conditional case & data file writing
  #9
New Member
 
Join Date: Mar 2010
Posts: 25
Rep Power: 7
Dorit is on a distinguished road
Quote:
Originally Posted by macfly View Post
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
Dorit is offline   Reply With Quote

Old   December 5, 2012, 08:05
Default
  #10
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Laval University, Canada
Posts: 366
Rep Power: 8
macfly is on a distinguished road
Thanks a lot Dorit, it looks good! I'll try it.

François
macfly is offline   Reply With Quote

Old   February 26, 2013, 05:38
Default
  #11
Senior Member
 
rkhr
Join Date: May 2011
Posts: 209
Rep Power: 7
Kanarya is on a distinguished road
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
Kanarya is offline   Reply With Quote

Old   March 21, 2014, 12:29
Default
  #12
New Member
 
Chandrasekhar
Join Date: Oct 2013
Location: new jersey
Posts: 24
Rep Power: 3
chandrasekhar is on a distinguished road
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 View Post
You can write a UDF (using DEFINE_AT_END) for writing special data in a text file whenever you want.
chandrasekhar is offline   Reply With Quote

Old   March 21, 2014, 12:35
Default
  #13
Senior Member
 
rkhr
Join Date: May 2011
Posts: 209
Rep Power: 7
Kanarya is on a distinguished road
Hi,
I think you should use UDF. take a look on DEFINE_PROFILE function.
I hope it helps,
good luck!
kanarya
Kanarya is offline   Reply With Quote

Old   March 21, 2014, 16:36
Default
  #14
New Member
 
Chandrasekhar
Join Date: Oct 2013
Location: new jersey
Posts: 24
Rep Power: 3
chandrasekhar is on a distinguished road
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
chandrasekhar is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF to record FLUENT Solver variables... mariachi Fluent UDF and Scheme Programming 9 February 19, 2010 13:25
UDF in Fluent subha_meter Main CFD Forum 0 October 17, 2009 23:54
fluent UDF external library lapack problem Rick FLUENT 0 May 7, 2008 10:16
accessing solver data with UDF macros Dushan FLUENT 0 October 4, 2006 01:39
UDF of Zimont model in fluent Z Main CFD Forum 0 February 17, 2005 04:07


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