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

printf in DEFINE_PROFILE

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 17, 2015, 04:00
Default printf in DEFINE_PROFILE
  #1
Member
 
Join Date: Jan 2015
Posts: 40
Rep Power: 11
philus is on a distinguished road
Hi all,

there is an "easy" thing that I cannot understand: why the following code do not generate a single output "h=..." in the console, but more than one and less than the face cell number or I don't know what?

Code:
DEFINE_PROFILE (name,t,i){
   real h;
   h=some expression;

   printf("h=%f\n",h);

   begin_f_loop(f,t){
      F_PROFILE(f,z,i)=h;
   }end_f_loop(f,t)
}
I was expecting that, since printf is out of the loop, there was only one output...

Can anyone help me on that?

Thanks in advance,
philus
philus is offline   Reply With Quote

Old   April 17, 2015, 04:27
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
How many times is the output "h=..." repeated? Are you running Fluent in serial or parallel? I suspect this output would be repeated for each parallel process if it's outside a loop. Each process executes this DEFINE_PROFILE macro.
`e` is offline   Reply With Quote

Old   April 17, 2015, 04:31
Default
  #3
Member
 
Join Date: Jan 2015
Posts: 40
Rep Power: 11
philus is on a distinguished road
I also thought that, but when I ran Fluent in serial I had it 11 times...

Otherwise I have 100 cells on the boundary, 3 domains...
philus is offline   Reply With Quote

Old   April 17, 2015, 04:52
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
How many times was this phrase repeated in parallel, and how many processors were used? When are these outputs printed to the screen: during initialisation, iterations or otherwise?
`e` is offline   Reply With Quote

Old   April 17, 2015, 04:58
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
This code is called every time Fluent needs to know the profile.

To make it more concrete, suppose that this is a pressure boundary condition. In every iteration, Fluent may need this profile more than once, depending on which numerical scheme is used, which discretization, and maybe depending on more factors.
And if you plot the pressure, Fluent also collects this information, so this code is also run.

Fluent could have been programmed differently, such that it executes the code once per iteration, and stores the result in memory, but that is not how it is implemented.
pakk is offline   Reply With Quote

Old   April 17, 2015, 05:13
Default
  #6
Member
 
Join Date: Jan 2015
Posts: 40
Rep Power: 11
philus is on a distinguished road
I copy paste what happens in parallel mode on 2 CPUs. At the beginning I read an initialized simulation. I think that the first time it compute h frome the results of the initialization. After this it does the update (don't know what is it..) and then starts the iterations. There it do 2 times per iteration (so, there you were right!), but at the end...incomprehensible!

Sorry for the long code


Code:
Reading "\"| gunzip -c \\\"Flower-h2o-v8-2.dat.gz\\\"\""...
       1 user-defined node memory locations, 3829 nodes, binary.
Parallel variables...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
Done.

h=...
h=...
h=...
h=...
h=...
h=...

Updating solution at time level N... done.
h=...
h=...
h=...
h=...
  iter  continuity  x-velocity  y-velocity      energy     time/iter
!  157 solution is converged
   157  3.7286e-08  6.4842e-07  9.4505e-07  1.1936e-16  0:00:00 1000
h=...
h=...
h=...
h=...
h=...
h=...
   158  9.1256e-05  8.0999e-02  2.2566e-01  1.3977e-07  0:00:22  999
h=...
h=...
   159  2.4483e-02  2.9444e-02  3.6535e-01  7.7532e-09  0:00:25  998
h=...
h=...

[*** I cut the rest.... ***]

   195  1.2377e-07  6.8890e-07  1.1911e-06  1.9772e-16  0:00:38  962
h=...
h=...
!  196 solution is converged
   196  9.4425e-08  5.2995e-07  8.9362e-07  1.9223e-16  0:00:37  961
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
h=...
  step  flow-time       h_ext  t_h2o_mean t_tube_mean t_insulation
     2  1.0000e+01         nan  3.5315e+02  3.5314e+02  3.1153e+02
Flow time = 10s, time step = 2
philus is offline   Reply With Quote

Old   April 17, 2015, 05:19
Default
  #7
Member
 
Join Date: Jan 2015
Posts: 40
Rep Power: 11
philus is on a distinguished road
Ok, thank you pakk and sorry: you answered during I was writing the reply.

I now understand what it happens.

I must now understand why, some time, I got different values, but this is my task ;-)

Thanks a lot, thanks to everybody!
philus
philus is offline   Reply With Quote

Reply

Tags
define_profile, output, printf, udf


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
A problem about 'printf' and 'Message' in UDF. LICH Fluent UDF and Scheme Programming 2 May 2, 2013 02:45
problem printf fluent marye FLUENT 2 June 7, 2010 05:19
C, printf marye FLUENT 0 June 1, 2010 06:08
Problems in compiling paraview in Suse 10.3 platform chiven OpenFOAM Installation 3 December 1, 2009 07:21


All times are GMT -4. The time now is 09:43.