CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

Finding out boundary cells in a domain

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

Reply
 
LinkBack Thread Tools Display Modes
Old   October 9, 2003, 13:44
Default Finding out boundary cells in a domain
  #1
Abbas
Guest
 
Posts: n/a
I have a simple 2-D channel, and I want to manipulate the cells at channel boundary. I wrote a code for it, but it gives Segmentation Violation when I run it.

Please see if you can see what the problem is with this UDF:

---------------------------------------------

# include "udf.h"

DEFINE_ADJUST (macro_s,d) {

Thread *t, *tf, *tc1;

face_t f;

cell_t c;

cell_t c1;

int n,k;

thread_loop_c (t, d) /*loops over all cell threads in domain*/

{

begin_c_loop(c, t) /* loops over cells in a cell thread */

{

c_face_loop(c,t,n) /* loops over all faces on a cell */

{

f=C_FACE(c,t,n); /* returns the face f for the cell c and Thread t */

tf=C_FACE_THREAD(c,t,n); /* get cell ids c0 and c1 which are adjacent to this face f */

tc1=F_C1_THREAD(tf, t);

c1=F_C1(f,tf);

if (c1=NULL) ; /*Error occurs when cells are out of the boundary. Have to apply condition to the cell ADJACENT to it */

printf("%f, it's out\n", k);

k++;

}

}

end_c_loop(c, t)

}

}

---------------------------------------------

Thanks.
  Reply With Quote

Old   October 10, 2003, 04:38
Default Re: Finding out boundary cells in a domain
  #2
Andrew Garrard
Guest
 
Posts: n/a
OK, I think there are alot of problems with this code. It might be easier if you tell us exactly what you are trying to do and we could suggest a better code. One of the major problems, to my mind, is that you are defining several cell and face threads and not specifying what they are in your geometry. For example, you define a thread *t and then begin a cell loop without telling the code what the thread is. You need a line like:

Thread *t = Lookup_Thread(d, thread_ID);

Where thread_ID is the boundary ID taken from the fluent GUI. What is it that you want your code to do? All I can see is that you are printing the value of k, which is uninitialised anyway.
  Reply With Quote

Old   October 11, 2003, 02:18
Default Re: Finding out boundary cells in a domain
  #3
Abbas
Guest
 
Posts: n/a
Thanks Andrew. I'm sorry about the code. Actually, I've just started using Fluent UDFs and, as obvious, am not good at it.

I want to get the cells in contact with the upper wall, and define my own velocity for these cells, say, 10 m/s.

Here is how I tried to do it using another code. I use C_U(c,t) to define the x-velocity. Now it appears to be working fine.

Here is the code:

------ # include "udf.h"

DEFINE_ADJUST (macro_s2, domain)

{

cell_t c0; face_t face; Thread *thread;

int ID=5; /* Zone ID for wall from Boundary Conditions panel */

thread = Lookup_Thread(domain, ID);

begin_f_loop(face, thread) /* loops over faces in a face thread */

{

c0=F_C0(face, thread); /* F_C1 will be out of boundary */

C_U(c0, thread)=10;

printf("%f\n", C_U(c0, thread)); /* Looking at the velocity value. */

}

end_f_loop (face, thread)

}
  Reply With Quote

Old   October 12, 2003, 16:21
Default Re: Finding out boundary cells in a domain
  #4
Mazyar
Guest
 
Posts: n/a
Hi, I think another easy way for specifying a velocities to those cells is that you: 1) mark those cells in: adapt/boundary/...=> choose the cell row next to that boundary 2) separate them in: grid/separate/cell... 3)In boundary condition menu, specify mass and momentum source values according to the formula in manual.

another method is using a DEFINE_ADJUST function : 1) loop over the cells of the domain 2) get the center point of the cells using: C_CENTROID( ) 3)Using an IF statement: if(center of the cell is equal to location you want) then C_U(c,t)=10

Good luck
  Reply With Quote

Old   October 13, 2003, 04:56
Default Re: Finding out boundary cells in a domain
  #5
Andrew Garrard
Guest
 
Posts: n/a
That piece of code looks alot healthier, glad that it is working.
  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
Finding boundary cells stephan OpenFOAM Running, Solving & CFD 4 February 4, 2013 15:59
Import problem ARC Open Source Meshers: Gmsh, Netgen, CGNS, ... 0 February 27, 2010 11:56
increasing mesh quality is leading to poor convergence tippo CFX 2 May 5, 2009 10:55
help:uds source added to boundary cells FredPacheo FLUENT 5 September 5, 2008 05:45
Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 2 July 15, 2005 04:15


All times are GMT -4. The time now is 18:57.