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

C_FACE(c,t,i) local face index i ?????????

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By sbaffini
  • 1 Post By sbaffini

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 18, 2012, 04:52
Default C_FACE(c,t,i) local face index i ?????????
  #1
New Member
 
Jacky
Join Date: Jul 2011
Posts: 24
Rep Power: 15
bharat.cmeri is on a distinguished road
Hi everyone....... can u pls tell me how would i know whether a face is top,bottom, right or left of a cell using this local face index ??

Regards,
Bharat
bharat.cmeri is offline   Reply With Quote

Old   April 19, 2012, 10:29
Default
  #2
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
You can't because, in general, there is no such information in the cell of an unstructured solver (like Fluent), which can also be a tetrahedron (nonetheless, the information on the cell type is written in the case file). Still, if you define your own directions in space you can still check how the face centroid-cell centroid vector is oriented with respect to them and make your conclusions.
sbaffini is offline   Reply With Quote

Old   April 20, 2012, 02:15
Default
  #3
New Member
 
Jacky
Join Date: Jul 2011
Posts: 24
Rep Power: 15
bharat.cmeri is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
You can't because, in general, there is no such information in the cell of an unstructured solver (like Fluent), which can also be a tetrahedron (nonetheless, the information on the cell type is written in the case file). Still, if you define your own directions in space you can still check how the face centroid-cell centroid vector is oriented with respect to them and make your conclusions.
Thanks for replying...... I think I found d way out....... Below is what i hv done.... I hvnt ran it yet bt pls go thru it.........

V[0] = C_U(c,t);
V[1] = C_V(c,t);
mag = NV_MAG(V);
NV_D(xunit, = ,1,0,0);
NV_D(yunit, = ,0,1,0);

c_face_loop(c, t, n)
{
F_AREA(A, f,t);
C_CENTROID(dr0, F_C0(f,t),t->t0);
F_CENTROID(xf, f,t);
NV_VV(dr0, =, xf,-,dr0);
ds = NV_MAG(dr0);
NV_VS(es,=,dr0,/,ds);

XDOT = NV_DOT(es,xunit);
YDOT = NV_DOT(es,yunit);

if (XDOT <= 1.0 && XDOT > cos(15.0))
{
front = n;
}
else if( XDOT < -cos(15.0) && XDOT >= -1.0)
{
back = n;
}
else if( YDOT <= 1.0 && YDOT > cos(15.0))
{
top = n;
}
else if( YDOT < -cos(15.0) && YDOT >= -1.0)
{
bottom = n;
}

}
bharat.cmeri is offline   Reply With Quote

