CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   A question about DEFINE_DMP_BODY_FORCE ! (https://www.cfd-online.com/Forums/fluent/43198-question-about-define_dmp_body_force.html)

zhaoh December 25, 2006 03:08

A question about DEFINE_DMP_BODY_FORCE !
 
Hi I have a question about DEFINE_DMP_BODY_FORCE want to consult you! The force is fx=2.2x+1.5y; fy=0. It just a body force about two-dimensional space direction. I am trying to write a UDF to include the body force. But it has some problems always. Could you check this UDF for me please? Does it need loop micros in computation according to different position of particles?

#include "udf.h" # include "dpm.h" #define C1 2.2 #define C2 1.5 DEFINE_DPM_BODY_FORCE(p_b_force, p, i) { Thread *t; real xc[ND_ND]; real x,y; real bforce; cell_t c; if(i==1) bforce=0; else if(i==0) C_CENTROID(xc, c, t); x=xc[0]; y=xc[1]; bforce=C1*x+C2*y; return (bforce/P_MASS(p)); }

If I compute the program, there'll be a window to appear go with the information. Updating solution at time level N... done. chip-exec: p_b_force: wrong return type: void udf function expected Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: () Please tell me how to solve this problem. Thanks a lot! My email address is xiaozhaozai@163.com.


Sujith December 25, 2006 09:34

Re: A question about DEFINE_DMP_BODY_FORCE !
 
There were some coding errors. Apart from that , you havent provided the cell c and cell thread t for the macro C_CENTROID(xc, c, t);

You have provide the cell and cell thread in which the particle is currently in.

----------------

#include "udf.h" # include "dpm.h" #define C1 2.2 #define C2 1.5 DEFINE_DPM_BODY_FORCE(p_b_force, p, i) {

real xc[ND_ND]; real x,y; real bforce;

cell_t c = RP_CELL(&(p->cCell)); Thread *t = RP_THREAD(&(p->cCell));

if(i==1) bforce=0; else if(i==0) { C_CENTROID(xc, c, t); x=xc[0]; y=xc[1]; bforce=C1*x+C2*y; }

return (bforce/P_MASS(p));

}

/* I havent check the code for any errors*/ ---------

Sujith S Nair

zhaoh December 25, 2006 19:59

Re: A question about DEFINE_DMP_BODY_FORCE !
 
Sujith: Thank you very much for response, first. I have been checked the case accorded to your advice, but it also has some problems, such as RP_CELL: undeclared variable and so on. Could you help me solve my problems more clearly? Could you teach me how to compile this UDF? I think I have no idea about it for along time. Thanks again! Expecting for your reply!

#include "udf.h" #include "dpm.h" #include "surf.h" #define C1 2.2 #define C2 1.5 DEFINE_DPM_BODY_FORCE(p_b_force, p, i) { real xc[ND_ND]; real x,y; real bforce; cell_t c = RP_CELL(&(p->cCell)); Thread *t = RP_THREAD(&(p->cCell)); if(i==1) bforce=0; else if(i==0) { C_CENTROID(xc, c, t);

x=xc[0];

y=xc[1];

bforce=C1*x+C2*y; } return (bforce/P_MASS(p)); }


sujith December 26, 2006 10:48

Re: A question about DEFINE_DMP_BODY_FORCE !
 
I was able to compile it successfully... Pls make sure u have, the supported compilers n all.

RP_CELL(&(p->cCell)) is used to get the cell in which the particle is in..

You can also use the particles positions directly using the macro P_POS(p)[0],P_POS(p)[1],P_POS(p)[2] for x,y,z coordinates of particle. No need for cell, cell-thread, centroid etc....


HS January 2, 2007 07:03

Re: A question about DEFINE_DMP_BODY_FORCE !
 
I would also suggest using the P_POS(p)[i]-commands, but perhaps that's not actually the same thing... I mean, P_POS(p) gives the coordinates for the current particle position, whereas C_CENTROID will return the cell centroid coordinates - i.e. there will be a slight difference depending on exactly where inside the cell the particle is currently positioned. This could perhaps be of either minor or major importance, depending on the mesh and the relative magnitude of the body force to the other forces acting on the particle.

