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

Parallel UDF problem

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

Reply
 
LinkBack Thread Tools Display Modes
Old   November 7, 2008, 05:31
Default Parallel UDF problem
  #1
Lindsay
Guest
 
Posts: n/a
Hi,

Im having a couple of problems with running a UDF in parallel. When I compile the UDF on 2 processors, the library's are built and loaded but the simulation does not start. I receive a couple of warning signs during the build.

-In the host build:

modified_drag.c: In function `modified_drag_EMMS':

modified_drag.c:5: warning: 'k_g_s' might be used uninitialized in this function

-In the node build:

modified_drag.c: In function `modified_drag_EMMS':

modified_drag.c:80: warning: control reaches end of non-void function

modified_drag.c:10: warning: 'w' might be used uninitialized in this function

modified_drag.c:10: warning: 'cd' might be used uninitialized in this function

Firstly, I have initialised 'k_g_s', 'w' and 'cd' which confused me a bit and secondly I thought the 'warning: control reaches end of non-void function' might be why the simulation seems to stop before producing the first line of iteration.

The UDF is given as follows:

#include "udf.h"

DEFINE_EXCHANGE_PROPERTY(modified_drag_EMMS,cell,m ix_thread,s_col,f_col) { real k_g_s; #if !RP_HOST

Thread *thread_g, *thread_s; real x_vel_g, x_vel_s, y_vel_g, y_vel_s, abs_v, slip_x, slip_y,

rho_g, mu_g, Re, vf_g, vf_s, dp, w, cd;

/* find the threads for the gas (primary) */ /* and solids (secondary phases) */

thread_g = THREAD_SUB_THREAD(mix_thread, s_col); /* gas phase */ thread_s = THREAD_SUB_THREAD(mix_thread, f_col); /* solid phase*/

/* find phase velocities and properties*/

x_vel_g = C_U(cell, thread_g); y_vel_g = C_V(cell, thread_g); x_vel_s = C_U(cell, thread_s); y_vel_s = C_V(cell, thread_s); slip_x = x_vel_g - x_vel_s; /* velocity slip in the x direction */ slip_y = y_vel_g - y_vel_s; /* velocity slip in the y direction */

rho_g = C_R(cell, thread_g); /* gas density */

mu_g = C_MU_L(cell, thread_g); /* viscosity of gas */ dp = C_PHASE_DIAMETER(cell, thread_s); /* particle diameter */

vf_g = C_VOF(cell, thread_g); /* gas volume fraction */ vf_s = C_VOF(cell, thread_s); /* solid volume fraction */

/* Absolute slip velocity */ abs_v = sqrt(slip_x*slip_x + slip_y*slip_y);

/* Reynold's number */ Re = vf_g*rho_g*abs_v*dp/mu_g;

/* Reynolds conditions */

if (Re < 960)

cd = (24./(vf_g*Re))*(1+0.15*pow(vf_g*Re,0.687));

if (Re > 960)

cd = 0.44;

/* compute drag coefficient for dilute region */

if (0.74 < vf_g <= 0.82)

w = -0.1680+(0.0679/(4*pow(vf_g-0.7463,2)+0.0044));

if (0.82 < vf_g <= 0.97)

w = -0.8601+(0.0823/(4*pow(vf_g-0.7789,2)+0.0040));

if (0.97 < vf_g)

w = -31.8295+32.9895*vf_g;

k_g_s = 0.75*cd*((rho_g*vf_s*abs_v)/dp)*w;

/* drag coefficient for the dense region */

if(vf_g <= 0.74)

k_g_s = 150*((pow(vf_s,2)*mu_g)/(pow(vf_g,2)*pow(dp,2)))+1.75*((vf_s*rho_g*abs_v)/(vf_g*dp));

node_to_host_real_1(k_g_s);

#endif

#if !RP_NODE

return k_g_s;

#endif

}

I would really appreciate some guidence as to why the iterations are not starting as I am new to all this.

Thanks in advance,

Lindsay
  Reply With Quote

Old   June 9, 2016, 14:16
Default
  #2
Member
 
xin
Join Date: Dec 2013
Posts: 33
Rep Power: 4
guxin7005 is on a distinguished road
I have the same problem


Quote:
Originally Posted by Lindsay
;154600
Hi,

Im having a couple of problems with running a UDF in parallel. When I compile the UDF on 2 processors, the library's are built and loaded but the simulation does not start. I receive a couple of warning signs during the build.

