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/)
-   -   Assign piece-wise linear temperature to wall. No errors but no function. (https://www.cfd-online.com/Forums/fluent-udf/165955-assign-piece-wise-linear-temperature-wall-no-errors-but-no-function.html)

silent2608 January 30, 2016 10:28

Assign piece-wise linear temperature to wall. No errors but no function.
 
Code:

#include "udf.h"

DEFINE_PROFILE(gradient_temp20,thread,nv)
{
    face_t f;
    real x[ND_ND];
    real dist;
   
    /* loop over each of the faces of this zone */
    begin_f_loop (f,thread)
        {
            F_CENTROID(x,f,thread);
            dist = NV_MAG(x);
            if (dist <= 1.)
                {
                F_PROFILE(f,thread,nv) = 300.;
                }
            else
                {
                F_PROFILE(f,thread,nv) = 600.;
                }
        }
    end_f_loop (f,thread)
}

This works, but now it only works on walls in X-Direction that are at Position 0 on Y axis. I'm going insane.

Please take a look at this, there must be some small error which is not obvious to me.

silent2608 January 30, 2016 14:45

Ok solved.

But I feel like it's a pretty bad solution. Like this I need to perfectly define the y-Position of the wall. Anyone have a solution so I don't need to set starting point for Y Axis? (real orig[ND_ND] = {0.0, 0.0} ?

Code:

#include "udf.h"

DEFINE_PROFILE(temp_wallinside,thread,nv)
{
real orig[ND_ND] = {0.0, 0.0};
real x[ND_ND];
face_t f;
real r;
real temp;

    begin_f_loop (f,thread)
    {
        F_CENTROID(x, f, thread);
        NV_VV(x,=,x,-,orig);
        r = NV_MAG(x);
            if ( r < 1.)
            {
            temp = 300.;
            }
            else if ( r < 2.)
            {
            temp = 400.*(x[0]-1.)+300;
            }
            else
            {
            temp = 700.;
            }
        F_PROFILE(f, thread, nv) = temp;
    }
    end_f_loop(f, thread)
}

DEFINE_PROFILE(temp_walloutside,thread,nv)
{
real orig[ND_ND] = {0.0, 1.0};
real x[ND_ND];
face_t f;
real r;
real temp;

    begin_f_loop (f,thread)
    {
        F_CENTROID(x, f, thread);
        NV_VV(x,=,x,-,orig);
        r = NV_MAG(x);
            if ( r < 1.)
            {
            temp = 300.;
            }
            else if ( r < 2.)
            {
            temp = 400.*(x[0]-1.)+300;
            }
            else
            {
            temp = 700.;
            }
        F_PROFILE(f, thread, nv) = temp;
    }
    end_f_loop(f, thread)
}



All times are GMT -4. The time now is 19:55.