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

Warning: UDF FLUENT

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 26, 2019, 12:04
Default Warning: UDF FLUENT
  #1
New Member
 
hraf5
Join Date: Mar 2018
Posts: 8
Rep Power: 8
EL OMARI Achraf is on a distinguished road
Hi everyone,
I'm getting the following warning when I compiled a UDF function in Fluent. I obtained the following warning:

warning C4700: uninitialized local variable 'x' used

is this program right, or something is missing??



#include "udf.h"
#define PI 3.14
#define A 20.0
#define freq 10.0

DEFINE_PROFILE(unsteady_inlet_x_velocity, thread, position)
{
real y[ND_ND] ;
real x;
face_t f;
real t = CURRENT_TIME;

begin_f_loop(f, thread)
{
F_PROFILE(f,thread, position) = sin(15.*PI/180)*A*sin(400.*PI*(x-0.001))*sin(400.*PI*(x-0.001))*sin(freq*2.*PI*t);
}
end_f_loop(f, thread)
}

DEFINE_PROFILE(unsteady_inlet_y_velocity, thread, position)
{
real y[ND_ND];
real x;
face_t f;
real t = CURRENT_TIME;

begin_f_loop(f, thread)
{
F_PROFILE(f,thread, position) = cos(15.*PI/180)*A*sin(400.*PI*(x-0.001))*sin(400.*PI(x-0.001))*sin(freq*2.*PI*t);
}
end_f_loop(f, thread)
}
EL OMARI Achraf is offline   Reply With Quote

Old   March 26, 2019, 12:28
Default
  #2
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,675
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
just follow the error message

Quote:
Originally Posted by EL OMARI Achraf View Post
real x;
you declared x here

Quote:
Originally Posted by EL OMARI Achraf View Post
F_PROFILE(f,thread, position) = cos(15.*PI/180)*A*sin(400.*PI*(x-0.001))*sin(400.*PI(x-0.001))*sin(freq*2.*PI*t);
You called x here and also later but never assigned any values to x.

Check out the example from the Fluent manual. You are missing lines that should look like so:
Code:
F_CENTROID(y, f, thread);

x = y[0];
F_Centroid is a macro that loops over the face thread f and stores the centroids into variable y. Hence why you declare real y[ND_ND]; instead of just real y;
x=y[0] takes the 1st value of the centroid coordinate (the x position in this case). If you want the y coordinate then do y[1], and do y[2] if you want the z coordinate.
LuckyTran is offline   Reply With Quote

Old   March 26, 2019, 15:05
Default question
  #3
Member
 
Join Date: Sep 2018
Posts: 31
Rep Power: 7
serrar is on a distinguished road
Thanks a lot for your advice, I did everything you asked me to do but I still get the error mentioned above
------------------------------------------------------------------------------------
vprofile1.c(31): error C2064: term does not evaluate to a function taking 337 arguments

------------------------------------------------------------------------------------
To clarify things, my basic equation is noted as 1:

1) A*sin(400.*PI*(x-0.001))*sin(400.*PI*(x-0.01))*sin(freq*2.*PI*t)

and concerning the X and Y axes present the projection of this equation according to these axes.

I hoped things were very clear

how can I solve this problem?
Best regards
serrar is offline   Reply With Quote

Old   March 26, 2019, 16:38
Default
  #4
Member
 
Join Date: Sep 2018
Posts: 31
Rep Power: 7
serrar is on a distinguished road
serrar is offline   Reply With Quote

Old   March 26, 2019, 21:32
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
put here final version of your code

best regards
AlexanderZ is offline   Reply With Quote

Old   March 27, 2019, 03:14
Default
  #6
Member
 
Join Date: Sep 2018
Posts: 31
Rep Power: 7
serrar is on a distinguished road
Hello everyone,
I hope someone can compile this code and modify or correct it if there are any errors, I would be very grateful.
Best regards
------------------------------------------
#include "udf.h"
#define PI 3.14
#define A 20.0
#define freq 10.0

