|
[Sponsors] |
March 15, 2004, 13:27 |
pointers and threads
|
#1 |
Guest
Posts: n/a
|
Hello all. I am trying to create a function within a UDF. I have used pointers before to identify threads - e.g. Thread *thread = Lookup_Thread(domain, ID);, bt never really understood how they work in fluent. I wish to pass the thread to a function outside the DEFINE macro, how should I do this? should I pass the variable thread, or *thread? Also, if I wish to compare the thread being passed to a know ID, how can I do this. Essentially, if I know the name of the thread, can i retrive the ID? If I have not expalined this very well, I am sorry. I will put an example of what I am trying to achieve below:
real function(f, thread) { Thread *thread_1 = Lookup_Thread(dom, ID_1) If (thread = thread_1){return 10); else {return 20); } DEFINE_PROFILE(name, thread, index) face_t f; begin_f_loop(f, thread) { F_PROIFLE(f, thread, i) = function(f, thread) } end_f_loop(f, thread) Thanks in advance for any help. |
|
March 15, 2004, 21:44 |
Re: pointers and threads
|
#2 |
Guest
Posts: n/a
|
All FLUENT macros want a Thread pointer as argument. So when you write
C_T(cell, thread); you have: cell_t cell; Thread *thread; So, I think you should write your function like follows : real function(face_t f, Thread *thread) /* I changed this line */ { Thread *thread_1 = Lookup_Thread(dom, ID_1); if (thread = thread_1) { return 10; } else { return 20; } } I didn't try to compile the code...hope it works. Hi ap |
|
March 16, 2004, 13:27 |
Re: pointers and threads
|
#3 |
Guest
Posts: n/a
|
Thanks, I didn't actually think that it would work from my previous experince of doing this sort of thing, but it did perfectly. Of course, you should use if(thread == thread_1), as this is a mistake I have made too often to ignore.
|
|
March 16, 2004, 13:57 |
Re: pointers and threads
|
#4 |
Guest
Posts: n/a
|
Oops...sorry for that mistake.
Hi ap |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
X-Momentum Source to water pahse in VOF | srm206 | FLUENT | 7 | June 22, 2011 21:31 |
separate cell threads via UDF | pedro garcia | FLUENT | 0 | September 19, 2006 07:36 |