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

code for locating cell faces in domain isn't working as intended

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 16, 2015, 17:51
Default code for locating cell faces in domain isn't working as intended
  #1
New Member
 
Join Date: Apr 2015
Posts: 7
Rep Power: 11
malicemethods is on a distinguished road
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 is offline   Reply With Quote

Old   June 16, 2015, 18:05
Default
  #2
New Member
 
Join Date: Apr 2015
Posts: 7
Rep Power: 11
malicemethods is on a distinguished road
Quote:
Originally Posted by malicemethods View Post
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!
malicemethods is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Foam::error::PrintStack almir OpenFOAM Running, Solving & CFD 91 December 21, 2022 04:50
[snappyHexMesh] Add Mesh Layers doesnt work on the whole surface Kryo OpenFOAM Meshing & Mesh Conversion 13 February 17, 2022 07:34
[Other] refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 2 November 11, 2021 11:04
injection problem Mark New FLUENT 0 August 4, 2013 01:30
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 15:56


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