-In the host build:

modified_drag.c: In function `modified_drag_EMMS':

modified_drag.c:5: warning: 'k_g_s' might be used uninitialized in this function

-In the node build:

modified_drag.c: In function `modified_drag_EMMS':

modified_drag.c:80: warning: control reaches end of non-void function

modified_drag.c:10: warning: 'w' might be used uninitialized in this function

modified_drag.c:10: warning: 'cd' might be used uninitialized in this function

Firstly, I have initialised 'k_g_s', 'w' and 'cd' which confused me a bit and secondly I thought the 'warning: control reaches end of non-void function' might be why the simulation seems to stop before producing the first line of iteration.

The UDF is given as follows:

#include "udf.h"

DEFINE_EXCHANGE_PROPERTY(modified_drag_EMMS,cell,m ix_thread,s_col,f_col) { real k_g_s; #if !RP_HOST

Thread *thread_g, *thread_s; real x_vel_g, x_vel_s, y_vel_g, y_vel_s, abs_v, slip_x, slip_y,

rho_g, mu_g, Re, vf_g, vf_s, dp, w, cd;

/* find the threads for the gas (primary) */ /* and solids (secondary phases) */

thread_g = THREAD_SUB_THREAD(mix_thread, s_col); /* gas phase */ thread_s = THREAD_SUB_THREAD(mix_thread, f_col); /* solid phase*/

/* find phase velocities and properties*/

x_vel_g = C_U(cell, thread_g); y_vel_g = C_V(cell, thread_g); x_vel_s = C_U(cell, thread_s); y_vel_s = C_V(cell, thread_s); slip_x = x_vel_g - x_vel_s; /* velocity slip in the x direction */ slip_y = y_vel_g - y_vel_s; /* velocity slip in the y direction */

rho_g = C_R(cell, thread_g); /* gas density */

mu_g = C_MU_L(cell, thread_g); /* viscosity of gas */ dp = C_PHASE_DIAMETER(cell, thread_s); /* particle diameter */

vf_g = C_VOF(cell, thread_g); /* gas volume fraction */ vf_s = C_VOF(cell, thread_s); /* solid volume fraction */

/* Absolute slip velocity */ abs_v = sqrt(slip_x*slip_x + slip_y*slip_y);

/* Reynold's number */ Re = vf_g*rho_g*abs_v*dp/mu_g;

/* Reynolds conditions */

if (Re < 960)

cd = (24./(vf_g*Re))*(1+0.15*pow(vf_g*Re,0.687));

if (Re > 960)

cd = 0.44;

/* compute drag coefficient for dilute region */

if (0.74 < vf_g <= 0.82)

w = -0.1680+(0.0679/(4*pow(vf_g-0.7463,2)+0.0044));

if (0.82 < vf_g <= 0.97)

w = -0.8601+(0.0823/(4*pow(vf_g-0.7789,2)+0.0040));

if (0.97 < vf_g)

w = -31.8295+32.9895*vf_g;

k_g_s = 0.75*cd*((rho_g*vf_s*abs_v)/dp)*w;

/* drag coefficient for the dense region */

if(vf_g <= 0.74)

k_g_s = 150*((pow(vf_s,2)*mu_g)/(pow(vf_g,2)*pow(dp,2)))+1.75*((vf_s*rho_g*abs_v)/(vf_g*dp));

node_to_host_real_1(k_g_s);

#endif

#if !RP_NODE

return k_g_s;

#endif

}

I would really appreciate some guidence as to why the iterations are not starting as I am new to all this.

Thanks in advance,

Lindsay
guxin7005 is offline   Reply With Quote

Old   June 10, 2016, 10:08
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 919
Rep Power: 12
pakk will become famous soon enough
I'll assume you use the same code as Lindsay, because you did not supply any other information.

This code uses compiler directives. Look for this term in the Fluent manual.

In the host build, RP_HOST is true and RP_NODE is false. So the code simplifies to:

Code:
#include "udf.h"

DEFINE_EXCHANGE_PROPERTY(modified_drag_EMMS,cell,m ix_thread,s_col,f_col) { real k_g_s;

return k_g_s;

}
And indeed, in line 5, k_g_s is returned but it has no value.


In the node build, RP_HOST is false and RP_NODE is true. So the code simplifies to:

Code:
#include "udf.h"

