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

UDF interpret error with "C_CENTROID"

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By pakk

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   September 20, 2009, 00:15
Default UDF interpret error with "C_CENTROID"
  #1
New Member
 
Jinfeng
Join Date: Aug 2009
Posts: 6
Rep Power: 16
Jinfeng is on a distinguished road
Hi folks,

I wrote a program to calculate the electrical body force with DEFINE_SOURCE macro. Inside the macro, C_CENTROID was used to get the coordinates of the cells (just like the DEFINE_SOURCE example in UDF manual). However, when I try to interpret the code, it gives me an error saying "line 13 C_CENTROID undeclared variable."

I can't figure out why it threw me that error! Does anybody know what's going on? Any help would be greatly appreciated! Thanks.

The following code is the DEFINE_SOURCE part:

#include "udf.h"

DEFINE_SOURCE(xmom_source, c, t, dS, eqn)
{
int i; // index for the nodes
float startx; // x coordinate of nearest node to interpolation node with lower x value
float starty; // y coordinate of nearest node to interpolation node with lower y value
float startz; // z coordinate of nearest node to interpolation node with lower z value
float xinterpfact, yinterpfact, zinterpfact;
float newrho;
float newdvdx, newdvdy, newdvdz;
float xinterp1, xinterp2, xinterp3, xinterp4;
float yinterp1, yinterp2;
real x[ND_ND];
real source;


C_CENTRIOD(x,c,t);

xinc = xdomain/(xdirnodes-1);
yinc = ydomain/(ydirnodes-1);
zinc = zdomain/(zdirnodes-1);
startx = ((
int)(x[0]/xinc))*xinc;
xinterpfact = (x[0] - startx)/xinc;
starty = ((
int)(x[1]/yinc))*yinc;
yinterpfact = (x[1] - starty)/yinc;

startz = ((
int)(x[2]/zinc))*zinc;
zinterpfact = (x[2] - startz)/zinc;

i = xdirnodes*ydirnodes*startz/zinc + xdirnodes*starty/yinc + startx/xinc;

//*** INTERPOLATE RHO ***//
xinterp1 = xinterpfact*(rho[i+1]-rho[i]) + rho[i];
xinterp2 = xinterpfact*(rho[i+xdirnodes+1]-rho[i+xdirnodes])+rho[i+xdirnodes];
xinterp3 = xinterpfact*(rho[i+xdirnodes*ydirnodes+1]-rho[i+xdirnodes*ydirnodes])+rho[i+xdirnodes*ydirnodes];
xinterp4 = xinterpfact*(rho[i+xdirnodes+xdirnodes*ydirnodes+1]-rho[i+xdirnodes+xdirnodes*ydirnodes])+rho[i+xdirnodes+xdirnodes*ydirnodes];

yinterp1 = yinterpfact*(xinterp2-xinterp1)+xinterp1;
yinterp2 = yinterpfact*(xinterp4-xinterp3)+xinterp3;

newrho = zinterpfact*(yinterp2-yinterp1)+yinterp1;

//*** INTERPOLATE DVDX ***//
xinterp1 = xinterpfact*(dvdx[i+1]-dvdx[i]) + dvdx[i];
xinterp2 = xinterpfact*(dvdx[i+xdirnodes+1]-dvdx[i+xdirnodes])+dvdx[i+xdirnodes];
xinterp3 = xinterpfact*(dvdx[i+xdirnodes*ydirnodes+1]-dvdx[i+xdirnodes*ydirnodes])+dvdx[i+xdirnodes*ydirnodes];
xinterp4 = xinterpfact*(dvdx[i+xdirnodes+xdirnodes*ydirnodes+1]-dvdx[i+xdirnodes+xdirnodes*ydirnodes])+dvdx[i+xdirnodes+xdirnodes*ydirnodes];

yinterp1 = yinterpfact*(xinterp2-xinterp1)+xinterp1;
yinterp2 = yinterpfact*(xinterp4-xinterp3)+xinterp3;

newdvdx = zinterpfact*(yinterp2-yinterp1)+yinterp1;

source = newrho*newdvdx;
dS[eqn] = 0.0;

return source;
}

Last edited by Jinfeng; September 20, 2009 at 15:22.
Jinfeng is offline   Reply With Quote

 


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
Can not to interpret UDF AlexanderSventitskiy FLUENT 4 August 18, 2011 08:10
interpret or compile an UDF (emergency) Lotfi FLUENT 1 August 26, 2007 12:58
Not able to interpret UDF Prasad FLUENT 1 August 15, 2007 08:44
Interpret three UDF for property Atsu FLUENT 4 April 22, 2006 15:04
UDF Interpret - Syntax Error Leonard FLUENT 1 October 22, 2005 10:06


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