CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

UDF problem (ACCESS VIOLATION)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 11, 2009, 13:57
Default UDF problem (ACCESS VIOLATION)
  #1
Jorge Poyatos
Guest
 
Posts: n/a
Hi! sorry , but i am having some problems with a UDF, I am using it for discrete phase model. I can interpret it without problems but when i try to display the particles track i get the next error:

FLUENT received fatal signal (ACCESS VIOLATION) 1. Note exact evets 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: ()

The UDF is as follows:

#include "udf.h"

#include "mem.h"

DEFINE_DPM_DRAG(particle_drag_force,Re,p)

{

cell_t c;

Thread *t;

real drag_force;

double cd,epsilon,lkolm,pinelli;

epsilon = C_D(c, t);

if (Re > 1000)

{

cd=0.44;

}

else

{cd=24*(1+0.15*pow(Re,0.687))/Re;

}

lkolm = pow(0.001003/998.2,3);

lkolm = pow(lkolm/epsilon,0.25);

pinelli = 16.0*lkolm/0.000421-1.0;

pinelli = (exp(pinelli)-exp(-pinelli))/(exp(pinelli)+exp(-pinelli)); /* calculate TANH */

pinelli = 0.4*pinelli+0.6;

cd=cd/pow(pinelli,2.0);

drag_force = 18*cd*Re/24 ;

return (drag_force);

}

I realized that when I change: epsilon = C_D(c, t); by: epsilon = 10000 or any constant value.

Everything goes right.

if someone cuold help me.
  Reply With Quote

Old   March 12, 2009, 03:39
Default Re: UDF problem (ACCESS VIOLATION)
  #2
R Liew
Guest
 
Posts: n/a
Hi,

I assume your problem is unsteady in time, so I think the problem is the first iteration. You should iterate one time without using the UDF. Then, when this first iteration is done, you can turn on the UDF and then it should work. This is because Fluent need to calculate the diffusivity first.

You can make a if-function in the DEFINE loop like this:

real timestep = RP_Get_Real('physical_timestep');

real current_time = RP_Get_Real('current_time');

if (current_time>timestep)

{ your code }

else

{ drag_force = 0; }

Good luck!

R Liew
  Reply With Quote

Old   March 12, 2009, 08:25
Default Re: UDF problem (ACCESS VIOLATION)
  #3
Jorge Poyatos
Guest
 
Posts: n/a
It doesn't work. I think there is a problem in the function when a use Thread and cell, could you please check it? should I include c,t as arguments?

Thank you!
  Reply With Quote

Old   March 12, 2009, 11:54
Default Re: UDF problem (ACCESS VIOLATION)
  #4
R Liew
Guest
 
Posts: n/a
You should try this. If it's not working, you should check the UDF manual.

#include "udf.h"

#include "mem.h"

DEFINE_DPM_DRAG(particle_drag_force,Re,p)

{

cell_t c;

Thread *t;

real drag_force;

real timestep = RP_Get_Real('physical_timestep');

real current_time = RP_Get_Real('current_time');

if (current_time>timestep)

{

double cd,epsilon,lkolm,pinelli;

epsilon = C_D(c, t);

if (Re > 1000)

{cd=0.44;}

else

{cd=24*(1+0.15*pow(Re,0.687))/Re;}

lkolm = pow(0.001003/998.2,3);

lkolm = pow(lkolm/epsilon,0.25);

pinelli = 16.0*lkolm/0.000421-1.0;

pinelli = (exp(pinelli)-exp(-pinelli))/(exp(pinelli)+exp(-pinelli)); /* calculate TANH */

pinelli = 0.4*pinelli+0.6;

cd=cd/pow(pinelli,2.0);

drag_force = 18*cd*Re/24 ;

}

else

{

drag_force = 0;

}

return (drag_force);

}
  Reply With Quote

Old   March 12, 2009, 12:13
Default Re: UDF problem (ACCESS VIOLATION)
  #5
hervé
Guest
 
Posts: n/a
I am not experienced with interpreted udf, but should not you use "real" (which is a fluent type) instead of "double"?

"real" as the benefit to be immediately adpated either to float or double depending on the fluent version you are running, without having to recompile your udf.

Could this be the problem? Frankly I don't know...
  Reply With Quote

Old   March 16, 2009, 08:02
Default
  #6
Member
 
Henrik Ström
Join Date: Mar 2009
Posts: 33
Rep Power: 17
HenrikS is on a distinguished road
c and t are not passed as arguments to the macro and you need to supply these. Change:

cell_t c;
Thread *t;

to

cell_t c = P_CELL(p);
Thread *t = P_CELL_THREAD(p);

and things should hopefully work!

/Henrik
HenrikS is offline   Reply With Quote

Reply


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
access violation co2 FLUENT 5 November 7, 2010 10:48
Access Violation Help!!!!!! thuy FLUENT 0 March 5, 2008 08:26
ACCESS VIOLATION MHDWill FLUENT 1 September 23, 2007 02:51
Access violation - Help please AlwaysLearning FLUENT 3 August 22, 2006 12:21
access violation R.B.M FLUENT 3 July 11, 2002 05:07


All times are GMT -4. The time now is 15:35.