Momentum source UDF
Hi, I've just written up some code for a momentum source compiled UDF, where the constant source is restricted by its position in the domain and is adjusted on each iteration. It compiled OK (which doesn't mean much) but I get an error when fluent tries to call the function:
Error: get_udf_function: function cell_x_source has wrong type: 5 != 3 Error Object: () What does this mean and how can I fix it? I am a novice at C programming so it is probably something majorly wrong with the variable and function types I'm using. Here's the code: #include "udf.h" /*  X_Momentum_Source This routine returns the source term for the Xmomentum term for each control volume in the domain.  */ DEFINE_SOURCE(cell_x_source, cell, thread, dS, eqn) { real source; real xc[ND_ND]; /* 3D position in array */ C_CENTROID(xc,cell,thread); /* outputs xc (cell centroid) */ if (xc[0] > 0.95) { if (xc[0] < 1.05) if (xc[1] > 0) if (xc[1] < 1) /* Restricted position of momentum source */ /* source term */ source = 0.1; /* derivative of source term w.r.t. xvelocity. */ dS[eqn] = 0; } else source = dS[eqn] = 0.; return source; } 
Re: Momentum source UDF

Re: Momentum source UDF
What do you want to do with the following lines?
if (xc[0] > 0.95) { if (xc[0] < 1.05) if (xc[1] > 0) if (xc[1] < 1) Do you want to say if xc[0] belongs to (0.95, 1.05) and xc[1] belongs to (0,1)? If so, then you may want to try if((xc[0] > 0.95)&&(xc[0] < 1.05)&& (xc[1] > 0)&&(xc[1] < 1)) { source=0.1; dS[eqn]=0; } else { source=dS[eqn]=0; } 
Re: Momentum source UDF
Thanks for the reply. Yes, that is exactly what I want to say; I must say that is a way better way of putting it. Although I still get the same error when using the function with the 'adjust' function hook.
Error: get_udf_function: function cell_x_source has wrong type: 5 != 3 Error Object: () Any suggestions on what this error means with respect to my function code? Any solution to this? 
Re: Momentum source UDF
I might misunderstand, but if you're trying to implement this as an "adjust" function, then that's why you're getting an error. Just leave the function hook as "none", and set this source term in the boundary conditions panel. For each fluid zone you want to apply it to, turn on the "Source Terms" button, and then for the xmomentum equation, set udf cell_x_source.
Hope this helps. Keith 
Re: Momentum source UDF
Thanks, problem sorted. Now I understand where to use the DEFINE_SOURCE and DEFINE_ADJUST macros.

All times are GMT 4. The time now is 17:51. 