CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   code for locating cell faces in domain isn't working as intended (https://www.cfd-online.com/Forums/fluent-udf/154545-code-locating-cell-faces-domain-isnt-working-intended.html)

malicemethods June 16, 2015 17:51

code for locating cell faces in domain isn't working as intended
 
My geometry is rod with radius 0.3m and a concentric cylinder with radius 1.5m. The right face of the geometry serves as the window for radiation input. I've split faces on the window (which consists of the two faces, the rod and the cylinder face) and now I am trying to locate all the split faces. The code I've written only locates faces from 0 to 0.3m. I am using the thread_loop_f function so it should locate ALL the faces in the domain, but it doesnt. I am trying to locate all split faces located at z=0, Can someone help me? Thank you in advance.


#include "udf.h"


DEFINE_ON_DEMAND(count_window)
{
FILE *win_data;

real face_c[3];
real face_a[3];
real r;
real crit;


Domain *d;
cell_t c;
Thread *t;
face_t f;
int ID;


crit = 1.5;
win_data = fopen("window_data.txt","w");

d=Get_Domain(1);
printf("Locating window faces...\n");
thread_loop_f(t,d){
F_CENTROID(face_c,f,t);
F_AREA(face_a,f,t);
ID = THREAD_ID(t);
r = sqrt(face_c[0]*face_c[0]+face_c[1]*face_c[1]+face_c[2]*face_c[2]);
if(r<=crit && face_c[2]==0){
fprintf(win_data,"%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%. 3e\t%d\n",face_c[0],face_c[1],face_c[2],face_a[0],face_a[1],face_a[2],ID);
}
}



printf("done.\n");


fclose(win_data);


}

malicemethods June 16, 2015 18:05

Quote:

Originally Posted by malicemethods (Post 550658)
My geometry is rod with radius 0.3m and a concentric cylinder with radius 1.5m. The right face of the geometry serves as the window for radiation input. I've split faces on the window (which consists of the two faces, the rod and the cylinder face) and now I am trying to locate all the split faces. The code I've written only locates faces from 0 to 0.3m. I am using the thread_loop_f function so it should locate ALL the faces in the domain, but it doesnt. I am trying to locate all split faces located at z=0, Can someone help me? Thank you in advance.


#include "udf.h"


DEFINE_ON_DEMAND(count_window)
{
FILE *win_data;

real face_c[3];
real face_a[3];
real r;
real crit;


Domain *d;
cell_t c;
Thread *t;
face_t f;
int ID;


crit = 1.5;
win_data = fopen("window_data.txt","w");

d=Get_Domain(1);
printf("Locating window faces...\n");
thread_loop_f(t,d){
F_CENTROID(face_c,f,t);
F_AREA(face_a,f,t);
ID = THREAD_ID(t);
r = sqrt(face_c[0]*face_c[0]+face_c[1]*face_c[1]+face_c[2]*face_c[2]);
if(r<=crit && face_c[2]==0){
fprintf(win_data,"%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%. 3e\t%d\n",face_c[0],face_c[1],face_c[2],face_a[0],face_a[1],face_a[2],ID);
}
}



printf("done.\n");


fclose(win_data);


}


I figured out the answer.. There wasn't anything wrong with the thread_loop_f function. The code wrote all faces at z=0. However the faces I was looking for were at z=-3.44e-17. So I rewrote the bounds

crit = -4e-17;
if(face_c[2]>=crit && face_c[2]<=0)

Thanks for the help. This forum is great!


All times are GMT -4. The time now is 15:10.