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

How to print a message only once with printf in a UDF

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

Reply
 
LinkBack Thread Tools Display Modes
Old   September 23, 2017, 10:08
Question How to print a message only once with printf in a UDF
  #1
Senior Member
 
Astio Lamar
Join Date: May 2012
Location: Pipe
Posts: 186
Rep Power: 7
asal is on a distinguished road
Hello all,

I want to print a variable in a UDF hooked to a BC in my case. However, in each iteration, the message printed several times:

Code:
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
I think the UDF called several times in each iteration and that's why it printed several times.
Any idea how can I call "printf" only once, no matter how many time hooked UDF to the BC called?

Thanks.
asal is offline   Reply With Quote

Old   September 25, 2017, 21:41
Default
  #2
Senior Member
 
Ji Junjie
Join Date: Feb 2010
Location: Shanghai, China
Posts: 111
Rep Power: 10
gearboy is on a distinguished road
Quote:
Originally Posted by asal View Post
Hello all,

I want to print a variable in a UDF hooked to a BC in my case. However, in each iteration, the message printed several times:

Code:
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
BC Pressure: -1.19 [Pa]
I think the UDF called several times in each iteration and that's why it printed several times.
Any idea how can I call "printf" only once, no matter how many time hooked UDF to the BC called?

Thanks.
in the face loop, add
if(f==0)
printf(xxxxxxx);
gearboy 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
Another cylinder question bendel_boy OpenFOAM Native Meshers: blockMesh 5 January 6, 2015 06:09
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
UDF message error (SEGMENTATION VIOLATION" C_H_G louiza FLUENT 0 July 16, 2009 04:38
Parse Error Message While interpreting UDF in FLUENT dhimans Fluent UDF and Scheme Programming 1 July 10, 2009 06:29
error message when compiling the udf brusly FLUENT 6 October 6, 2006 04:30


All times are GMT -4. The time now is 00:29.