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_ADJUST to patch at each time step? (https://www.cfd-online.com/Forums/fluent-udf/131409-define_adjust-patch-each-time-step.html)

ghost82 March 14, 2014 06:32

DEFINE_ADJUST to patch at each time step?
 
1 Attachment(s)
Hi all,
I have a problem with a udf (I'm not very expert).

Problem: 2D problem with 2 fluids and one solid, as in the attached picture.
Only energy is solved, no motion.
Problem is transient: total time 7200 seconds, time step: 1 second

I want to patch water at each time step with a temperature which is function of time (linear function, from 5 ˚C at time 0 s to 8 ˚C at time 7200 s).

I think I should go with the DEFINE_ADJUST macro but I don't know how to assign temperature to water domain.

Any help is appreciated.

Thank you,

Daniele

ghost82 March 14, 2014 07:42

Solved, if anyone else needs it:

Code:

#include "udf.h"

DEFINE_ADJUST(my_adjust,d)
{
    cell_t c;
    Thread *t;
    real xc[ND_ND];
    real time = CURRENT_TIME;

    thread_loop_c(t,d)
    {
            begin_c_loop_all(c,t)
            {
                    C_CENTROID(xc,c,t);
                   
                    /*put here the temperature function of time such as C_T(c,t)=(3.0/7200.0*time+36000.0/7200.0)+273.15; Use if && || to define zones by system geometry to patch */

            }
            end_c_loop_all(c,t)
    }
}



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