/Henrik

zhaoh January 2, 2007 10:30

Re: A question about DEFINE_DMP_BODY_FORCE !
 
SUJITH and HS:

Thank you alot! These day I cannot communicate with you, because the network was cut down by the earthquake.I have been do it according to you advices. My code is:

#include "udf.h" #include "dpm.h" #include "surf.h" #define C1 2.2 #define C2 1.5 DEFINE_DPM_BODY_FORCE(p_b_force,p,i) { cell_t c=RP_CELL(&(p->cCell)); Thread *t = RP_THREAD(&(p->cCell)); Particle *p; real bforce; if(i==1) bforce=0; else if(i==0) { bforce=C1*P_POS(p)[0]+C2*P_POS(p)[1]; } return (bforce/P_MASS(p)); } but it has some problem as follows:

(system "move user_nt.udf libudf\ntx86\2d")0 (system "copy C:\Fluent.Inc\fluent6.1.22\src\makefile_nt.udf libudf\ntx86\2d\makefile") (chdir "libudf")() (chdir "ntx86\2d")() 004.c ..\..\src\004.c(10) : error C2082: redefinition of formal parameter 'p' Done. Opening library "libudf"... Error: open_udf_library: the system can not find the library。 Error Object: ()

what`s wrong with this program? who can tell me? my email address is: zhaohuang-csu@hotmail.com can you leave your email address? We can communicate with each other quickly and conveniently! Thank you!

zhaoh January 2, 2007 10:48

Re: A question about DEFINE_DMP_BODY_FORCE !
 
SUJITH and HS:

Thank you alot! These day I cannot communicate with you, because the network was cut down by the earthquake.I have been do it according to you advices. My code is:

#include "udf.h" #include "dpm.h" #include "surf.h" #define C1 2.2 #define C2 1.5 DEFINE_DPM_BODY_FORCE(p_b_force,p,i) { cell_t c=RP_CELL(&(p->cCell)); Thread *t = RP_THREAD(&(p->cCell)); Particle *p; real bforce; if(i==1) bforce=0; else if(i==0) { bforce=C1*P_POS(p)[0]+C2*P_POS(p)[1]; } return (bforce/P_MASS(p)); } but it has some problem as follows:

(system "move user_nt.udf libudf\ntx86\2d")0 (system "copy C:\Fluent.Inc\fluent6.1.22\src\makefile_nt.udf libudf\ntx86\2d\makefile") (chdir "libudf")() (chdir "ntx86\2d")() 004.c ..\..\src\004.c(10) : error C2082: redefinition of formal parameter 'p' Done. Opening library "libudf"... Err

zhaoh January 2, 2007 10:48

Re: A question about DEFINE_DMP_BODY_FORCE !
 
SUJITH and HS:

Thank you alot! These day I cannot communicate with you, because the network was cut down by the earthquake.I have been do it according to you advices. My code is:

#include "udf.h" #include "dpm.h" #include "surf.h" #define C1 2.2 #define C2 1.5 DEFINE_DPM_BODY_FORCE(p_b_force,p,i) { cell_t c=RP_CELL(&(p->cCell)); Thread *t = RP_THREAD(&(p->cCell)); Particle *p; real bforce; if(i==1) bforce=0; else if(i==0) { bforce=C1*P_POS(p)[0]+C2*P_POS(p)[1]; } return (bforce/P_MASS(p)); } but it has some problem as follows:

(system "move user_nt.udf libudf\ntx86\2d")0 (system "copy C:\Fluent.Inc\fluent6.1.22\src\makefile_nt.udf libudf\ntx86\2d\makefile") (chdir "libudf")() (chdir "ntx86\2d")() 004.c ..\..\src\004.c(10) : error C2082: redefinition of formal parameter 'p' Done. Opening library "libudf"... Error: open_udf_library: the system can not find the library。 Error Object: ()

what`s wrong with this program? who can tell me? my email address is: zhaohuang-csu@hotmail.com. Can you leave your email address? We can communicate with each other quickly and conveniently by email! Thank you!


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