CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   Initialization error (

CMA December 3, 2012 15:46

Initialization error
Hi all, I am trying to write a UDF for my inlet boundary condition. I want the temperature of this inlet face to be updated at every time step to a new value that is calculated based on a formula that includes the temperature of my outflow boundary. That means, I set an inlet tube fluid temperature, and then after a few iterations (up to 60s) the temperature of my outflow boundary at the outlet of my tube is taken (in this case 283 K because I am setting everything around my tube and my inlet to be at 283 C for the first 60 s) and my new inlet temperature is calculated. With this new inlet temperature, a new outlet temperature is produced and then my UDF calculates a new inlet again and so on.
When I interpret my UDF everything works fine with no error. But as soon as I choose a boundary or all zones in the drop down list in the initialization window, I get an ACCESS VIOLATION error.

Here is my UDF:

#include "udf.h"

DEFINE_PROFILE(Inlettemp, thread, i)
real t=RP_Get_Real("flow-time");
face_t f;
face_t face;
int ID = 4;
/* Zone ID for Outflow zone from Boundary Conditions panel */
Domain *domain; /* domain is declared as a variable */
Thread *outlet_thread = Lookup_Thread(domain, ID);
real tempa=0.0;
real totalarea=0.0;
real avetempa=0.0;
real A[ND_ND];

if(t<=60){F_PROFILE(face, thread, i)=283.0;}

else if(t>60)
/* Loop over faces in a face thread to get the information stored on faces and calculate the area average temperature on Outlet. */
/* F_T gets face temperature. += causes all face temperatures to be added together. */

totalarea += F_AREA(A,f,outlet_thread);
tempa += F_AREA(A,f,outlet_thread)*F_T(f,outlet_thread);

avetempa = tempa/totalarea;

begin_f_loop(face, thread)
F_PROFILE(face, thread, i) = avetempa + 30*200/(0.561*4182);
end_f_loop(face, thread)

All times are GMT -4. The time now is 23:57.