CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   printf in DEFINE_PROFILE (https://www.cfd-online.com/Forums/fluent-udf/151790-printf-define_profile.html)

philus April 17, 2015 04:00

printf in DEFINE_PROFILE
 
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

`e` April 17, 2015 04:27

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.

philus April 17, 2015 04:31

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...

`e` April 17, 2015 04:52

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?

pakk April 17, 2015 04:58

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.

philus April 17, 2015 05:13

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 April 17, 2015 05:19

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


All times are GMT -4. The time now is 10:35.