|
[Sponsors] |
April 16, 2002, 22:48 |
Problem with UDF
|
#1 |
Guest
Posts: n/a
|
Hi,
I am trying to access the data of neighbhouring cells from a cell. I am looping through all the cells in the domain. Inside this loop, I am looping through all the faces of a cell(say x). From the face of the cell x, I am getting the id and thread of the cells to which this face forms the boundary. Now I will have two cell ids c0 and c1. One of these cells is the original cell x. To determine which one is the original cell x, I am using the C_CENTROID macros. I was able to compile the following code. But when I run it, I get a segementation violation. And I found out that this error occurs when I try to find the centroid of cell c1. I am confused since I am not trying to access any undefined variable. If anybody could point out any bug in the code, I will be thankful. DEFINE_ADJUST(filter, d) { Thread *t,*tf,*tc0,*tc1; cell_t c,c0,c1; face_t f; float xcell[3],xcellc0[3],xcellc1[3]; thread_loop_c (t,d) { begin_c_loop (c,t) C_CENTROID(xcell,c,t); c_face_loop(c,t,n) /* loops over all faces on a cell */ { f = C_FACE(c,t,n); tf = C_FACE_THREAD(c,t,n); /* get cell ids c0 and c1 which are adjacent to this face f */ c0 = F_C0(f,tf); tc0 = THREAD_T0(tf); c1 = F_C1(f,tf); tc1 = THREAD_T1(tf); if ((c0!=c)&&(c1==c)) { C_CENTROID(xcellc0,c0,tc0); } else if ((c0==c)&&(c1!=c)) { C_CENTROID(xcellc1,c1,tc1); } } end_c_loop (c,t) } } Thank you senthil |
|
April 17, 2002, 23:39 |
Can you tell me the name of your project??
|
#2 |
Guest
Posts: n/a
|
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN' >
<html> <head> <title>My Web Site Title</title> </head> <meta name="Description" content="A Short but sharp description of website or web page for search engines"> <meta name="Keywords" content="A list of keywords users may type in a search engine to find website or page"> <meta name="Generator" content="WebSoftware HotHTML 2001 Professional Edition"> <body bgcolor="#FFFFFF" text="#000000" link="#804040" vlink="#008080" alink="#004080"> Suppose I've understood your code ...(There are some syntax errors in your code ...) try the following: #include "udf.h" #define C_NFACES(c,t)(cell_type_nfaces[(int)(C_TYPE((c),(t)))]) DEFINE_ADJUST(filter, d) { Thread *t,*tf,*tc0,*tc1; cell_t c,c0,c1; face_t f; float xcell[3],xcellc0[3],xcellc1[3]; int n; thread_loop_c (t,d) { begin_c_loop (c,t) { C_CENTROID(xcell,c,t); c_face_loop(c,t,n){ f = C_FACE(c,t,n); tf = C_FACE_THREAD(c,t,n); c0 = F_C0(f,tf); tc0 = THREAD_T0(tf); c1 = F_C1(f,tf); tc1 = THREAD_T1(tf); if ((c0!=c)&&(c1==c)<font color="FF0000"> &&tc0!=NULL</font> ) C_CENTROID(xcellc0,c0,tc0); /* Make sure the cell exists */ if ((c0==c)&&(c1!=c)<font color="FF0000"> &&tc1!=NULL</font> ) C_CENTROID(xcellc1,c1,tc1); /* Error occurs when cells are out of the boundary */ } }end_c_loop (c,t); } } <font color="0010FF">Johnix </body> </html> |
|
April 18, 2002, 00:08 |
Re: Problem with UDF
|
#3 |
Guest
Posts: n/a
|
You will need to check the type of the face thread, since faces on the boundary only have one adjacent cell - c0.
Look at the fluent 6 udf manual for this or see previous posts - I think I've put this up before. Greg |
|
April 18, 2002, 22:11 |
Re: Problem with UDF
|
#4 |
Guest
Posts: n/a
|
Thanks Johnix and Greg. I could not find the previous post. But I assume that tc1=null if the face is near a wall, as Johnix pointed out. I am trying to find out the second and fourth derivatives of flow variables. That is why I need to be able to access the adjacent cells. Let me know if there is any easier way of calculating derivatives except using user defined scalars.
I have one more question. What happens when we have a periodic boundary condition at a face. Will both c0 and c1 exist or only c0 exists as in wall boundary. What exactly is a cell identifier,i.e cell macro and thread variable. Fluent UDF manual does not say much about them except how to use them. Thanks Senthil |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM | Rizwan | Fluent UDF and Scheme Programming | 40 | March 18, 2018 06:05 |
Problem with my udf | july | Fluent UDF and Scheme Programming | 3 | June 20, 2010 06:56 |
UDF problem | mansha goraya | FLUENT | 0 | October 29, 2007 00:31 |
udf compiling problem | akr | FLUENT | 3 | August 22, 2007 07:14 |
UDF problem | chiseung | FLUENT | 4 | January 10, 2002 09:58 |