CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

How to Reference an Adjacent Cell in a UDF ?

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

Reply
 
LinkBack Thread Tools Display Modes
Old   March 8, 2011, 10:33
Default How to Reference an Adjacent Cell in a UDF ?
  #1
New Member
 
Join Date: Mar 2011
Posts: 2
Rep Power: 0
jeff8541 is on a distinguished road
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:


DEFINE_PROFILE(box_temp_step, thread, position)
/** 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;

int adjacent_cell = F_C1(f,thread);
int adjacent_thread = THREAD_T1(thread);
real boxtemp = C_T(adjacent_cell,adjacent_thread);

begin_f_loop(f, thread)
{
F_CENTROID(r, f, thread);
if (airtemp <= Tactivate) {
F_PROFILE(f,thread,position) = boxtemp;
}else if(airtemp > Tactivate) {
F_PROFILE(f,thread,position) = Tp;
}

}
end_f_loop(f, thread)
}
/** Code should turn the tank on whenever the mean air temperature reaches above 284.82. When the tank is turned on it has a constant temperature of Tp. When the mean air temp drops below 284.82, the tank should turn off and equalize to the surrounding temperature **/
jeff8541 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
LiencubiclowRemodel nzy102 OpenFOAM Bugs 14 January 10, 2012 08:53
Error with Wmake skabilan OpenFOAM Installation 3 July 28, 2009 00:35
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08
passing a cell mark to UDF toni FLUENT 0 April 4, 2006 11:11
Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 2 July 15, 2005 04:15


All times are GMT -4. The time now is 18:26.