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 time step size with max or min of Temp in a domain (https://www.cfd-online.com/Forums/fluent-udf/146050-define-time-step-size-max-min-temp-domain.html)

ho3ein.agl December 17, 2014 13:33

Define time step size with max or min of Temp in a domain
 
Hi cfd-online

I have a very very sensible unsteady simulation and it must run with small time step size.

I want to use DEFINE_DELTAT and set Deltat function of some cell variable in a domain.

for example
if max Temp < T1 then Deltat=a
if max Temp >= T1 then Deltat=b
if max Liquid fraction > 0 then Deltat=c
.
.
.


is it possible to do that?

I think "Looping Over Cell Threads in a Domain (thread_loop_c)" can help me if I use that in DEFINE_DELTAT macro.

thank you

ho3ein.agl December 18, 2014 05:30

my udf is:

Red number is line number in udf commands .
Code:

DEFINE_DELTAT(mydeltat, domain)
{
        real time_step;
        real T_max=0.0 ;
        real T1=303.0 ;
        real T2=300.5 ;
        real T3=304.0 ;
        Thread t;
    cell_t c;
54        thread_loop_c(t,domain)
        {
56                begin_c_loop(c,t)
                {
58                        temp = C_T(c,t);
                        if (temp > T_max || T_max == 0.0) T_max = temp;
                }
                end_c_loop(c,t)
        }
        if (T_max < T1) time_step = 1.0;
        else time_step = 0.00001;
        return time_step;
}


error after build in compiler window:

Done.

(chdir "libudf")(chdir "win64\2ddp")# Generating ud_io1.h
Paper_PCM_Prop_and_DeltaT_v2.c
..\..\src\Paper_PCM_Prop_and_DeltaT_v2.c(54) : error C2440: '=' : cannot convert from 'thread_struct *' to 'Thread'
..\..\src\Paper_PCM_Prop_and_DeltaT_v2.c(54) : error C2088: '!=' : illegal for struct
..\..\src\Paper_PCM_Prop_and_DeltaT_v2.c(54) : error C2232: '->next' : left operand has 'struct' type, use '.'
..\..\src\Paper_PCM_Prop_and_DeltaT_v2.c(56) : error C2232: '->nelements' : left operand has 'struct' type, use '.'
..\..\src\Paper_PCM_Prop_and_DeltaT_v2.c(58) : error C2232: '->storage' : left operand has 'struct' type, use '.'

Done.

whats wrong in udf?

pakk December 18, 2014 05:57

Instead of making "t" a thread variable, in
Code:

Thread t;
you should make it a pointer to a thread variable:
Code:

Thread *t;

ho3ein.agl December 18, 2014 06:59

ok , Its work :)


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