DEFINE_PROFILE(unsteady_inlet_x_velocity, thread, position)
{
real y[ND_ND] ;
real x;
face_t f;
real t = CURRENT_TIME;

begin_f_loop(f, thread)
{
F_PROFILE(f,thread, position) = sin(15.*PI/180)*A*sin(400.*PI*(x-0.001))*sin(400.*PI*(x-0.001))*sin(freq*2.*PI*t);
}
end_f_loop(f, thread)
}

DEFINE_PROFILE(unsteady_inlet_y_velocity, thread, position)
{
real y[ND_ND];
real x;
face_t f;
real t = CURRENT_TIME;

begin_f_loop(f, thread)
{
F_CENTROID(y,f,thread);
x = y[0];
F_PROFILE(f,thread, position) = cos(15.*PI/180)*A*sin(400.*PI*(x-0.001))*sin(400.*PI(x-0.001))*sin(freq*2.*PI*t);
}
end_f_loop(f, thread)
}
serrar is offline   Reply With Quote

Old   March 27, 2019, 04:13
Default
  #7
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Code:
#include "udf.h"
#include "math.h"
#define PI 3.14
#define A 20.0
#define freq 10.0

DEFINE_PROFILE(unsteady_inlet_x_velocity, thread, position) 
{
real y[ND_ND] ;
real x;
face_t f;
real t = CURRENT_TIME;

begin_f_loop(f, thread)
{
F_CENTROID(y,f,thread);
x = y[0];
F_PROFILE(f,thread, position) = sin(15.*PI/180)*A*sin(400.*PI*(x-0.001))*sin(400.*PI*(x-0.001))*sin(freq*2.*PI*t);
}
end_f_loop(f, thread)
}
best regards
AlexanderZ is offline   Reply With Quote

Old   March 27, 2019, 06:28
Default
  #8
Member
 
Join Date: Sep 2018
Posts: 31
Rep Power: 7
serrar is on a distinguished road
dear AlexanderZ,
thank you very much for your help
to clarify the problem exists only in the part that represents the projection along the axis OY

#include "udf.h"
#include "math.h"
#define PI 3.14
#define A 20.0
#define freq 10.0

DEFINE_PROFILE(unsteady_inlet_x_velocity, thread, position)
{
real y[ND_ND] ; /* projection along the OX axis */
real x;
face_t f;
real t = CURRENT_TIME;

begin_f_loop(f, thread)
{
F_PROFILE(f,thread, position) = sin(15.*PI/180)*A*sin(400.*PI*(x-0.001))*sin(400.*PI*(x-0.001))*sin(freq*2.*PI*t);
}
end_f_loop(f, thread)
}
----------------------------------------------------------------------------
----------------------------------------------------------------------------
DEFINE_PROFILE(unsteady_inlet_y_velocity, thread, position)
{
real y[ND_ND]; /* projection along the OY axis */
real x;
face_t f;
real t = CURRENT_TIME;

begin_f_loop(f, thread)
{
F_CENTROID(y,f,thread);
x = y[0];
F_PROFILE(f,thread, position) = cos(15.*PI/180)*A*sin(400.*PI*(x-0.001))*sin(400.*PI(x-0.001))*sin(freq*2.*PI*t);
}
end_f_loop(f, thread)
}
----------------------------------------------------------------------
----------------------------------------------------------------------


Best regards
serrar is offline   Reply With Quote

Old   March 27, 2019, 19:34
Default
  #9
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
to clarify - no

best regards
AlexanderZ 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
[Other] refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 2 November 11, 2021 11:04
whats the cause of error? immortality OpenFOAM Running, Solving & CFD 13 March 24, 2021 07:15
Two questions on Fluent UDF Steven Fluent UDF and Scheme Programming 7 March 23, 2018 03:22
Problem with compiling UDF in Fluent amojodi Fluent UDF and Scheme Programming 4 April 14, 2015 09:01
using METIS functions in fortran dokeun Main CFD Forum 7 January 29, 2013 04:06


All times are GMT -4. The time now is 03:55.