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

How to retrieve thread id by name

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By gernot lukesch

Reply
 
LinkBack Thread Tools Search this Thread 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
PanPeter likes this.
  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: 5
Rep Power: 15
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
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
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: 5
Rep Power: 15
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
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
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

Old   March 29, 2021, 04:40
Default
  #9
Senior Member
 
AH
Join Date: Apr 2014
Posts: 282
Rep Power: 13
visitor is on a distinguished road
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.
visitor is offline   Reply With Quote

Old   December 20, 2021, 03:36
Default
  #10
New Member
 
Join Date: Sep 2010
Location: Wuhan, China
Posts: 23
Rep Power: 15
qin chunqiu is on a distinguished road
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.
qin chunqiu 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
udf problem jane Fluent UDF and Scheme Programming 37 February 20, 2018 04:17
Guide: Getting Started with the CFD Online Discussion Forums pete Site Help, Feedback & Discussions 8 July 29, 2016 05:00
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 14:37


All times are GMT -4. The time now is 17:13.