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

UDF problems...FATAL ERROR!

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 8, 2005, 09:00
Default UDF problems...FATAL ERROR!
  #1
Paolo Lampitella
Guest
 
Posts: n/a
Thank you to all the people that helped me in these days. I'm still having problems with my UDF; now i post it all :

/************************************************** ********************

mut/mu profile

************************************************** *********************/

#include "udf.h"

/* profilo per il rapporto di viscosità turbolento */

DEFINE_PROFILE(mut_su_mu_profile, t, i)

{

real cf, utau, knw, kext, Kturb, mix, Epsilon;

real y, delta, uext, x[ND_ND], viscin, iext, cmu, vkc;

face_t f;

/*costanti*/

#define VISCIN 4.e-05 /*mu*/

#define Iext 0.01

#define uext 1.0

#define delta 0.5

#define CMU 0.09

#define VKC 0.41

cf = 0.045/pow(uext*delta/VISCIN,0.25);

knw=(pow(uext,2.)/sqrt(CMU))*cf/2.;

kext=(3./2.)*pow(uext,2.)*pow(Iext,2.);

begin_f_loop(f, t)

{

F_CENTROID(x,f,t);

y=x[2];

if (y <= delta)

Kturb=knw+y/delta*(kext-knw);

else

Kturb=kext;

if (VKC*y < 0.085*delta)

mix=VKC*y;

else

mix=0.085*delta;

Epsilon=pow(CMU,0.75)*pow(Kturb,1.5)/mix;

F_PROFILE(f,t,i)=F_R(f,t)*(CMU/VISCIN)*pow (Kturb,2.0)/Epsilon;

}

end_f_loop(f,t)

}

/************************************************** ********************

UDF for specifying a steady-state velocity profile boundary condition

************************************************** ********************/

DEFINE_PROFILE(inlet_x_velocity, thread, index)

{

real x[ND_ND];

real y;

real ydel;

real uset;

face_t f;

begin_f_loop(f, thread)

{

F_CENTROID(x,f,thread);

y = x[2];

if (y < delta)

y = x[2];

else

{

y = delta;

}

F_PROFILE(f, thread, index) = pow(y/delta,1./7.);

}

end_f_loop(f, thread)

}

/************************************************** ******************

udf_source_term.c line 90 UDF per il calcolo del source term (only 3D)

************************************************** ******************/

real Volume;

real ALPHA;

real XMIN, XMAX, YMIN, YMAX, ZMIN, ZMAX;

real Xg, Yg, Zg, dist;

real ny;

real d;

real d1;

real d2;

real dx, dy, dz;

real p1;

real p2;

real p3;

real xc[3];

real bar[3];

real xc1[3];

real x[3];

real x1[3];

int n;

DEFINE_ON_DEMAND(cell_select)

{

Domain *domain;

cell_t c;

Thread *t;

#define XMIN 1

#define XMAX 3.1

#define YMIN 14

#define YMAX 14

#define ZMIN 0

#define ZMAX 0.3

#define ALPHA 10

/*Calcolo del baricentro del MVG*/

p1=XMAX-XMIN;

p2=YMAX-YMIN;

p3=ZMAX-ZMIN;

Xg=p1/2+XMIN;

Yg=p2/2+YMIN;

Zg=p3/2+ZMIN;

bar[0]=Xg;

bar[1]=Yg;

bar[2]=Zg;

/*Valori iniziali per il confronto del ciclo if sulle celle*/

d=10;

d1=0;

domain = Get_Domain(1);

thread_loop_c(t,domain)

{

begin_c_loop(c,t)

{

C_CENTROID(xc,c,t);

dist=sqrt(pow((xc[0]-bar[0]),2)+pow((xc[1]-bar[1]),2)+pow((xc[2]-bar[2]),2));

if ( dist < d )

{

d=dist;

C_CENTROID(xc1,c,t);

for (n=0; n <= cell_type_nnodes[(int)C_TYPE(c,t)]; n++)

{

ny=NODE_Y(n);

d2=fabs(ny-bar[1]);

if (d2>d1)

{

d1=d2;

}

}

}

}

end_c_loop(c,t)

}

/*Calcolo del volume totale delle celle da selezionare*/

dx=(XMAX-XMIN)/2;

dy=d1/2;

dz=(ZMAX-ZMIN)/2;

Volume=0;

thread_loop_c(t,domain)

{

begin_c_loop(c,t)

{

C_CENTROID(x,c,t);

if ( fabs ( x[0] - bar[0] ) < dx )

{

if ( fabs ( x[2] - bar[2] ) < dz )

{

if ( fabs ( x[1] - xc1[1] ) < dy )

{

Volume=Volume+C_VOLUME(c,t);

}

}

}

}

end_c_loop(c,t)

}

}

/*PROVA INIZIALIZZAZIONE CAMPO*/

DEFINE_INIT(init_func, domain)

{

cell_t c;

Thread *t;

thread_loop_c (t,domain)

{

begin_c_loop_all (c,t)

{

C_CENTROID(x,c,t);

if ( fabs ( x[0] - bar[0] ) < dx )

{

if ( fabs ( x[2] - bar[2] ) < dz )

{

if ( fabs ( x[1] - xc1[1] ) < dy )

{

C_U(c,t)=100/Volume;

}

else

C_U(c,t)=0;

}

}

}

end_c_loop_all (c,t)

}

}

I wrote this UDF to set the boundary profiles at the inlet and to compute a source term for the x-mom eqn. At this stage there isn't the source term because i only want to know if i've selected the right cells where to put it in, so i wrote the DEFINE_INIT to do this check (after the initialization i will plot a velocity contour). The profiles already worked alone in an other UDF so i think the problem is not there. WHEN I INTERPRET THIS FILE, IT WORKS. After that the file has been interpreted i hook the on_demand routine and i have this error:

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: ()

but the initialization works (i need the on demand first). Obviously if i put all together in a DEFINE_INIT macro i have the same error. After this i started the debug of my UDF cutting a lot of parts and i discovered that when i try to run the on_demand the variables that i define in it are not read in the right way, so if i write:

#define a 1;

doesn't read it and say me that "a = a very big number that i don't remember" (i checked it with a printf command)

So now i'm going crazy because i don't know how to proceed. Any kind of help needed...please.

Thank you
  Reply With Quote

Old   September 8, 2005, 11:07
Default Re: UDF problems...FATAL ERROR!
  #2
Paolo Lampitella
Guest
 
Posts: n/a
Some news, maybe someone can help me:

I debugged all the UDF and i founded that the problem is the C_CENTROID(x,c,t) command, when i use it i have the fatal error. So i looked inside the metric.h file to see how is build the function C_CENTROID(x,c,t). Doing this i discovered that in this function is used the c_node_loop macro that gived me problems in the last days. Now i would try to see how is build this function inside fluent but i'm not able to do it because i can't find it anywhere. Do someone of you knows where is the relative "something.h" file in which is defined the macro c_node_loop? Or anyway someone knows what is the problem with my UDF?

Thanks a lot
  Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[swak4Foam] GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh gschaider OpenFOAM Community Contributions 300 October 29, 2014 19:00
OpenFOAM install on Ubuntu Natty 11.04 bkubicek OpenFOAM 13 May 26, 2011 06:48
compile errors of boundary condition "expDirectionMixed" liying02ts OpenFOAM Bugs 2 February 1, 2010 21:11
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
How to get the max value of the whole field waynezw0618 OpenFOAM Running, Solving & CFD 4 June 17, 2008 06:07


All times are GMT -4. The time now is 07:05.