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

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

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By gearboy

Reply
 
LinkBack Thread Tools Search this Thread 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: 13
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
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
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);
skanjosh likes this.
gearboy is offline   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
[blockMesh] Another cylinder question bendel_boy OpenFOAM Meshing & Mesh Conversion 5 January 6, 2015 05:09
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 22: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 16:08.