UDF interpret error with "C_CENTROID"
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; } |
It will help when you show the relevant part of your UDF. Now I can only guess for possible errors in your code.
|
you have spelt C_CENTROID incorrectly...youve got C_CENTRIOD.
|
Quote:
|
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) } |
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...
|
Quote:
|
All times are GMT -4. The time now is 06:17. |