CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Calculating the centre of a surface (http://www.cfd-online.com/Forums/fluent-udf/108228-calculating-centre-surface.html)

victoryv October 17, 2012 12:11

Calculating the centre of a surface
 
I need to find centroid of multiple boundaries to implement in equation in UDF. I want Fluent to calculate the coordinates (x,z) of the centroid. I have written a code for area weighted centroid. I am getting an error. Can someone tell me what am I doing wrong?
( I think its with the A(). I need to calculate area in xz planes. Is it right?)

/* Calculating the centroid of the Boundary*/
begin_f_loop(f, thread)
{
F_CENTROID(p,f,thread);
F_AREA(A,f,thread);
a = (p[0]*A[1])+a;
b= (p[2]*A[1])+b;
}
end_f_loop(f, thread)

begin_f_loop(f, thread)
{
F_AREA(A,f,thread);
d = A[1] + d;
}
end_f_loop(f, thread)
k=a/d;l=b/d;

syavash October 17, 2012 19:27

Quote:

Originally Posted by victoryv (Post 387130)
I need to find centroid of multiple boundaries to implement in equation in UDF. I want Fluent to calculate the coordinates (x,z) of the centroid. I have written a code for area weighted centroid. I am getting an error. Can someone tell me what am I doing wrong?
( I think its with the A(). I need to calculate area in xz planes. Is it right?)

/* Calculating the centroid of the Boundary*/
begin_f_loop(f, thread)
{
F_CENTROID(p,f,thread);
F_AREA(A,f,thread);
a = (p[0]*A[1])+a;
b= (p[2]*A[1])+b;
}
end_f_loop(f, thread)

begin_f_loop(f, thread)
{
F_AREA(A,f,thread);
d = A[1] + d;
}
end_f_loop(f, thread)
k=a/d;l=b/d;

The problem is right here, if you want to access Area magnitude of a boundary face, you have to implement this macro:
area=NV_MAG(A);
instead of "A[1]"
Goodluck


All times are GMT -4. The time now is 03:55.