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 Tree5Likes
  • 1 Post By krish
  • 3 Post By e0125583
  • 1 Post By Bharadwaj B S

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: 5
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: 70
Rep Power: 2
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: 670
Rep Power: 9
pakk is on a distinguished road
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: 70
Rep Power: 2
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: 670
Rep Power: 9
pakk is on a distinguished road
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: 70
Rep Power: 2
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: 670
Rep Power: 9
pakk is on a distinguished road
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: 70
Rep Power: 2
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: 70
Rep Power: 2
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: 2
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: 70
Rep Power: 2
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: 2
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

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 05:07.