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

Problem with looping over faces in cell, c_face_loop, two phases

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 8, 2015, 23:53
Default Problem with looping over faces in cell, c_face_loop, two phases
  #1
Member
 
Join Date: Dec 2014
Posts: 38
Rep Power: 11
Harry321 is on a distinguished road
Dear colleagues,

I have a problem with looping inside c_face_loop(c, t, i). At the beginning I should mention that I am working with two phases and the source is attached to the second phase.

I wrote simple UDF to find out where is a problem:
DEFINE_SOURCE(source, c, t, dS, eqn)
{
int i;
real a = 0;
real b = 0, cc = 0, d = 0, ee = 0, ff = 0, gg = 0;
face_t f;
Thread *t112;
c_face_loop(c, t, i)
{

f = C_FACE(c, t, i);
t112 = C_FACE_THREAD(c, t, i);
if (THREAD_TYPE(t112) != THREAD_F_WALL);
{
Message("ThreadID t112: %d\n", THREAD_ID(t112));
Message("F_W: %f\n", F_W(f, t));
}
}

dS[eqn] = cc-d;
return a -b;
}

And I have checked several cases and non of them seems to work good:

1) first case: Message("F_W: %f\n", F_W(f, t));
I run this UDF and I got several messages on the screen which shows values of F_W and after the while after fluent showed ID of a thread I got Segmentation fault.

2) second case: Message("F_W: %f\n", F_W(f, t112));

but in that case I got Segmentation fault after showing first ID.

3) third case: I added some more code befor If statement:
t11 = THREAD_SUB_THREADS(t112);
t12 = t11[0];
t13 = t11[1];
t14 = t11[2];
now Message is:
Message("F_W: %f\n", F_W(f, t13));
the same result as in case 2)

In this all cases ID of a t112 is interior so I am not a boundary.

Does anybody know how to fix this UDF? or maybe it is limitation of this macro and I cannot access face values using this one.
Harry321 is offline   Reply With Quote

Old   February 9, 2015, 00:38
Default
  #2
Member
 
Join Date: Dec 2014
Posts: 38
Rep Power: 11
Harry321 is on a distinguished road
I added also:



DEFINE_SOURCE(source, c, t, dS, eqn)
{
int i;
real a = 0;
real b = 0, cc = 0, d = 0, ee = 0, ff = 0, gg = 0;
face_t f;
Thread *t112;
Domain *superdomain= Get_Domain(1);
Domain *subdomain = DOMAIN_SUB_DOMAIN(superdomain, 1);
Thread *tm = THREAD_SUPER_THREAD(t);
c_face_loop(c, tm, i)
{
f = C_FACE(c, tm, i);
t112 = C_FACE_THREAD(c, tm, i);
Thread *t13 = Lookup_Thread(subdomain, THREAD_ID(t112));
if (THREAD_TYPE(t112) != THREAD_F_WALL);
{
Message("ThreadID t112: %d\n", THREAD_ID(t112));
Message("F_W: %f\n", F_W(f, t));
}
}
dS[eqn] = cc-d;
return a -b;

}



I run out of ideas what can I do :/
Harry321 is offline   Reply With Quote

Old   February 9, 2015, 05:12
Default
  #3
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 12
upeksa is on a distinguished road
Is your case 2D or 3D?
upeksa is offline   Reply With Quote

Old   February 9, 2015, 09:10
Default
  #4
Member
 
Join Date: Dec 2014
Posts: 38
Rep Power: 11
Harry321 is on a distinguished road
The case is 3 D
Harry321 is offline   Reply With Quote

Old   February 9, 2015, 10:21
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Try what this (added Message) does in your code:
Code:
...
t112 = C_FACE_THREAD(c, tm, i);
Message("Type:%d\n",THREAD_TYPE(t112));
Thread *t13 = Lookup_Thread(subdomain, THREAD_ID(t112));
if (THREAD_TYPE(t112) != THREAD_F_WALL);
...
Check the last type printed before you get an error.
You now exclude types of THREAD_F_WALL, but maybe you should have exclude more thread types.
pakk is offline   Reply With Quote

Old   February 9, 2015, 10:35
Default
  #6
Member
 
Join Date: Dec 2014
Posts: 38
Rep Power: 11
Harry321 is on a distinguished road
Hi,
thank both of you for help.

Message("ThreadID t112: %d\n", THREAD_ID(t112));

This line shows me the ID of a thread appropriate for a face. It shows ID of a interior side so I am not at the any kind of BC.
I tested sever cases (including alocation of a second phase velocity in face UDS) when I try to retrieve UDS values for in c_face_loop(c, tm, i) {} in DEFINE_SOURCE by using Message("F_U: %f\n", F_UDSI(f, t13, 5)); where
Domain *superdomain = Get_Domain(1);
Domain *subdomain = DOMAIN_SUB_DOMAIN(superdomain, 1);
f = C_FACE(c, tm, i);
t112 = C_FACE_THREAD(c, tm, i);
t13 = Lookup_Thread(subdomain, THREAD_ID(t112));

I don't have a problem with cell values for two phases but it seems that FLUENT has some issues with this specific loop and especially with face values for phases.
Harry321 is offline   Reply With Quote

Old   February 9, 2015, 20:56
Default
  #7
Member
 
Join Date: Dec 2014
Posts: 38
Rep Power: 11
Harry321 is on a distinguished road
The answer to this problem is very simple. Fluent doesn't store face velocity at the interior only at the boundaries.
Harry321 is offline   Reply With Quote

Reply

Tags
c_face_loop, looping over cells


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
[Other] Mesh Importing Problem cuteapathy ANSYS Meshing & Geometry 2 June 24, 2017 05:29
Problem with looping over faces in certain cell Harry321 Fluent UDF and Scheme Programming 1 January 9, 2015 21:57
foam-extend_3.1 decompose and pyfoam warning shipman OpenFOAM 3 July 24, 2014 08:14
Cells with t below lower limit Purushothama Siemens 2 May 31, 2010 21:58
Looping over faces in a cell Senthil FLUENT 3 April 11, 2002 11:41


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