Author Topic: How to calculate geometry diameter using UDF  (Read 1406 times)

Offline mali28

  • Newbie
  • *
  • Posts: 15
  • Reputation: +0/-0
  • Searching for solution
    • View Profile
How to calculate geometry diameter using UDF
« on: January 14, 2012, 09:58:01 PM »
Advertisement
Hello,

I have a geometry with varying diameter along the column height. I want to specify heat loss condition because the wall is insulated. For that, I need to calculate the overall heat transfer coefficient first. For that I need the inside diameter of the column as well. Since the diameter is not constant throughout the geometry, I have to find a way of calculating the distance from the centre of geometry up to the wall using UDF.

Any help will be highly appreciated.

Thank you.

Offline william

  • Full Member
  • ***
  • Posts: 151
  • Reputation: +14/-0
  • Know it, share it.
    • View Profile
Re: How to calculate geometry diameter using UDF
« Reply #1 on: January 15, 2012, 10:29:24 AM »
Fluent offers geometry macros to get the coordinates of the node. Once you know the node coordinates, use the equation of the circle to get the radius. The code below shows how you implement it.


face_t f;
Thread *tf = DT_THREAD(dt);
real xnode, ynode, r;
int n;

begin_f_loop(f,tf) /* Loops over all faces in the thread passed in the DEFINE macro argument */

{
f_node_loop(f,tf,n) /* Loops over all nodes in the face */
{
Node *node;
xnode = NODE_X(node); /* calculate x-coordinate of a grid point on wall */
ynode = NODE_Y(node); /* calculate y-coordinate of a grid point on wall */
r = sqrt(pow(xnode,2)+pow(ynode,2)); /* calculate radial coordinate of the grid point on wall */
}

//Enter your equation here which you want to calculate as a function of radius


}
end_f_loop(f,tf);
« Last Edit: January 15, 2012, 12:46:15 PM by william »

Offline mali28

  • Newbie
  • *
  • Posts: 15
  • Reputation: +0/-0
  • Searching for solution
    • View Profile
Re: How to calculate geometry diameter using UDF
« Reply #2 on: January 15, 2012, 10:39:08 AM »
Thank you very much!

You solved my problem.
 :D