CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

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

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   January 30, 2016, 11:28
Default Assign piece-wise linear temperature to wall. No errors but no function.
  #1
New Member
 
Join Date: Nov 2015
Posts: 16
Rep Power: 2
silent2608 is on a distinguished road
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.

Last edited by silent2608; January 30, 2016 at 15:46.
silent2608 is offline   Reply With Quote

Old   January 30, 2016, 15:45
Default
  #2
New Member
 
Join Date: Nov 2015
Posts: 16
Rep Power: 2
silent2608 is on a distinguished road
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)
}
silent2608 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Floating point exception error lpz_michele OpenFOAM Running, Solving & CFD 53 October 19, 2015 02:50
Running UDF with Supercomputer roi247 FLUENT 4 October 15, 2015 13:41
Non-constant heat flux (as a function of wall temperature)) Laplace CFX 1 February 23, 2014 17:56
How to write k and epsilon before the abnormal end xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 15:33
error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Native Meshers: blockMesh 2 March 14, 2012 10:56


All times are GMT -4. The time now is 04:31.