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

WHAT IS WRONG WITH MY UDF?!

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 7, 2008, 06:29
Default WHAT IS WRONG WITH MY UDF?!
  #1
Mikael
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) --------------------------------------------------------
  Reply With Quote

Old   February 7, 2008, 06:45
Default Re: WHAT IS WRONG WITH MY UDF?!
  #2
Mikael
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)

--------------------------------------------------------

  Reply With Quote

Old   February 8, 2008, 06:12
Default Re: WHAT IS WRONG WITH MY UDF?!
  #3
selma
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) }

  Reply With Quote

Old   February 12, 2008, 08:42
Default Re: WHAT IS WRONG WITH MY UDF?!
  #4
Mikael
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
  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
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


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