CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   How to retrieve thread id by name (https://www.cfd-online.com/Forums/fluent/42388-how-retrieve-thread-id-name.html)

thomas September 26, 2006 03:46

How to retrieve thread id by name
 
hi guys, does anybody of you know a good method to retrieve the id of a thread (you know, those shown in the boundary conditions panel) if I only know the name of the thread (e.g. ground)? I have to implement a function like

int thread_id = getThreadIDByName("ground");

but I have absolutely no idea how to get the id of "ground" without taking a look into the boundary conditions panel and adjust the sources.

thanks for any help thomas


gernot lukesch September 26, 2006 04:46

Re: How to retrieve thread id by name
 
by typing :

surface list

into the tui you get all idīs to all names. hope that helps

thomas September 26, 2006 06:04

Re: How to retrieve thread id by name
 
definitely helps. but do you know a way to call this from within the source code (I was thinking about doing this via CX_Interpret_String(char *) ) so that you can access the output? I was thinking about writing a *.fluent file that starts a transscript and cutting out the needed information from the generated file, but I want everything to happen automatically when I load the case into fluent and still don't know how to realise this best...

gernot lukesch September 26, 2006 06:07

Re: How to retrieve thread id by name
 
sorry i canīt help you with that.

Highflower July 31, 2011 04:13

Hi Thomas!
Did you solve the problem of getting the thread ID from the name? I have exactly the same problem now...

Thanks in advance!

gearboy July 31, 2011 21:56

Quote:

Originally Posted by thomas
;135783
hi guys, does anybody of you know a good method to retrieve the id of a thread (you know, those shown in the boundary conditions panel) if I only know the name of the thread (e.g. ground)? I have to implement a function like

int thread_id = getThreadIDByName("ground");

but I have absolutely no idea how to get the id of "ground" without taking a look into the boundary conditions panel and adjust the sources.

thanks for any help thomas

For Serial solver and Fluent version before 12.1, you can use the following in you source code.

real ground_id;
CX_Interpret_String("(if(not(rp-var-object 'ground-id))(rp-var-define 'ground-id -1 'integer #f) ())");
CX_Interpret_String("(if (zone-name->id 'ground)(rpsetvar 'ground-id (zone-name->id 'ground))(rpsetvar 'ground-id -1))");
ground_id=RP_Get_Integer("ground-id");

Note: The above code doesn't work in parallel solver. You need to use auto-load scheme file.
For Fluent 12.1, you can loop over all the thread in you domain and use THREAD_NAME to judge whether the thread name is same as you specified. Then use THREAD_ID to get its id.

Highflower August 1, 2011 10:21

Quote:

Originally Posted by gearboy (Post 318224)
For Serial solver and Fluent version before 12.1, you can use the following in you source code.

real ground_id;
CX_Interpret_String("(if(not(rp-var-object 'ground-id))(rp-var-define 'ground-id -1 'integer #f) ())");
CX_Interpret_String("(if (zone-name->id 'ground)(rpsetvar 'ground-id (zone-name->id 'ground))(rpsetvar 'ground-id -1))");
ground_id=RP_Get_Integer("ground-id");

Note: The above code doesn't work in parallel solver. You need to use auto-load scheme file.
For Fluent 12.1, you can loop over all the thread in you domain and use THREAD_NAME to judge whether the thread name is same as you specified. Then use THREAD_ID to get its id.

Hi gearboy!
I use Fluent 13 in parallel, do you mean that I can use THREAD_NAME(t) instead of THREAD_ID(t) in my loop?
For example to access my cells in zone n:

thread_loop_c (t,domain)
{
if ( NULL != THREAD_STORAGE(t,SV_T_G) )
{
begin_c_loop (c,t)
{

if(THREAD_NAME(t) == "n")
{
}
}
end_c_loop (c,t)
}
}

It doesn't seems to work, maybe I misunderstood you...
Thanks for your help!

gearboy August 2, 2011 01:21

Quote:

Originally Posted by Highflower (Post 318332)
Hi gearboy!
I use Fluent 13 in parallel, do you mean that I can use THREAD_NAME(t) instead of THREAD_ID(t) in my loop?
For example to access my cells in zone n:

thread_loop_c (t,domain)
{
if ( NULL != THREAD_STORAGE(t,SV_T_G) )
{
begin_c_loop (c,t)
{

if(THREAD_NAME(t) == "n")
{
}
}
end_c_loop (c,t)
}
}

It doesn't seems to work, maybe I misunderstood you...
Thanks for your help!

Use STREQ to compare two strings, not "==".

visitor March 29, 2021 04:40

Interesting, a long way since this posting started. Now ANSYS 2021academic, just looking if any developments have occurred. Whether above code will work with parallel processing or not.

qin chunqiu December 20, 2021 03:36

Quote:

Originally Posted by gernot lukesch
;135784
by typing :

surface list

into the tui you get all idīs to all names. hope that helps

I get the surface list as following. But the IDs are not reasonable. Could you please share me what these IDs mean?
/surface> list-surfaces
surface group name id points 0D facets 1D facets 2D facets
------------------------- ---- --------- ---------- ----------- -----------
cylinder 0 0 0 0 0
inlet 2 0 0 0 0
int_fluid 3 0 0 0 0
outlet 1 0 0 0 0
x0 4 0 0 0 0

Total: 0 points, 0 facets.


All times are GMT -4. The time now is 09:53.