
[Sponsors] 
November 13, 2008, 06:42 
Area of a particular face of the cell using UDF

#1 
Guest
Posts: n/a

Hi, Can any body tell me hoe to get the area of a particular cell using UDF. Becoz my main intention is to calculate the surface integral of a scalar over a particular interior face. Any sor tof help is appreciated. Bye


November 13, 2008, 09:23 
Re: Area of a particular face of the cell using UD

#2 
Guest
Posts: n/a

Hi! In FLUENT the face area is given as the magnitude of the face normal vector. See UDFmanual chapter 3.2.4 Face Macros.
the udf macro is the following: DEFINE_ON_DEMAND(calculate_area) { Domain *d = Get_Domain(1); Thread *ft; face_t f; real area = 0.; thread_loop_f(ft,d) { begin_f_loop(f,ft) { real NV_VEC(farea); F_AREA(farea,f,ft); area = NV_MAG(farea); } end_f_loop(f,ft) } } 

March 12, 2013, 05:37 
if?

#3 
New Member

If You have the area and the pressure You can calculate the force.... But if the face has an inclination how to get the force components in the x y direction and not just normal to the face?????


March 31, 2015, 05:31 
Not working

#4 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 4 
Dear all,
I tried the code above for calculating the surface area of a surface whose zone id is known. It is showing Area as 0.0000. I tried with both DEFINE_INIT as well as DEFINE_ON_DEMAND function. Please anybody having Idea on this help me. It will be of great help for me. Thanks in advance, Bharadwaj B S 

March 31, 2015, 07:31 

#5 
Senior Member
Join Date: Nov 2013
Posts: 958
Rep Power: 13 
The code above only calculates the area, it does not show the area. So if you used this code, I am surprised you saw a number on your screen... You probably used a different code.


March 31, 2015, 07:49 
Message()

#6 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 4 
Dear pakk,
I used Message() function to verify the result. During initialization, It showed 0.0000. And it kept on increasing once the calculations started and continued. It never stopped. I wonder whether it is because of face looping. Pardon me and correct me if I have interpreted the facts wrongly. Thanks you, Bharadwaj B S 

March 31, 2015, 07:51 

#7 
Senior Member
Join Date: Nov 2013
Posts: 958
Rep Power: 13 
If you do Message(), nothing will return. Something should be inside the brackets.
Don't make this a puzzle hunt. If you need help, just share the code that you used, don't let us guess what you did. 

March 31, 2015, 08:00 
Code

#8  
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 4 
Dear pakk,
The code which I used for calculating area. Vectors and other needed variable I have declared globally. Quote:
Thank you, Bharadwaj B S 

March 31, 2015, 08:10 

#9 
Senior Member
Join Date: Nov 2013
Posts: 958
Rep Power: 13 
In that case, if you face area is for example 0.000001251, you would indeed see "Area is 0.0000".
If you want more accuracy in your answer, you should tell Fluent to do that. IF my memory is correct: Code:
Message("Area is %e\n",At); Code:
Message("Area is %1.15f\n",At); 

March 31, 2015, 09:20 
Thank you.

#10 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 4 
Dear pakk,
Thank you very much for suggestion. I will try this. And let you know about results. Bharadwaj B S 

April 2, 2015, 06:06 
Working

#11  
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 4 
Dear all,
The function is working fine. I was using DEFINE_ADJUST instead of DEFINE_ON_DEMAND. Pardon me for doubting on the thread. Quote:


May 13, 2015, 07:06 

#12 
New Member
Join Date: Oct 2014
Posts: 11
Rep Power: 4 
Dear Bharadwaj B S,
i need to calculate total area of all negative valued static pressure cells on a face. Can you guide me? Thank you, 

May 13, 2015, 07:10 
info

#13 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 4 
Dear sozen,
I cannot say I can guide you but I can help you on how to calculate the area using UDF. Can you brief me more? I will try to help. regards, Bharadwaj B S 

May 15, 2015, 02:24 

#14 
New Member
Join Date: Oct 2014
Posts: 11
Rep Power: 4 
Thank you dear Bharadwaj B S,
I've got static pressure results over a cylindrical face which contains some negligibleunphysical negative pressure values. All literature studies set these negative values to zero by using UDF. I actually need to calculate surface integral for [pressure=0...p_max] with neglected negative values. I checked that fluent calculates surface integral = surface average * area But this integrated calculation still contains all zeroed area and it disturbs the calculation. So if I'd gotten this zeroed area I could calculate integrals manually only for positive area. Thanks in advance.. Sozen Last edited by sozen; May 18, 2015 at 06:41. 

September 9, 2015, 05:18 
This might help

#15 
Member
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 4 
Dear sozen,
You can do this. While doing the averaging u can open a cell loop, within that u can specify the condition i.e, if (C_P(c,t)==0  C_P(c,t) <=0.0) end; This might do your job I guess. And sorry for late reply. Please make sure of how to end the loop, that was just an example in words. 

September 16, 2015, 03:26 

#16 
Member
Join Date: Jun 2014
Location: Taiwan
Posts: 65
Rep Power: 4 
Hi~
I am new to using UDF. I have a question: is "At" the total surface area of a zone t, or the total face area of a zone t? For example, if a sphere with a radius 1 m contains 10 cells, the surface area of the sphere is 4/3*pi*1^3. (Correction: the surface area of the sphere should be 4*pi*0.5^2) The face area of the sphere is the summation of the surface area of each cell and it should be larger than the surface area of the sphere. Thank you! 

September 16, 2015, 03:30 

#17  
Senior Member
Join Date: Nov 2013
Posts: 958
Rep Power: 13 
Quote:
But if your mesh is good, the difference should be very small. 

September 16, 2015, 04:33 

#18  
Member
Join Date: Jun 2014
Location: Taiwan
Posts: 65
Rep Power: 4 
Thanks for your reply.
In my model as attached, the rectangle domain contains a solid zone with an arbitrary shape and the surrounding is Fluid. I need to calculated the contact area of the SolidFluid interface. Another situation is if the solid zone would change its shape, how to calculate the contact area? Thank you! Modification: The difference of the codes. Codes from Bharadwaj B S: it's a "begin_f_loop," and calculate the area of small faces on the face. F_AREA(A,f,t); At+=NV_MAG(A); Codes from me: it's a "begin_c_loop," and calculate the face area of cells in the zone. f=C_FACE(c,t,n); ss=C_FACE_THREAD(c,t,n); F_AREA(A,f,ss); At+=NV_MAG(A); is this right? If this is right, how do I modify the code? Thank you! Quote:


September 16, 2015, 04:46 

#19 
Senior Member
Join Date: Nov 2013
Posts: 958
Rep Power: 13 
Results>Reports>Surface Integrals>Set up
Report type: Area Select your interface. Click "compute". 

September 16, 2015, 05:03 

#20 
Member
Join Date: Jun 2014
Location: Taiwan
Posts: 65
Rep Power: 4 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Face Area  Corentin  FLUENT  2  April 9, 2008 11:33 
how to get cell face area in RADPRO.F  cthsieh  CDadapco  1  January 2, 2007 09:53 
how to get cell face area and U in registers  chinayu  CDadapco  3  May 16, 2006 08:47 
cell velocity U and its cell face area  Chinayu  CDadapco  0  May 6, 2006 22:44 
Face area  gg  FLUENT  0  June 30, 2003 04:18 