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

How to Reference an Adjacent Cell in a UDF ?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 8, 2011, 11: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


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
LiencubiclowRemodel nzy102 OpenFOAM Bugs 14 January 10, 2012 09:53
Error with Wmake skabilan OpenFOAM Installation 3 July 28, 2009 01:35
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
passing a cell mark to UDF toni FLUENT 0 April 4, 2006 12:11
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 05:15


All times are GMT -4. The time now is 14:52.