CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   UDF - accessing face variable problem (http://www.cfd-online.com/Forums/fluent/84612-udf-accessing-face-variable-problem.html)

argeus February 3, 2011 12:32

UDF - accessing face variable problem
 
Hi all,
really appreciate your help. Im trying to create a UDF for velocity inlet. UDF was interpreted without any problems. Problem is, that Im just not able to access data from appropriate boundary condition (fatal signal, access violation) which I need in my equations.
Problematic part of UDF:

DEFINE_PROFILE(velocity_inlet, thread, index)
{
real x[ND_ND];
double y;
face_t f;
Thread *tf;
ro = 1.225;

begin_f_loop(f, thread)
{
F_CENTROID(x, f, thread);
y = x[1];

density= F_R(f,tf);

F_PROFILE(f, thread, index) = equation;
}
end_f_loop(f,thread)
}

Using Data_Valid_P() function, initialization, or if-loop function didnt help (probably my syntax was incorrect). What should I do?

byronsmith February 6, 2011 03:21

hai,
to access the face boundary, you need to include the thread identifier. use Lookup_thread(d,Zone_ID) where the zone ID is obtained from the boundary conditions panel. try these

DEFINE_PROFILE(velocity_inlet, thread, index)
{
real x[ND_ND];
double y;
face_t f;
int Zone_ID=--- ;
Thread *tf=Lookup_Thread(d,Zone_ID);
Thread *tf;
real ro = 1.225;

begin_f_loop(f, thread)
{
F_CENTROID(x, f, thread);
y = x[1];

density= F_R(f,tf);

F_PROFILE(f, thread, index) = equation;
}
end_f_loop(f,thread)
}

argeus February 9, 2011 05:08

Thank you very much for your help, now it works..:))
Complete version of solution looks like (if someone interested in):

DEFINE_PROFILE(velocity_inlet, thread, index)
{
real x[ND_ND];
double y;
face_t f;
Thread *tf;
int Zone_ID=--- ;
real density;
Domain *domain;
domain = Get_Domain(1);
tf=Lookup_Thread(d,Zone_ID);

begin_f_loop(f, thread)
{
F_CENTROID(x, f, thread);
y = x[1];

density= F_R(f,tf);

F_PROFILE(f, thread, index) = equation;
}
end_f_loop(f,thread)
}


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