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

How to retrieve thread id by name

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

Reply
 
LinkBack Thread Tools Display Modes
Old   September 26, 2006, 03:46
Default How to retrieve thread id by name
  #1
thomas
Guest
 
Posts: n/a
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

  Reply With Quote

Old   September 26, 2006, 04:46
Default Re: How to retrieve thread id by name
  #2
gernot lukesch
Guest
 
Posts: n/a
by typing :

surface list

into the tui you get all id´s to all names. hope that helps
  Reply With Quote

Old   September 26, 2006, 06:04
Default Re: How to retrieve thread id by name
  #3
thomas
Guest
 
Posts: n/a
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...
  Reply With Quote

Old   September 26, 2006, 06:07
Default Re: How to retrieve thread id by name
  #4
gernot lukesch
Guest
 
Posts: n/a
sorry i can´t help you with that.
  Reply With Quote

Old   July 31, 2011, 04:13
Default
  #5
New Member
 
Olle Högblom
Join Date: Jan 2011
Posts: 2
Rep Power: 0
Highflower is on a distinguished road
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!
Highflower is offline   Reply With Quote

Old   July 31, 2011, 21:56
Default
  #6
Senior Member
 
Ji Junjie
Join Date: Feb 2010
Location: Shanghai, China
Posts: 106
Rep Power: 7
gearboy is on a distinguished road
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.
gearboy is offline   Reply With Quote

Old   August 1, 2011, 10:21
Default
  #7
New Member
 
Olle Högblom
Join Date: Jan 2011
Posts: 2
Rep Power: 0
Highflower is on a distinguished road
Quote:
Originally Posted by gearboy View Post
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!
Highflower is offline   Reply With Quote

Old   August 2, 2011, 01:21
Default
  #8
Senior Member
 
Ji Junjie
Join Date: Feb 2010
Location: Shanghai, China
Posts: 106
Rep Power: 7
gearboy is on a distinguished road
Quote:
Originally Posted by Highflower View Post
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 "==".
gearboy is offline   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
Guide: Getting Started with the CFD Online Discussion Forums pete Site Help, Feedback & Discussions 6 July 20, 2015 07:20
udf problem jane Fluent UDF and Scheme Programming 11 December 4, 2012 04:09
Please check out my parallelized udf code aleisia Fluent UDF and Scheme Programming 0 June 10, 2011 16:16
Parallelizing UDF Hattori Hanzo Fluent UDF and Scheme Programming 4 July 17, 2010 14:26
Phase locked average in run time panara OpenFOAM 2 February 20, 2008 15:37


All times are GMT -4. The time now is 11:59.