# Area of a particular face of the cell using UDF

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

 November 13, 2008, 06:42 Area of a particular face of the cell using UDF #1 krish 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 sozen likes this.

 November 13, 2008, 09:23 Re: Area of a particular face of the cell using UD #2 e0125583 Guest   Posts: n/a Hi! In FLUENT the face area is given as the magnitude of the face normal vector. See UDF-manual 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) } } elcino, cMichael and sozen like this.

 March 12, 2013, 05:37 if? #3 New Member   Luca Gorasso Join Date: Oct 2011 Location: Harbin, China Posts: 24 Rep Power: 7 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: 3 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: 933 Rep Power: 12 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: 3 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: 933 Rep Power: 12 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

Join Date: Jan 2015
Posts: 75
Rep Power: 3
Dear pakk,

The code which I used for calculating area. Vectors and other needed variable I have declared globally.

Quote:
 DEFINE_ADJUST(areacalc,d) { d = Get_Domain(1); t = Lookup_Thread(d, ID); begin_f_loop(f,t) if PRINCIPAL_FACE_P(f,t) { F_AREA(A,f,t); At+=NV_MAG(A); }end_f_loop(f,t) t_a=PRF_GRSUM1(At); Message("Area is %f\n",At); } }
Please suggest me if there is any mistakes.

Thank you,

 March 31, 2015, 08:10 #9 Senior Member   Join Date: Nov 2013 Posts: 933 Rep Power: 12 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);` or Code: `Message("Area is %1.15f\n",At);` And now you see why it is important to include the relevant part of the code you are working with. The problem was not in the calculation, but in the way you show the result.

 March 31, 2015, 09:20 Thank you. #10 Member   Baradwaj B S Join Date: Jan 2015 Posts: 75 Rep Power: 3 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

Join Date: Jan 2015
Posts: 75
Rep Power: 3
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:
 DEFINE_ON_DEMAND(areacalc) { d = Get_Domain(1); t = Lookup_Thread(d, ID); begin_f_loop(f,t) if PRINCIPAL_FACE_P(f,t) { F_AREA(A,f,t); At+=NV_MAG(A); }end_f_loop(f,t) Message("Area is %e\n",At); } }

 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: 3 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 negligible-unphysical 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: 3 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. sozen likes this.

September 16, 2015, 03:26
#16
Member

Join Date: Jun 2014
Location: Taiwan
Posts: 54
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!

Quote:
 Originally Posted by Bharadwaj B S Dear pakk, The code which I used for calculating area. Vectors and other needed variable I have declared globally. Please suggest me if there is any mistakes. Thank you, Bharadwaj B S

September 16, 2015, 03:30
#17
Senior Member

Join Date: Nov 2013
Posts: 933
Rep Power: 12
Quote:
 Originally Posted by SJSW 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. 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!
In your geometry, there are only cells that approximate the sphere. The sphere is not there, and Fluent has no information that your cells originally were a sphere. So Fluent will never give an answer about that sphere, but always an answer about the cells that approximate the sphere.

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: 54
Rep Power: 4

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 Solid-Fluid 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.
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);
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:
 Originally Posted by pakk In your geometry, there are only cells that approximate the sphere. The sphere is not there, and Fluent has no information that your cells originally were a sphere. So Fluent will never give an answer about that sphere, but always an answer about the cells that approximate the sphere. But if your mesh is good, the difference should be very small.
Attached Images
 Untitled123.png (11.3 KB, 8 views)

 September 16, 2015, 04:46 #19 Senior Member   Join Date: Nov 2013 Posts: 933 Rep Power: 12 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: 54
Rep Power: 4
Thank you!

It is OK, but I have to calculate the contact area by UDF.

Quote:
 Originally Posted by pakk Results->Reports->Surface Integrals->Set up Report type: Area Select your interface. Click "compute".

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Corentin FLUENT 2 April 9, 2008 11:33 cthsieh CD-adapco 1 January 2, 2007 09:53 chinayu CD-adapco 3 May 16, 2006 08:47 Chinayu CD-adapco 0 May 6, 2006 22:44 gg FLUENT 0 June 30, 2003 04:18

All times are GMT -4. The time now is 05:02.