CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   How to Reference an Adjacent Cell in a UDF ? (https://www.cfd-online.com/Forums/fluent/85851-how-reference-adjacent-cell-udf.html)

 jeff8541 March 8, 2011 11:33

How to Reference an Adjacent Cell in a UDF ?

Hello,

I am trying to reference the temperature of an adjacent cell and assign the temperature of that cell to another cell.

Here is a basic overview of what I am doing:

A box is surrounded by another larger solid. A temp gradient in the solids are created by a fluid flowing past the larger solid. The flowing fluid temperature is based off a sine function. When the fluid temp is above a specific value the interior box walls should be a constant temp. When the fluid temp drops back below the specific value, the box walls should no longer be a constant temp, they should equalize to the surrounding solid temp.

1) assign a constant temperature to the faces of the box for a period of time when the fluid temp is above Tactivate.

2) when the surrounding fluid temp drops below Tactivate, I want the face temp of the box to no longer be at a constant temp. The box temp should essentually equalize to the surrounding solid temp.

I tried to set the temperature of the box equal to the temperature of the adjacent cells outside the box. The idea is that the cells adjacent to the face will be affected by the surrounding solid and the interior box will slowly re-establish equilibrium.

The UDF will interpret, but the setup closes when I try to calculate.

Here's some of the code:

/** Apply to box edges **/
{
real t = CURRENT_TIME;
real r[3];
real A = 12.727;
real B = 6.346017;
real D = 15.7;
real E = -1.84;
real airtemp = A*sin(B*t/(365*24*60*60)+E)+D+273.15;
real pi = 3.1415926535897932384626433832795;
real e = 2.718281828182818;
real boxdepth = 1.524;
real Tp = 305.15;
real Tactivate = 284.82;

face_t f;

{