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

Weird problem in my UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 27, 2011, 02:46
Default Weird problem in my UDF
  #1
Member
 
Join Date: Mar 2011
Posts: 38
Rep Power: 15
aleisia is on a distinguished road
I want to model a filter (but not modeling it as a porous media), in a room I have SO2-air mixture. First I want to get the SO2 mass flow rate at the inlet surface of the filter, then multiply it by 0.999989, and set the sink rate of the filter volume as -0.999989*(SO2 mass flow rate at the inlet surface)/(Volume of filter). For the outlet of the filter, I set it as "interior", so you can see the filter is not perfect, and my simulation is always transient.

The transient code is almost ready after discussion with ANSYS technical support, but when I applied the serial version into test, I got these errors:

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:
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: #f

I'm sure I got the inlet surface and volume's zone ID correct, I googled, and some said there could be two reasons: 1) mesh problem, my mesh skewness is 0.9688, I know it is high, but there is no way I can make it smaller; 2) there is no enough memory (since it is serial mode), I have 14G of memory, and I've made the gird as coarse as possible so that the serial mode can work.
What I'm trying to ask is, 1) is there any other reasons that can cause these errors? 2) Am I writing the UDMs right in DEFINE_SOURCE? because in my DEFINE_SOURCE, I just use the UDMIs to transfer the data calculated from DEFINE_ADJUST, but in DEFINE_ADJUST, I used begin_f_loop and begin_c_loop to go over all the faces and cells involved to calculate the entire surface mass flow rate and entire volume and store them in UDMs, but in DEFINE_SOURCE, I just used UDMs, without writing begin_f_loop or begin_c_loop to get the data from UDMs to some other variables that I'll use later. Actually, I followed the example 7.8 in the UDF manual, that's how it is done in that example, so I'm very confused.
Please advise.
Thanks

my serial udf:

#include "udf.h"

#define inlet_surface_ID 70
#define filter_volume_ID 3

Domain *d;

DEFINE_ADJUST(my_adjust, d)
{
int i;
/* real A[ND_ND]; */
/* real flux[ND_ND]; */
real NV_VEC(flux);
real NV_VEC(A); /* declaring vectors flux and A */
real source;
real massflowrate;
real vol;
/* real ti = RP_Get_Real("flow-time"); */ /* ti = CURRENT_TIME;*/
face_t f;
cell_t c;
Thread *t;
Thread *thread;

t = Lookup_Thread(d, inlet_surface_ID); /* defining the inlet surface thread by specifying the Zone_ID*/
thread= Lookup_Thread(d, filter_volume_ID); /* defining the filter volume thread by specifying the Zone_ID*/
vol=0.0;
massflowrate=0.0;


/* Send the ID value to all the nodes */
/* host_to_node_real_4(f, t, c, thread); Does nothing in serial, t is the thread of inlet surface, thread is the thread of the filter volume */

/*Start to calculate the mass flow rate through the inlet surface and store it in UDM*/

begin_f_loop(f,t)
if PRINCIPAL_FACE_P(f,t) /* tests if the face is the principle face FOR COMPILED UDFs ONLY */
{
/* NV_D(flux, =, F_U(f,t), F_V(f,t), F_W(f,t)); */ /* defining flux in terms of velocity field */
/* NV_S(flux, *=, F_R(f,t)); */ /* multiplying density to get flux vector */
/* F_AREA(A,f,t); */ /* face normal vector returned from F_AREA */
/* i is being used uninitialized. Please fix this */
massflowrate += F_FLUX(f,t)*F_YI(f,t,i); /* dot product of the inlet surface flux and area vector, multiplied by the mass fraction of species i */
}
end_f_loop(f,t)

/* # if RP_NODE /\* Perform node synchronized actions here, Does nothing in Serial *\/ */
massflowrate = PRF_GRSUM1(massflowrate);
/* # endif /\* RP_NODE *\/ */


begin_f_loop(f,t)
if PRINCIPAL_FACE_P(f,t) /* tests if the face is the principle face FOR COMPILED UDFs ONLY */
{
F_UDMI(f, t, 0)= massflowrate; /* YOU MAY NEED TO CHECK THE NODE AS THE SUMMED UP VALUE OF massflowrate IS DONE AT node0. */
}
end_f_loop(f,t)
Message0("Inlet TEP Mass Flor Rate through %d is: %g \n", inlet_surface_ID, massflowrate);

/*Start to calculate the total volume of filter volume and store it in UDM */
begin_c_loop(c,thread)
{
vol += C_VOLUME(c,thread); /* get cell volume */
}
end_c_loop_int(c,thread)

/* #if RP_NODE /\* Perform node synchronized actions here, Does nothing in Serial *\/ */
vol= PRF_GRSUM1(vol);
/* # endif /\* RP_NODE *\/ */

begin_c_loop_int(c,thread)
{
C_UDMI(c, thread, 1)= vol; /* YOU MAY NEED TO CHECK THE NODE AS THE SUMMED UP VALUE OF massflowrate IS DONE AT node0. */
}
end_c_loop_int(c,thread)
Message0("Sink Volume in %d is: %g \n", filter_volume_ID, vol);

}

DEFINE_SOURCE(cell_tepmass_source, c, thread, dS, eqn)
{
/* int i; */
/* real A[ND_ND]; */
/* real flux[ND_ND]; */
/* real NV_VEC(flux); */
/* real NV_VEC(A); /\* declaring vectors flux and A *\/ */
real source;
real tepflowrate;
real vol_tot;
/* real ti = RP_Get_Real("flow-time"); /\* ti = CURRENT_TIME;*\/ */
face_t f;
Thread *t;
/* Thread *thread; */
/* Domain *d = Get_Domain(1); */
t= Lookup_Thread(d, inlet_surface_ID); /* defining the inlet surface thread by specifying the Zone_ID*/
thread= Lookup_Thread(d, filter_volume_ID); /* defining the filter volume thread by specifying the Zone_ID*/

/* f is being utilized without initialization. This will lead to errors.Please fix this issue */
/* instead of F_UDMI, you can store data in C_UDMI */
tepflowrate= F_UDMI(f, t, 0);
vol_tot = C_UDMI(c, thread, 1);

/* Pass the node's SO2 mass flow rate and volume to the Host for calculating source */
/* node_to_host_real_2(tepflowrate, vol_tot); /\* Does nothing in SERIAL *\/ */

source=0.999989*tepflowrate/vol_tot;
dS[eqn]=0.0;
return source;
Message("Sink Rate in Filter %d is %f (kg/m^3/s)\n", filter_volume_ID,source);

}
aleisia is offline   Reply With Quote

Old   June 29, 2011, 13:17
Default
  #2
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 156
Rep Power: 18
Micael is on a distinguished road
There is a problem in DEFINE_SOURCE. This udf is called for cell, but you try to access a face:
Code:
 
tepflowrate= F_UDMI(f, t, 0);
The funny thing is that there is a comment in your code pointing this out!
Code:
 
/* f is being utilized without initialization. This will lead to errors.Please fix this issue */
Micael 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
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 40 March 18, 2018 06:05
what's the problem with my udf zzyan FLUENT 0 November 4, 2010 03:56
Problem with my udf july Fluent UDF and Scheme Programming 3 June 20, 2010 06:56
udf compiling problem akr FLUENT 3 August 22, 2007 07:14
UDF problem chiseung FLUENT 4 January 10, 2002 09:58


All times are GMT -4. The time now is 09:20.