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/)
-   -   define_on_demand:Initialization of a scalar (https://www.cfd-online.com/Forums/fluent-udf/189819-define_on_demand-initialization-scalar.html)

mataus June 28, 2017 02:05

define_on_demand:Initialization of a scalar
 
How to use a define_on_demand macro to initialize a scalar in the field?

KaLium June 28, 2017 05:47

This is for all cells:
Code:

DEFINE_ON_DEMAND (scalar_init)
{
  float x = 1.0; /*your value here*/
  Thread *thread; 
  cell_t cell; 
  Domain *domain = Get_Domain(1);       
  thread_loop_c(thread,domain)   
  {     
    begin_c_loop(cell,thread)             
    {     
    C_UDSI(cell,thread,0) = x;       
    }     
    end_c_loop(cell,thread)   
  } 
}


mataus June 28, 2017 07:45

Thank you so much for the reply.
Actually, I am looking for assigning a constant value('0') for all the cells in a particular thread at the start of the calculation.
I wrote my UDF like this

#include "udf.h"

DEFINE_ON_DEMAND(rec)
{
Domain *d;
int zone_id=3;
Thread *t = Lookup_Thread(d,zone_id);
cell_t c;
d = Get_Domain(1);
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_UDMI(c,t,0) = 0;
}
end_c_loop(c,t)
}
}

Then I interpret this udf. but i dont know how to proceed further.
how can i assign the value '0' for all the cells at the beginning of calculation?
Will it assign automatically after i interpret the udf?

KaLium June 28, 2017 08:46

Do you have some non-zero values in UDM-0?

You have to use the DEFINE_ON_DEMAND - macro with manual command.

http://jullio.pe.kr/fluent6.1/help/h...-use-on-demand

Or you can use the Fluent patch panel:

https://www.sharcnet.ca/Software/Flu...g/node1035.htm

mataus June 28, 2017 08:49

Thank you so much...:)


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