|
[Sponsors] |
September 20, 2009, 01:15 |
UDF interpret error with "C_CENTROID"
|
#1 |
New Member
Jinfeng
Join Date: Aug 2009
Posts: 6
Rep Power: 17 |
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. |
|
September 20, 2009, 06:16 |
|
#2 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
It will help when you show the relevant part of your UDF. Now I can only guess for possible errors in your code.
|
|
September 25, 2009, 11:55 |
|
#3 |
Member
Akour
Join Date: May 2009
Posts: 79
Rep Power: 17 |
you have spelt C_CENTROID incorrectly...youve got C_CENTRIOD.
__________________
akour |
|
September 26, 2009, 18:40 |
|
#4 |
New Member
Jinfeng
Join Date: Aug 2009
Posts: 6
Rep Power: 17 |
||
November 5, 2020, 11:02 |
|
#5 |
Member
abdo
Join Date: Apr 2018
Posts: 42
Rep Power: 7 |
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) } |
|
November 6, 2020, 07:33 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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...
|
|
November 6, 2020, 16:38 |
|
#7 |
Member
abdo
Join Date: Apr 2018
Posts: 42
Rep Power: 7 |
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.
|
|
|
|
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 |