CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   pointers and threads (https://www.cfd-online.com/Forums/fluent/33245-pointers-threads.html)

Andrew Garrard March 15, 2004 13:27

pointers and threads
 
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.


ap March 15, 2004 21:44

Re: pointers and threads
 
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

Andrew Garrard March 16, 2004 13:27

Re: pointers and threads
 
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.

ap March 16, 2004 13:57

Re: pointers and threads
 
Oops...sorry for that mistake.

Hi :)

ap


All times are GMT -4. The time now is 08:00.