CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

record a variable in UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 22, 2005, 02:25
Default record a variable in UDF
  #1
reto
Guest
 
Posts: n/a
hello

i have an unsteady problem with an UDF. how can i record a variable by time in a file, to get a list? at the moment i use fprintf but i get only the value of the last time step.

thanks

reto
  Reply With Quote

Old   November 22, 2005, 16:30
Default Re: record a variable in UDF
  #2
Zhang
Guest
 
Posts: n/a
My suggestion:

1. Define a DEFINE_ON_DEMAND subroutine. In this subroutine you open an output file. Something like this,"ofp=fopen("out2.txt","w");"

2. Define a DEFINE_EXECUTE_AT_END subroutine. This subroutine will be executed at the end of each time step. In this subroutine your output the value of desired variables. e.g. "fprintf (ofp,"%e\n",variablename);"

3. Define another DEFINE_ON_DEMAND subroutine. In this subroutine you close the output file. "fclose(ofp);"

4. Please include,

#include "stdio.h"

#include "udf.h" and define,

FILE *ofp; at the beginning of your source code file.

5. Before you start the iteration, run the first subroutine through "Define -> User-Defined -> Execute On Demand...". Then iterate. Once the iteration finished, run the third subroutine through "Define -> User-Defined -> Execute On Demand...".

6. Hope it works. Good luck!

Zhang
  Reply With Quote

Old   November 23, 2005, 05:01
Default Re: record a variable in UDF
  #3
reto
Guest
 
Posts: n/a
many thanks for your suggestion, it works!

reto
  Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fluent UDF urgent! Variable reaction rate natantyt Fluent UDF and Scheme Programming 8 October 17, 2021 04:35
Do I need to use UDF to get time-averaged variable? ivanbuz Fluent UDF and Scheme Programming 0 August 11, 2009 15:26
Variable for AVERAGE VELOCITY, Pressure etc. in UDF? aam Fluent UDF and Scheme Programming 0 May 15, 2009 06:21
DEFINE_DPM_OUTPUT macro UDF HELP Puneet FLUENT 3 November 28, 2003 11:55
Yplus UDF variable Matthew Brannock FLUENT 0 June 23, 2003 04:41


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