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/)
-   -   temperature sensor (https://www.cfd-online.com/Forums/fluent-udf/239888-temperature-sensor.html)

erfan2000 November 30, 2021 17:16

temperature sensor
 
Hello dear friends
I have a problem in which there's a solid and a pipe is on top of it with water flow. I want to write a UDF which changes the water inlet velocity corresponding to the temperature of a specific location of the solid. I'll be thankful if you help me with this frustrating problem. I've written this UDF which needs to be corrected.
Code:

DEFINE_PROFILE(InletVelocity, t, i)
{

face_t f;
begin_f_loop (f,t)
{
        real temp=0.;
        real thermosensor_coordinate[ND_ND];
        cell_t c;
        Domain *d;
        Thread *t;
        d = Get_Domain(1);
        real xmin=0.0049215709;
        real ymin=-0.049582131;
        real zmin=-0.028587651;
        real tmax=0.;
        real x,y,z;       
        temp=C_T(c,t);
        if (temp>=305 && temp<=315)
                F_PROFILE(f,t,i) = 5;
        else if (temp>315)
                F_PROFILE(f,t,i) = 10;
        else
                F_PROFILE(f,t,i) = 1;
}
end_f_loop(f,t)
}

thanks in advance

AlexanderZ November 30, 2021 22:47

compile code
Code:

DEFINE_PROFILE(InletVelocity, t, i)
{
cell_t c;
CX_Cell_Id cx_cell;
Thread *t;
face_t f;
real NV_VEC(pt);
real tmax=0.;
real temp=0.;
NV_D(pt, =, 0.0049215709, -0.049582131, -0.028587651);
CX_Start_ND_Point_Search();
cx_cell=*CX_Find_Cell_With_Point(pt);
CX_End_ND_Point_Search();
c = RP_CELL(&cx_cell); //the right cell number
t = RP_THREAD(&cx_cell); // the thread
temp=C_T(c,t);
begin_f_loop (f,t)
{
        if (temp>=305 && temp<=315)
                F_PROFILE(f,t,i) = 5;
        else if (temp>315)
                F_PROFILE(f,t,i) = 10;
        else
                F_PROFILE(f,t,i) = 1;
}
end_f_loop(f,t)
}


erfan2000 December 1, 2021 04:15

thank you but these errors have occurred during compiling:
Code:

warning: cast to 'void * __ptr32' from smaller integer type 'unsigned long' [-Wint-to-void-pointer-cast]
    return((void * POINTER_32) (unsigned long) (ULONG_PTR) p);

warning: incompatible redeclaration of library function 'strncasecmp' [-Wincompatible-library-redeclaration]
int strncasecmp (const char *, const char *, int);

note: 'strncasecmp' is a builtin with type 'int (const char *, const char *, unsigned long long)'

fatal error: 'ud_io1.h' file not found
#  include "ud_io1.h"

thank you

AlexanderZ December 3, 2021 01:59

compile code
Code:

#include "udf.h"
#include "cxndsearch.h"

DEFINE_PROFILE(InletVelocity, t, i)
{
static ND_Search *domain_table=NULL;
cell_t c;
CX_Cell_Id cx_cell;
Thread *tc;
face_t f;
real NV_VEC(pt);
real tmax=0.;
real temp=0.;
NV_D(pt, =, 0.0049215709, -0.049582131, -0.028587651);

domain_table = CX_Start_ND_Point_Search( domain_table,TRUE,-1);
cx_cell = *CX_Find_Cell_With_Point(domain_table,pt,0.0);
domain_table=CX_End_ND_Point_Search(domain_table);

c = RP_CELL(&cx_cell); //the right cell number
tc = RP_THREAD(&cx_cell); // the thread
temp=C_T(c,tc);
begin_f_loop (f,t)
{
        if (temp>=305 && temp<=315)
                F_PROFILE(f,t,i) = 5;
        else if (temp>315)
                F_PROFILE(f,t,i) = 10;
        else
                F_PROFILE(f,t,i) = 1;
}
end_f_loop(f,t)
}


erfan2000 December 4, 2021 13:57

thank you
Now I have a new problem with this UDF. When I compile this and apply it to the velocity, this message is showed and the fluent suddenly closed.
https://s4.uupload.ir/files/photo_20...22-00_4gbe.jpg
do you know what's wrong? and as I really have a problem with compiled UDF. Can I change this UDF in a way to be used as an interpreted UDF?
thanks a lot, and sorry for asking a lot of questions.


All times are GMT -4. The time now is 02:46.