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

Momentum source UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 3, 2001, 02:13
Default Momentum source UDF
  #1
Matthew Brannock
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; }

  Reply With Quote

Old   May 3, 2001, 02:22
Default Re: Momentum source UDF
  #2
John Brown
Guest
 
Posts: n/a
  Reply With Quote

Old   May 3, 2001, 10:57
Default Re: Momentum source UDF
  #3
Xiao Hu
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; }
  Reply With Quote

Old   May 3, 2001, 11:15
Default Re: Momentum source UDF
  #4
Matthew Brannock
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?
  Reply With Quote

Old   May 3, 2001, 13:37
Default Re: Momentum source UDF
  #5
keith
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
  Reply With Quote

Old   May 3, 2001, 21:18
Default Re: Momentum source UDF
  #6
Matthew Brannock
Guest
 
Posts: n/a
Thanks, problem sorted. Now I understand where to use the DEFINE_SOURCE and DEFINE_ADJUST macros.
  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
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 10:23
Pressure jump and momentum source Tanya FLUENT 1 June 4, 2009 15:22
UDF for energy source João Fernandes FLUENT 4 October 17, 2008 04:53
UDF: PROFILE + SOURCE Nuno FLUENT 0 September 1, 2008 15:31
UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0 October 13, 2000 23:03


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