CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

Area of a particular face of the cell using UDF

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

Like Tree7Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   November 13, 2008, 06:42
Default 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.
  Reply With Quote

Old   November 13, 2008, 09:23
Default 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.
  Reply With Quote

Old   March 12, 2013, 05:37
Default if?
  #3
New Member
 
Luca Gorasso
Join Date: Oct 2011
Location: Harbin, China
Posts: 24
Rep Power: 6
elcino is on a distinguished road
Send a message via Skype™ to elcino
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?????
elcino is offline   Reply With Quote

Old   March 31, 2015, 05:31
Default Not working
  #4
Member
 
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 3
Bharadwaj B S is on a distinguished road
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
Bharadwaj B S is offline   Reply With Quote

Old   March 31, 2015, 07:31
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 863
Rep Power: 12
pakk will become famous soon enough
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.
pakk is offline   Reply With Quote

Old   March 31, 2015, 07:49
Default Message()
  #6
Member
 
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 3
Bharadwaj B S is on a distinguished road
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
Bharadwaj B S is offline   Reply With Quote

Old   March 31, 2015, 07:51
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 863
Rep Power: 12
pakk will become famous soon enough
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.
pakk is offline   Reply With Quote

Old   March 31, 2015, 08:00
Default Code
  #8
Member
 
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 3
Bharadwaj B S is on a distinguished road
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,
Bharadwaj B S
Bharadwaj B S is offline   Reply With Quote

Old   March 31, 2015, 08:10
Default
  #9
Senior Member
 
Join Date: Nov 2013
Posts: 863
Rep Power: 12
pakk will become famous soon enough
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.
pakk is offline   Reply With Quote

Old   March 31, 2015, 09:20
Default Thank you.
  #10
Member
 
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 3
Bharadwaj B S is on a distinguished road
Dear pakk,

Thank you very much for suggestion. I will try this. And let you know about results.

Bharadwaj B S
Bharadwaj B S is offline   Reply With Quote

Old   April 2, 2015, 06:06
Default Working
  #11
Member
 
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 3
Bharadwaj B S is on a distinguished road
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);
}
}
sozen likes this.
Bharadwaj B S is offline   Reply With Quote

Old   May 13, 2015, 07:06
Default
  #12
New Member
 
Join Date: Oct 2014
Posts: 11
Rep Power: 3
sozen is on a distinguished road
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,
sozen is offline   Reply With Quote

Old   May 13, 2015, 07:10
Default info
  #13
Member
 
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 3
Bharadwaj B S is on a distinguished road
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
Bharadwaj B S is offline   Reply With Quote

Old   May 15, 2015, 02:24
Default
  #14
New Member
 
Join Date: Oct 2014
Posts: 11
Rep Power: 3
sozen is on a distinguished road
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.
sozen is offline   Reply With Quote

Old   September 9, 2015, 05:18
Default This might help
  #15
Member
 
Baradwaj B S
Join Date: Jan 2015
Posts: 75
Rep Power: 3
Bharadwaj B S is on a distinguished road
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.
Bharadwaj B S is offline   Reply With Quote

Old   September 16, 2015, 03:26
Default
  #16
Member
 
Join Date: Jun 2014
Location: Taiwan
Posts: 45
Rep Power: 3
SJSW is on a distinguished road
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 View Post
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
SJSW is offline   Reply With Quote

Old   September 16, 2015, 03:30
Default
  #17
Senior Member
 
Join Date: Nov 2013
Posts: 863
Rep Power: 12
pakk will become famous soon enough
Quote:
Originally Posted by SJSW View Post
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.
pakk is offline   Reply With Quote

Old   September 16, 2015, 04:33
Default
  #18
Member
 
Join Date: Jun 2014
Location: Taiwan
Posts: 45
Rep Power: 3
SJSW is on a distinguished road
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 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.
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:
Originally Posted by pakk View Post
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
File Type: png Untitled123.png (11.3 KB, 6 views)
SJSW is offline   Reply With Quote

Old   September 16, 2015, 04:46
Default
  #19
Senior Member
 
Join Date: Nov 2013
Posts: 863
Rep Power: 12
pakk will become famous soon enough
Results->Reports->Surface Integrals->Set up

Report type: Area

Select your interface.

Click "compute".
pakk is offline   Reply With Quote

Old   September 16, 2015, 05:03
Default
  #20
Member
 
Join Date: Jun 2014
Location: Taiwan
Posts: 45
Rep Power: 3
SJSW is on a distinguished road
Thank you!

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

Quote:
Originally Posted by pakk View Post
Results->Reports->Surface Integrals->Set up

Report type: Area

Select your interface.

Click "compute".
SJSW 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
Face Area Corentin FLUENT 2 April 9, 2008 11:33
how to get cell face area in RADPRO.F cthsieh CD-adapco 1 January 2, 2007 09:53
how to get cell face area and U in registers chinayu CD-adapco 3 May 16, 2006 08:47
cell velocity U and its cell face area Chinayu CD-adapco 0 May 6, 2006 22:44
Face area gg FLUENT 0 June 30, 2003 04:18


All times are GMT -4. The time now is 19:08.