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

Access Violation when using F_C0 and F_C1

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 15, 2012, 01:08
Default Access Violation when using F_C0 and F_C1
  #1
New Member
 
Trent
Join Date: Nov 2012
Posts: 3
Rep Power: 14
tjmartian is on a distinguished road
I am trying to find the cell index of a neighboring cell and found the macros F_C0 and F_C1 that look like they would work for me. However, when I try to run the code I get an Access Violation in Fluent. I read through the user manual and believe I am doing it correctly. The code is as follows:

Code:
 
#include "udf.h"
#include "metric.h"
#include "stdio.h"
#include "math.h"
#include "stdlib.h"
 
float mass_load[3000];
float mass_load_new[3000];
Domain *dz;
Thread *t;
Thread *t0;
Thread *t1;
Thread *tz;
Thread *tf;
cell_t c, ca, cb, cz;
face_t f;
int j, k;
 
DEFINE_INIT(cell_init, d)
{
double inlet_ml; inlet_ml = .01; j=0; thread_loop_c(t,d) {
begin_c_loop(c,t) {
mass_load[j] = inlet_ml; j++;
} end_c_loop(c,t)
}
}   DEFINE_ADJUST(get_data4, d) {
real vel[2]; real A[2]; real next_centr[2]; double av_prod, cell_ml; double mass_load_sum, mass_out_sum; int i; dz = Get_Domain(1); j=0; thread_loop_c(t,d) {
begin_c_loop(c,t) {
mass_load_sum = 0; mass_out_sum = 0; for(i=0; i<4; i++) { f = C_FACE(c,t,i); tf = C_FACE_THREAD(c,t,i); t0 = THREAD_T0(tf); t1 = THREAD_T1(tf); ca = F_C0(f,tf); cb = F_C1(f,tf); if(c1 != NULL) {
vel[0] = ((C_U(c0,t0) + C_U(c1,t1))/2); vel[1] = ((C_V(c0,t0) + C_V(c1,t1))/2);
} else {
vel[0] = 0; vel[1] = 0;
} F_AREA(A,f,tf); av_prod = NV_DOT(vel, A); if(av_prod < 0) {
C_CENTROID(next_centr, c1, t1); k = 0; thread_loop_c(tz,dz) {
begin_c_loop(cz,tz) {
if(cz == c) {
cell_ml = mass_load[k];
}
k++; } end_c_loop(cz,tz)
} mass_load_sum += cell_ml * fabs(av_prod);
} else {
mass_out_sum += fabs(av_prod);
} } mass_load_new[j] = mass_load_sum/mass_out_sum; j++;
} end_c_loop(c,t)
} j=0; thread_loop_c(t,d) {
begin_c_loop(c,t) {
mass_load[j] = mass_load_new[j]; j++;
} end_c_loop(c,t)
}
}
The code compiles fine but when I try to run it I get the error. As soon as I get rid of the F_C0 and F_C1 lines the code runs fine so it would seem that's where the problem is. Is there anything wrong with how I'm using those macros or is there anything else I can try? Thanks for your help.
tjmartian is offline   Reply With Quote

Reply

Tags
face connectivity


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



All times are GMT -4. The time now is 22:48.