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 Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 20, 2009, 01: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 16:22.
Jinfeng is offline   Reply With Quote

Old   September 20, 2009, 06:16
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
It will help when you show the relevant part of your UDF. Now I can only guess for possible errors in your code.
Bernhard is offline   Reply With Quote

Old   September 25, 2009, 11:55
Default
  #3
Member
 
Akour
Join Date: May 2009
Posts: 79
Rep Power: 16
ak6g08 is on a distinguished road
you have spelt C_CENTROID incorrectly...youve got C_CENTRIOD.
__________________
akour
ak6g08 is offline   Reply With Quote

Old   September 26, 2009, 18:40
Default
  #4
New Member
 
Jinfeng
Join Date: Aug 2009
Posts: 6
Rep Power: 16
Jinfeng is on a distinguished road
Quote:
Originally Posted by ak6g08 View Post
you have spelt C_CENTROID incorrectly...youve got C_CENTRIOD.
Thank you so much, akour! I just realized how stupid the mistake was! Oh, damn......
Jinfeng is offline   Reply With Quote

Old   November 5, 2020, 11:02
Default
  #5
Member
 
abdo
Join Date: Apr 2018
Posts: 42
Rep Power: 6
khaledhmz is an unknown quantity at this point
this is my udf:

#include "udf.h"
#include "mem.h"
#define Y_CH4_in 0.032
#define Y_O2_in 0.225
DEFINE_PROFILE(mass_fraction, t, i)
{
face_t f;
begin_f_loop(f, t)
{
F_CENTROID(x, f, t);
F_PROFILE(f, t, i) = Y_CH4_in;
F_PROFILE(f, t, i) = Y_O2_in;
}
end_f_loop(f, t)
}
khaledhmz is offline   Reply With Quote

Old   November 6, 2020, 07:33
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Interesting code, I see that it is still the same as several days ago, so the same problems are there. If you don't understand suggestions, ask for clarification, don't just ignore the help you get and ask the question again...
khaledhmz likes this.
pakk is offline   Reply With Quote

Old   November 6, 2020, 16:38
Default
  #7
Member
 
abdo
Join Date: Apr 2018
Posts: 42
Rep Power: 6
khaledhmz is an unknown quantity at this point
Quote:
Originally Posted by pakk View Post
Interesting code, I see that it is still the same as several days ago, so the same problems are there. If you don't understand suggestions, ask for clarification, don't just ignore the help you get and ask the question again...
Hello, I correct some error and it compile but there are other error related to the temperature that why I repulish the new one.I can't change the concentrations of each species.
khaledhmz is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 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 09:10
interpret or compile an UDF (emergency) Lotfi FLUENT 1 August 26, 2007 13:58
Not able to interpret UDF Prasad FLUENT 1 August 15, 2007 09:44
Interpret three UDF for property Atsu FLUENT 4 April 22, 2006 16:04
UDF Interpret - Syntax Error Leonard FLUENT 1 October 22, 2005 11:06


All times are GMT -4. The time now is 08:29.