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

pointers and threads

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

Reply
 
LinkBack Thread Tools Display Modes
Old   March 15, 2004, 12:27
Default pointers and threads
  #1
Andrew Garrard
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.

  Reply With Quote

Old   March 15, 2004, 20:44
Default Re: pointers and threads
  #2
ap
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
  Reply With Quote

Old   March 16, 2004, 12:27
Default Re: pointers and threads
  #3
Andrew Garrard
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.
  Reply With Quote

Old   March 16, 2004, 12:57
Default Re: pointers and threads
  #4
ap
Guest
 
Posts: n/a
Oops...sorry for that mistake.

Hi

ap
  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
X-Momentum Source to water pahse in VOF srm206 FLUENT 7 June 22, 2011 20:31
separate cell threads via UDF pedro garcia FLUENT 0 September 19, 2006 06:36


All times are GMT -4. The time now is 22:38.