CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   DEFINE_SOURCE error (https://www.cfd-online.com/Forums/fluent/49121-define_source-error.html)

romans August 28, 2008 11:13

DEFINE_SOURCE error
 
Hello, I am solving the diffusion equation with the concentration formulation. I would like to add a source term via UDF that includes the gradient of concentration but I get an Access Violation error when I try to use the C_UDSI_G(c,t,i) macro. Can I use this macro with the concentration formulation?

my code is:

DEFINE_SOURCE(MySource,c,t,dS,eqn)

{ real Rw,Dc,De,Q; #define Rw 4.0e-4 #define Dc 0.0001 #define De 4.0e-5 #define Q 2.14e10

real x[ND_ND],XX, Source;

C_CENTROID(x,c,t);

XX=De*C_UDSI_G(c,t,C0)[2];

Source=XX-(Rw+Dc)*C_UDSI(c,t,C0)+Q;

C_UDSI(c,t,C1)=C_UDSI_G(c,t,C0)[2];

dS[eqn]=XX*C_UDSI_G(c,t,C1)[2]-Rw-Dc;

return Source; }

I have used the first derivative and second derivative.

Best Regards, thank you

romans


romans August 28, 2008 23:09

Re: DEFINE_SOURCE error
 
HI, I have used the first derivative and second derivative for the user defined scalars,when i initialize source terms, i get this error,just like: 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: ()

would you help me? Thank you in advance.

romans


CDE August 29, 2008 01:34

Re: DEFINE_SOURCE error
 
in the C_UDSI_G(c,t,i) macro, you use i = C0. Is C0 an integer?

romans August 29, 2008 06:57

Re: DEFINE_SOURCE error
 
Hi, in the C_UDSI_G(c,t,C0) macro, C0 is an integer. the code is compiled without error. now, i want to get the second derivative for C_UDSI_G(x,t,i),how to do?

Thanks.

romans

pacheo April 30, 2012 23:08

Quote:

Originally Posted by romans
;153064
Hi, in the C_UDSI_G(c,t,C0) macro, C0 is an integer. the code is compiled without error. now, i want to get the second derivative for C_UDSI_G(x,t,i),how to do?

Thanks.

romans

try to calculate several steps, then hook your udf.

hope that can help you.

t.krishnamohan May 1, 2012 21:00

The last argument in the DEFINE_SOURCE is an index. In your case it is eqn. C0 and C1 are not defined in your code.


All times are GMT -4. The time now is 04:47.