Old   April 21, 2012, 07:46
Default
  #4
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Besides your choice of conditions to check (which i admit, now at first i don't get) you got the main point.

Just notice that:

- you may not need mag and A(F_AREA)

- i'm not very practical with the pointer stuff but, at first it seems that with C_CENTROID(dr0, F_C0(f,t),t->t0) you are picking up the centroid of c0 (correct me if i'm wrong as i'm interested in this). In this case you you should be aware that c0 may not correspond to c (whose faces you are looping) but to the neighbor cell trough the face. However, i don't see where you are picking up f (which still can be my foult, so correct me if i'm wrong). I usually do it by something like:

f = C_FACE(cn,tn,nf);
tf = C_FACE_THREAD(cn,tn,nf);
c0 = F_C0(f,tf);
t0 = THREAD_T0(tf);
sbaffini is offline   Reply With Quote

Old   April 23, 2012, 11:35
Default
  #5
New Member
 
Jacky
Join Date: Jul 2011
Posts: 24
Rep Power: 15
bharat.cmeri is on a distinguished road
f is being picked just before c_face_loop.
well as far as I know c0 means the parent cell where from f is being tracked(which is c). so basically c will be c0.

Now let me ask one question. can't we use these loops inside our own functions like say
static real
LINSEG(cell_t c, Thread *t)
{
----------loop-----------
}

I am having trouble as solver is giving MPI error.....viz... no such file or directory exists..... I am not able to make out how to do it. If you pls tell me........


And yes mag and AREA are not needed.........
Thanks & Regards,
Bharat....
bharat.cmeri is offline   Reply With Quote

Old   April 23, 2012, 17:13
Default
  #6
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Dear bharat,

according to my knowledge of UDFs, what you are doing is not exactly correct, that is:

- f can't be picked up before the cell face loop because it is changing inside the loop. In practice, with F_CENTROID(xf, f,t) you are asking the centroid (which is put in xf) of the face f belonging to the face thread t (which, by the way are already used by the main c_face_loop and this is wrong), but for each face of the cell you can have a different face thread and face index, hence you need to ask for them just after the beginning of the c_face_loop.

- what you actually know about c0 and c1 is that the vector A is pointing from c0 toward c1 (on the boundaries, where c1 is missing, it is just pointing outside). There is no way to know in advance if the cell you are looping over is c0 or c1, except for boundaries where the ambiguity is resolved by c1 missing


As long as you pass your function all the arguments in the correct form there should be no issues in using loop or what else kind of Fluent internal macros in a separate function. However, i have to say it, i never did it and can't be of much help on this. I definitely suggest you to first debug your UDF in serial before going to parallel (where MPI errors are supposed to belong)
sbaffini is offline   Reply With Quote

Old   August 14, 2012, 11:27
Default local face index
  #7
New Member
 
Bruce
Join Date: Mar 2012
Posts: 8
Rep Power: 14
XJTH is on a distinguished road
f = C_FACE(cn,tn,nf);
tf = C_FACE_THREAD(cn,tn,nf);
c0 = F_C0(f,tf);
t0 = THREAD_T0(tf);[/QUOTE]


nf is the local face index number, could u tell me it's meaning? and the return global face index face_t f .

ths

XJTH
XJTH is offline   Reply With Quote

Old   August 14, 2012, 12:00
Default
  #8
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
The meaning of the four lines above is:

- "f = C_FACE(cn,tn,nf);" = for a given cell cn belonging to the cell_thread tn, give me the global face index f corresponding to the local face index nf. It is assumed that the above statement is inside a cell_face loop "c_face_loop(cn, tn, nf)", a loop over the faces of the cell cn.

- "tf = C_FACE_THREAD(cn,tn,nf);" = as above, but now the request is for the face_thread tf containing the face f from above.

- "c0 = F_C0(f,tf);" given f and tf from above, this command asks for the so called cell c0 index. I described it in previous posts above; it is just one of at most two cells sharing the face f. Among the two (c0 and c1), c0 is the one which is always present.

- "t0 = THREAD_T0(tf);" this is just the cell_thread of the cell c0 above. Notice that, as the only input required is tf, all the faces on tf will have their c0 belonging to the same cell_thread t0.

Hope this is what you are looking for
XJTH likes this.
sbaffini is offline   Reply With Quote

Old   April 3, 2024, 13:12
Default
  #9
New Member
 
Diogo Martinho
Join Date: Sep 2022
Posts: 7
Rep Power: 4
diogoloureiromartinho is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
The meaning of the four lines above is:

- "f = C_FACE(cn,tn,nf);" = for a given cell cn belonging to the cell_thread tn, give me the global face index f corresponding to the local face index nf. It is assumed that the above statement is inside a cell_face loop "c_face_loop(cn, tn, nf)", a loop over the faces of the cell cn.

- "tf = C_FACE_THREAD(cn,tn,nf);" = as above, but now the request is for the face_thread tf containing the face f from above.

- "c0 = F_C0(f,tf);" given f and tf from above, this command asks for the so called cell c0 index. I described it in previous posts above; it is just one of at most two cells sharing the face f. Among the two (c0 and c1), c0 is the one which is always present.

- "t0 = THREAD_T0(tf);" this is just the cell_thread of the cell c0 above. Notice that, as the only input required is tf, all the faces on tf will have their c0 belonging to the same cell_thread t0.

Hope this is what you are looking for
Hi sbaffini,

I am not entirely sure if I understand this part.
When looking at fluent UDF manual they have written this
"
cell_t c;
Thread *t;
face_t f;
Thread *tf;
int n;
c_face_loop(c, t, n) /* loops over all faces of a cell */
{
.
.
.
f = C_FACE(c,t,n);
tf = C_FACE_THREAD(c,t,n);
.
.
.
}
"
What I dont really know is the meaning of the index n, in your answer "nf". If I use c_face_loop inside a define_adjust, how do I get n?
diogoloureiromartinho is offline   Reply With Quote

Old   April 3, 2024, 13:43
Default
  #10
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Quote:
Originally Posted by diogoloureiromartinho View Post
Hi sbaffini,

I am not entirely sure if I understand this part.
When looking at fluent UDF manual they have written this
"
cell_t c;
Thread *t;
face_t f;
Thread *tf;
int n;
c_face_loop(c, t, n) /* loops over all faces of a cell */
{
.
.
.
f = C_FACE(c,t,n);
tf = C_FACE_THREAD(c,t,n);
.
.
.
}
"
What I dont really know is the meaning of the index n, in your answer "nf". If I use c_face_loop inside a define_adjust, how do I get n?
Back then "n" (nf) was provided by the c_face_loop itself; it is just the local face index. I haven't done this in a decade, but n should vary from 0 to N-1, where N is the number of faces for a cell (6 for hexaedra, 4 for tetrahedra, etc.). C_FACE then converts that index into the actual address of the face (where you can actually find its data).

However, I really haven't coded UDFs seriously in a decade and I'm not aware of any possible modifications that might have intervened in the meanwhile, so you really need to refer to the manual of the FLuent version you are using in order to confirm this. Maybe, it would be nice if you could later confirm this here (not for me, but for anyone coming here in the future).

However, the example you report seems to fit my memories. Note that you don't need to use n, like at all. You need f and tf, which get n as input to return you the actual addresses of the face data.
sbaffini is offline   Reply With Quote

Old   April 4, 2024, 08:02
Default
  #11
New Member
 
Diogo Martinho
Join Date: Sep 2022
Posts: 7
Rep Power: 4
diogoloureiromartinho is on a distinguished road
The reason I asked this is because I am facing a problem when I calculate the gradient of a scalar.

I defined a UDS in some regions of my domain, and when I look at the boundary cells between the domain where this uds is solved and the other where it is not solved, the first layer of cells (on the domain where the UDS is solved) take wrong values. I was considering to somehow check if it was a boudnary cell and if so, to fix the value.

However, I am not really sure how to do this.
Do you have any ideas on this?

Thanks for your previous answer!!
diogoloureiromartinho is offline   Reply With Quote

Old   April 4, 2024, 09:00
Default
  #12
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Are you referring to how Fluent computes the gradients itself for UDS or to some procedure developed by you?

I can't give any hint for why Fluent would fail, except making a few considerations. Using an UDS only in certain zones require to set a bc on the boundaries between the solved and non solved zone. Maybe you are not using a correct bc? I never noticed if Fluent computes UDS gradients correctly or not.

If, instead, you are writing your own routine to compute uds gradients, which I have done (udm actually), I would first like to ask why, have you considered having them computed by Fluent? Because there are a lot of things to consider here, including parallel scenarios, and this requires a full understanding of how Fluent internally works and a full knowledge of the Fluent UDF manual.
sbaffini is offline   Reply With Quote

Reply


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
[Netgen] Import netgen mesh to OpenFOAM hsieh OpenFOAM Meshing & Mesh Conversion 32 September 13, 2011 06:50
[blockMesh] BlockMeshmergePatchPairs hjasak OpenFOAM Meshing & Mesh Conversion 11 August 15, 2008 08:36
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 15:00
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 19:07


All times are GMT -4. The time now is 12:19.