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

Help Parallelizing UDF - THREAD_STORE

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 20, 2006, 11:35
Default Help Parallelizing UDF - THREAD_STORE
  #1
Mario Santillo
Guest
 
Posts: n/a
I am trying to get this UDF to compile (correctly) after parallelizing and I'm not having much luck. Any help is appreciated.

I am using the DEFINE_PROFILE function to set a wall BC (velocity inlet). Everything works perfectly fine in serial mode, but it does not work correctly in parallel mode. In serial mode, if I set the BC to some value using the F_PROFILE function and use a velocity sensor (C_U,V,W) to record the velocity in a cell close to the wall, the results seem to correlate well, but if I do the exact same thing in parallel mode, the velocity sensor reads ~0m/s.

One thing I thought was odd was that the HOST process is not being called in the DEFINE_PROFILE function at all. I am using 2 NODES (to debug for now), and those are the only processes which run through this function. That aside, the real issue is getting F_PROFILE to work right in parallel. I've tried using if(PRINCIPAL_FACE_P), but upon adding this I get a compiler error - THREAD_STORE: undeclared variable. I'm not sure how to interpret this.....Even if I try to isolate one of the NODES to update the BC using F_PROFILE, the velocity sensor still reads ~0m/s. Anyone have suggestions? Code is shown below (I realize it is a bit hokey, because NODE 0 is writing the datafile, but this is all I could do since the HOST does not seem to run this function.....):

DEFINE_PROFILE(dist_source, t, i) { #if !RP_HOST

face_t f; #endif

real source;

real velmag = 0;

real time = CURRENT_TIME;

FILE* fp1;

int m;

real pi = 3.1415926;

fp1 = fopen("dist.txt","a+");

velmag = 1.5*sin(2.5*2.0*pi*time);

source = velmag;

host_to_node_real_1(source); #if RP_NODE

if(I_AM_NODE_ZERO_P) #endif

{

if(ash2!=time)

{

fprintf(fp1,"%f\n",source);

ash2 = time;

}

fclose(fp1);

} #if !RP_HOST

//update disturbance jet face

begin_f_loop(f,t)

if(PRINCIPAL_FACE_P(f,t)) //Adding this line gives me an error upon compilation for parallel mode

{

F_PROFILE(f,t,i) = source;

}

end_f_loop(f,t) #endif }

  Reply With Quote

Old   June 20, 2006, 17:38
Default Re: Help Parallelizing UDF - THREAD_STORE
  #2
vivek
Guest
 
Posts: n/a
I have used DEFINE_PROFILE in parallel before and it worked fine. I am not exactly sure of the problem you are facing but you could try this and see if it helps.

You have a compiler Directive #if !RP_HOST before the declaration is done. In C language all the declaration should always be in the first block of the function. So you could try deleting the directive. I dont see any necessity for the statement since you are not going use the face_t variable in the host anyway.
  Reply With Quote

Old   June 20, 2006, 18:54
Default Re: Help Parallelizing UDF - THREAD_STORE
  #3
Mario Santillo
Guest
 
Posts: n/a
Thanks for the help. I already tried removing the directive, but it makes no difference. Simplifying matters, I can reduce the code down to this (removing file I/O and injecting a constant instead of a sinusoid - rather trivial):

DEFINE_PROFILE(dist_source,t,i) { face_t f; real source = 2.0;

begin_f_loop(f,t) {

F_PROFILE(f,t,i) = source; } end_f_loop(f,t) }

Even with the above code, it works fine in serial mode but not in parallel mode. I did notice the HOST does not run this function, only the NODE machines. This really shouldn't make a difference, though, since the faces and cells are split among the NODES (not the HOST).

Any further suggestions are greatly appreciated. Thanks!

  Reply With Quote

Old   June 21, 2006, 13:31
Default Re: Help Parallelizing UDF - THREAD_STORE
  #4
wei rong
Guest
 
Posts: n/a
I strongly suggested you first read Fluent UDF manual. There is a chapter contributing to the problem. There are explanantions on difference between UDF used for serial and parallel mode and examples are attached to it.

First read. If you still have problems, Email me and I would be glad to discuss with you.

Good luck.
  Reply With Quote

Old   June 21, 2006, 15:21
Default Re: Help Parallelizing UDF - THREAD_STORE
  #5
Mario Santillo
Guest
 
Posts: n/a
Thanks for your response. I have read through the manual several times and have followed the examples in great detail. It turns out that I was actually debugging the wrong problem. The DEFINE_PROFILE function was working correctly, but my problem is the writing of cell velocities to a file.

Here is my new question. If I want to read the velocity of a specific cell in the mesh, is that cell # the same between both serial and parallel versions of FLUENT? For instance, say I want to read the x-velocity from cell #100 (as read from the grid on the FLUENT GUI). My code would look something like:

#if !RP_HOST /*SERIAL OR NODE*/ begin_c_loop(c,t) if(c==100) xvel = C_U(c,t); /*Read X-Velocity at Cell #100*/ end_c_loop(c,t) #endif

Then, by following the example in Section 9.7 of the UDF Manual, I go through the process of sending "xvel" to NODE0 and ultimately to the HOST to write a datafile. This is where I see a mismatch between the datafile written under SERIAL mode and the datafile written under PARALLEL mode. The numbers are not the same, though the files are of the same length. This is why I wonder if cell #'s are not unique and although I am looking for cell #100, perhaps I am not recording the correct data. Any suggestions?

Thanks for all of your help!
  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
automatic parallelizing udf chaos FLUENT 2 August 1, 2011 02:51
multi-core processor about parallelizing udf dasah Fluent UDF and Scheme Programming 0 June 23, 2011 11:50
Help Parallelizing UDF AndresC FLUENT 0 February 25, 2010 16:50
Help, parallelizing UDF problem. blivurmind Fluent UDF and Scheme Programming 2 July 24, 2009 12:40
Help, parallelizing UDF problem blivurmind FLUENT 0 July 9, 2009 22:39


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