|
[Sponsors] |
February 7, 2008, 06:29 |
WHAT IS WRONG WITH MY UDF?!
|
#1 |
Guest
Posts: n/a
|
I'm trying to take the x-velocity vectors and temperature profile from my outlet and past them on my inlet. I have written these UDF:s to do the job but it will not work. Somebody who can help me debugg it? It gives parse error on line 20 and I dont know why.
Greatful for any help at all! Mikael ------------------------------------------------ #include "udf.h" DEFINE_PROFILE(inlet_x_velocity_profile, thread, position) { real x[ND_ND]; real xkoord_out; real ykoord_out; face_t f_outlet; face_t f_inlet; real x_vel; Domain *domain; domain = Get_Domain(1); /*line 19*/ int zone_ID = 5; Thread *thread1 = Lookup_Thread(domain, zone_ID); begin_f_loop(f_outlet, thread1) /* Loop over faces in a face thread to get the information stored on faces. */ { F_CENTROID(x,f_outlet,thread1); xkoord_out = x[0]; ykoord_out = x[1]; x_vel = F_U(f_outlet,thread1); F_PROFILE(f_inlet,thread,position)=x_vel*((xkoord_ out)*(xkoord_out)/(0.0255*0.0255)+((ykoord_out+0.204)*(ykoord_out+0. 204))/(0.0255*0.0255)-1); } end_f_loop(f_outlet, thread1) --------------------------------------------------- #include "udf.h" /* must be at the beginning of every UDF you write */ #include "sg.h" DEFINE_PROFILE(inlet_x_velocity_profile, thread, position) { real x[ND_ND]; /* this will hold the position vector */ real xkoord_out; real ykoord_out; face_t f_outlet; face_t f_inlet; real x_vel; real Temp; Domain *domain; /* domain is declared as a variable */ domain = Get_Domain(1); /*line 19*/ int zone_ID=5; /* Zone ID for outlet zone from Boundary Conditions panel */ Thread *thread1 = Lookup_Thread(domain, zone_ID); begin_f_loop(f_outlet, thread1) /* Loop over faces in a face thread to get the information stored on faces. */ { F_CENTROID(x,f_outlet,thread1); xkoord_out = x[0]; ykoord_out = x[1]; Temp = F_T(f_outlet,thread1); F_PROFILE(f_inlet,thread,position)=Temp*((xkoord_o ut)*(xkoord_out)/(0.0255*0.0255)+((ykoord_out+0.204)*(ykoord_out+0. 204))/(0.0255*0.0255)-1); } end_f_loop(f_outlet, thread1) -------------------------------------------------------- |
|
February 7, 2008, 06:45 |
Re: WHAT IS WRONG WITH MY UDF?!
|
#2 |
Guest
Posts: n/a
|
Bad format on the other message, maybe this is easier to read...
------------------------------------------------ #include "udf.h" #include "sg.h" DEFINE_PROFILE(inlet_x_velocity_profile, thread, position) { real x[ND_ND]; real xkoord_out; real ykoord_out; face_t f_outlet; face_t f_inlet; real x_vel; Domain *domain; domain = Get_Domain(1); /*line 19*/ int zone_ID = 5; Thread *thread1 = Lookup_Thread(domain, zone_ID); begin_f_loop(f_outlet, thread1) /* Loop over faces in a face thread to get the information stored on faces. */ { F_CENTROID(x,f_outlet,thread1); xkoord_out = x[0]; ykoord_out = x[1]; x_vel = F_U(f_outlet,thread1); F_PROFILE(f_inlet,thread,position)=x_vel*((xkoord_ out)*(xkoord_out)/(0.0255*0.0255)+((ykoord_out+0.204)*(ykoord_out+0. 204))/(0.0255*0.0255)-1); } end_f_loop(f_outlet, thread1) --------------------------------------------------- #include "udf.h" /* must be at the beginning of every UDF you write */ #include "sg.h" DEFINE_PROFILE(inlet_x_velocity_profile, thread, position) { real x[ND_ND];/* this will hold the position vector */ real xkoord_out; real ykoord_out; face_t f_outlet; face_t f_inlet; real x_vel; real Temp; Domain *domain; /* domain is declared as a variable */ domain = Get_Domain(1); /*line 19*/ int zone_ID=5; /* Zone ID for outlet zone from Boundary Conditions panel */ Thread *thread1 = Lookup_Thread(domain, zone_ID); begin_f_loop(f_outlet, thread1) /* Loop over faces in a face thread to get the information stored on faces. */ { F_CENTROID(x,f_outlet,thread1); xkoord_out = x[0]; ykoord_out = x[1]; Temp = F_T(f_outlet,thread1); F_PROFILE(f_inlet,thread,position)=Temp*((xkoord_o ut)*(xkoord_out)/(0.0255*0.0255)+((ykoord_out+0.204)*(ykoord_out+0. 204))/(0.0255*0.0255)-1); } end_f_loop(f_outlet, thread1) -------------------------------------------------------- |
|
February 8, 2008, 06:12 |
Re: WHAT IS WRONG WITH MY UDF?!
|
#3 |
Guest
Posts: n/a
|
Hi!
The problem with your UDF is that DEFINE_PROFILE macro (so far I know) is executed within the thread loop. I hope this will help: 1. DEFINE_ON_DEMAND takes the values of U-velocity at outlet, stores them in 'container'. From there they are assigned to the inlet over F_UDMI. 2. DEFINE_PROFILE is more simple now, because the values you need are already stored in F_UDMI For sure, there could be a more elegant solution existing, my C-knowledge is rather poor. The routine will work only if the grid you use has the same number of cells at inlet and outlet, equally distributed (not equidistant) on both sides of domain. Otherwise you have to interpolate in some way. #include "udf.h" #define FROM_THREAD_ID 3 //outlet zone ID #define TARGET_THREAD_ID 4 //inlet zone ID DEFINE_ON_DEMAND(my_demand) { face_t f; double *container; int i=0; Thread* t = Lookup_Thread(root_domain, FROM_THREAD_ID); if (t == NULL) Error("can't lookup thread in my_demand!\n"); begin_f_loop (f,t) { F_UDMI(f,t,0) = F_U(f,t); container[i] = F_UDMI(f,t,0); i+=1; } end_f_loop (f,t) t = Lookup_Thread(root_domain, TARGET_THREAD_ID); if (t == NULL) Error("can't lookup thread in my_demand!\n"); i=0; begin_f_loop (f,t) { F_UDMI(f,t,0) = container[i]; i+=1; } end_f_loop (f,t) } DEFINE_PROFILE(inlet_x_velocity_profile, thread, position) { real x[ND_ND]; real xkoord_out; real ykoord_out; face_t f; begin_f_loop(f,thread) { F_CENTROID(x,f,thread); xkoord_out = x[0]; ykoord_out = x[1]; //here you can define your function: //F_PROFILE(f_inlet,thread,position)=F_UDMI(f,thread ,0)*((xkoord_out)*(xkoord_out)/(0.0255*0.0255)+((ykoord_out+0.204)*(ykoord_out+0. 204))/(0.0255*0.0255)-1); F_PROFILE(f,thread,position)= F_UDMI(f,thread,0)*2.; } end_f_loop(f, thread) } |
|
February 12, 2008, 08:42 |
Re: WHAT IS WRONG WITH MY UDF?!
|
#4 |
Guest
Posts: n/a
|
Thanks! I have now got my UDF to work (the one you wrote for me) in the matter of getting it compiled and able to load. But there is a problem... When I try to iterate (unsteady) it doesn't seem as the velocity is moved to the inlet immediataly because the velocity contour at the inlet is equally colored and doesnt look at all like the outlet. As the iterations pass the velocity decreases more and more from my average of 1 m/s.. Do know what could be the problem?
Mikael |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
parse error while interpreting udf | Kristin | Fluent UDF and Scheme Programming | 3 | March 15, 2012 07:43 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
I need UDF help. | S.Whitney | FLUENT | 0 | October 15, 2007 12:29 |
what's wrong with the UDF | major | FLUENT | 6 | March 3, 2005 07:39 |
UDF...UDF...UDF...UDF | Luc SEMINEL | FLUENT | 0 | November 25, 2002 05:03 |