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

record a variable in UDF

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

Reply
 
LinkBack Thread Tools 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

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
Fluent UDF urgent! Variable reaction rate natantyt Fluent UDF and Scheme Programming 5 July 25, 2016 08:17
Do I need to use UDF to get time-averaged variable? ivanbuz Fluent UDF and Scheme Programming 0 August 11, 2009 14:26
Variable for AVERAGE VELOCITY, Pressure etc. in UDF? aam Fluent UDF and Scheme Programming 0 May 15, 2009 05: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 03:41


All times are GMT -4. The time now is 18:21.