|
[Sponsors] |
May 3, 2001, 03:13 |
Momentum source UDF
|
#1 |
Guest
Posts: n/a
|
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 X-momentum 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. x-velocity. */ dS[eqn] = 0; } else source = dS[eqn] = 0.; return source; } |
|
May 3, 2001, 03:22 |
Re: Momentum source UDF
|
#2 |
Guest
Posts: n/a
|
|
|
May 3, 2001, 11:57 |
Re: Momentum source UDF
|
#3 |
Guest
Posts: n/a
|
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; } |
|
May 3, 2001, 12:15 |
Re: Momentum source UDF
|
#4 |
Guest
Posts: n/a
|
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? |
|
May 3, 2001, 14:37 |
Re: Momentum source UDF
|
#5 |
Guest
Posts: n/a
|
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 x-momentum equation, set udf cell_x_source.
Hope this helps. Keith |
|
May 3, 2001, 22:18 |
Re: Momentum source UDF
|
#6 |
Guest
Posts: n/a
|
Thanks, problem sorted. Now I understand where to use the DEFINE_SOURCE and DEFINE_ADJUST macros.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Version 15 on Mac OS X | gschaider | OpenFOAM Installation | 113 | December 2, 2009 11:23 |
Pressure jump and momentum source | Tanya | FLUENT | 1 | June 4, 2009 16:22 |
UDF for energy source | João Fernandes | FLUENT | 4 | October 17, 2008 05:53 |
UDF: PROFILE + SOURCE | Nuno | FLUENT | 0 | September 1, 2008 16:31 |
UDFs for Scalar Eqn - Fluid/Solid HT | Greg Perkins | FLUENT | 0 | October 14, 2000 00:03 |