DEFINE_EXCHANGE_PROPERTY(modified_drag_EMMS,cell,m ix_thread,s_col,f_col) { real k_g_s;

Thread *thread_g, *thread_s; real x_vel_g, x_vel_s, y_vel_g, y_vel_s, abs_v, slip_x, slip_y,

rho_g, mu_g, Re, vf_g, vf_s, dp, w, cd;

/* find the threads for the gas (primary) */ /* and solids (secondary phases) */

thread_g = THREAD_SUB_THREAD(mix_thread, s_col); /* gas phase */ thread_s = THREAD_SUB_THREAD(mix_thread, f_col); /* solid phase*/

/* find phase velocities and properties*/

x_vel_g = C_U(cell, thread_g); y_vel_g = C_V(cell, thread_g); x_vel_s = C_U(cell, thread_s); y_vel_s = C_V(cell, thread_s); slip_x = x_vel_g - x_vel_s; /* velocity slip in the x direction */ slip_y = y_vel_g - y_vel_s; /* velocity slip in the y direction */

rho_g = C_R(cell, thread_g); /* gas density */

mu_g = C_MU_L(cell, thread_g); /* viscosity of gas */ dp = C_PHASE_DIAMETER(cell, thread_s); /* particle diameter */

vf_g = C_VOF(cell, thread_g); /* gas volume fraction */ vf_s = C_VOF(cell, thread_s); /* solid volume fraction */

/* Absolute slip velocity */ abs_v = sqrt(slip_x*slip_x + slip_y*slip_y);

/* Reynold's number */ Re = vf_g*rho_g*abs_v*dp/mu_g;

/* Reynolds conditions */

if (Re < 960)

cd = (24./(vf_g*Re))*(1+0.15*pow(vf_g*Re,0.687));

if (Re > 960)

cd = 0.44;

/* compute drag coefficient for dilute region */

if (0.74 < vf_g <= 0.82)

w = -0.1680+(0.0679/(4*pow(vf_g-0.7463,2)+0.0044));

if (0.82 < vf_g <= 0.97)

w = -0.8601+(0.0823/(4*pow(vf_g-0.7789,2)+0.0040));

if (0.97 < vf_g)

w = -31.8295+32.9895*vf_g;

k_g_s = 0.75*cd*((rho_g*vf_s*abs_v)/dp)*w;

/* drag coefficient for the dense region */

if(vf_g <= 0.74)

k_g_s = 150*((pow(vf_s,2)*mu_g)/(pow(vf_g,2)*pow(dp,2)))+1.75*((vf_s*rho_g*abs_v)/(vf_g*dp));

node_to_host_real_1(k_g_s);

}
In the last line (line 80), the function ends, but there was no return statement yet.

Furthermore, you have a problem when Re is exactly 960: cd is undefined.
And when vf is smaller than 0.74, w is undefined.

I guess that your first problems can be solved by changing RP_NODE to RP_HOST. I don't really see why that one was used.
And the other problems: define cd when Re is exactly 960, and define w when vf is smaller than 0.74.
pakk is online now   Reply With Quote

Old   June 20, 2016, 09:19
Default
  #4
Member
 
xin
Join Date: Dec 2013
Posts: 33
Rep Power: 4
guxin7005 is on a distinguished road
Thank you very much!!

I have code like this, it is strange that before I didn't have any error, but now I have same problem as mentioned before.


Code:
#include <stdio.h>
#include<math.h>
#include "udf.h"
DEFINE_SOURCE(plasmasourcez,c,t,dS,eqn)
{
	#if !RP_HOST
         double source;
         source=C_UDMI(c,t,1);
		 dS[eqn] = 0;
		 return source;
	#endif
}
guxin7005 is offline   Reply With Quote

Old   June 20, 2016, 09:37
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 919
Rep Power: 12
pakk will become famous soon enough
Quote:
Originally Posted by guxin7005 View Post
Thank you very much!!

I have code like this, it is strange that before I didn't have any error, but now I have same problem as mentioned before.
What is "same problem as mentioned before"? Be more specific.
pakk is online now   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
Parallel UDF Problem Dimitris Fluent UDF and Scheme Programming 7 September 20, 2013 01:51
parallel problem siyu CD-adapco 6 March 7, 2009 00:38
Problem in Parallel UDF Giacomo de Renzi FLUENT 12 June 18, 2008 12:19
parallel problem rui CD-adapco 2 July 31, 2007 13:23
parallel UDF problem kerem FLUENT 2 June 20, 2006 06:56


All times are GMT -4. The time now is 05:23.