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

UDF syntax error

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 18, 2014, 08:49
Default UDF syntax error
  #1
New Member
 
Dawie Marais
Join Date: Jan 2014
Posts: 6
Rep Power: 12
Ratel is on a distinguished road
Hi,

I have written a UDF that specifies an atmospheric boundary layer (ABL) velocity profile at the inlet of a two-dimensional domain.

My ABL equation is valid for a domain where the origin lies on the bottom wall. For my work the domain is going to be translated downwards (So that the bottom wall will be in the negative y region)- this will happen automatically during design point runs in workbench and my UDF has to compensate for this by also translating the profile.

The attached UDF therefore loops through the boundary faces and nodes to find the most negative point (The bottom wall) and uses this value to translate the profile by the same amount. Below is my UDF:

--------------------------------------------------------------------
#include "udf.h"

#define uABL 0.2674; /* Atmospheric BL friction velocity */
#define k 0.41; /* Von Karman constant */
#define y0 4.6875E-4;; /* Aerodynamic roughness length */

/* Stream-wise velocity profile */
DEFINE_PROFILE(x_velocity,thread,nv)
{
real pos[ND_ND], y, yCnew, yNnew, yCold, yNold; /* variable declarations */
yCold = 1000; /* Initial values to ensure the two if-loops are entered */
yNold = 1000;

int n;
face_t f; /* f is a face thread index */
Node *node;

begin_f_loop(f, thread) /* loop through all the faces of the boundary*/
{
F_CENTROID(pos, f, thread); /* determine the centroid coordinate of the current face*/
yCnew = pos[1];

if (yCnew < yCold) /* if the current centroid coordinate is smaller than the previous one, loop through the nodes of that face*/
{
f_node_loop(f, thread, n)
{
node = F_NODE(f,thread,n);
yNnew = NODE_Y(node); /* nodal coordinate */

if (yNnew < yNold) /*if the current nodal coordinate is smaller than the previous one, replace it*/
{yNold = yNnew;}
}
yCold = yCnew; /* replace the previous centroid coordinate */
}
}
end_f_loop(f, thread)

begin_f_loop(f, thread) /*loop through the faces agian and specify te velocity profile */
{
F_CENTROID(pos, f, thread);
y = pos[1];
F_PROFILE(f, thread, nv) = uABL / k*log((y - yNold) / y0); /* translated velocity profile */
}
end_f_loop(f,thread)
}
--------------------------------------------------------------------------

When trying to compile it, I get the following message in Fluent:

---------------------------------------------------------------------
Copied C:\Dawie\Meesters\CFD Werk\UDF_Compile_Toets\UDF_Compile-Toets_files\dp0\FLU-2\Fluent\VelProf_Translated.c to libudf\src
udf_names.c and user_nt.udf files in 2ddp_host are upto date.
(system "copy "C:\PROGRA~1\ANSYSI~1\v150\fluent"\fluent15.0.0\sr c\makefile_nt.udf "libudf\win64\2ddp_host\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\2ddp_host")# Generating ud_io1.h
VelProf_Translated.c
..\..\src\VelProf_Translated.c(42) : error C2143: syntax error : missing ';' before '/'
..\..\src\VelProf_Translated.c(42) : error C2143: syntax error : missing ')' before ';'
..\..\src\VelProf_Translated.c(42) : error C2100: illegal indirection
..\..\src\VelProf_Translated.c(42) : error C2059: syntax error : ')'
udf_names.c and user_nt.udf files in 2ddp_node are upto date.
(system "copy "C:\PROGRA~1\ANSYSI~1\v150\fluent"\fluent15.0.0\sr c\makefile_nt.udf "libudf\win64\2ddp_node\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\2ddp_node")# Generating ud_io1.h
VelProf_Translated.c
..\..\src\VelProf_Translated.c(42) : error C2143: syntax error : missing ';' before '/'
..\..\src\VelProf_Translated.c(42) : error C2143: syntax error : missing ')' before ';'
..\..\src\VelProf_Translated.c(42) : error C2100: illegal indirection
..\..\src\VelProf_Translated.c(42) : error C2059: syntax error : ')'

Done.
-------------------------------------------------------------------------

I would appreciate it if anyone can help me with the syntax error that I am getting!

Thanks!
Ratel is offline   Reply With Quote

Old   June 18, 2014, 08:52
Default
  #2
New Member
 
Dawie Marais
Join Date: Jan 2014
Posts: 6
Rep Power: 12
Ratel is on a distinguished road
Line 42 is the line where the profile is being defined:
F_PROFILE(f, thread, nv) = uABL / k*log((y - yNold) / y0); /* translated velocity profile */
Ratel is offline   Reply With Quote

Old   June 18, 2014, 09:19
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
The problem is in your #defines:
Code:
#define uABL 0.2674; /* Atmospheric BL friction velocity */
#define k 0.41;	 /* Von Karman constant */
#define y0 4.6875E-4;; /* Aerodynamic roughness length */
Remove the semicolons there:
Code:
#define uABL 0.2674 /* Atmospheric BL friction velocity */
#define k 0.41	 /* Von Karman constant */
#define y0 4.6875E-4 /* Aerodynamic roughness length */
pakk is offline   Reply With Quote

Old   June 18, 2014, 13:26
Default
  #4
New Member
 
Dawie Marais
Join Date: Jan 2014
Posts: 6
Rep Power: 12
Ratel is on a distinguished road
Thank you very much pakk, your advice solved my problem!

Kind Regards
Ratel is offline   Reply With Quote

Old   May 23, 2015, 06:15
Default
  #5
New Member
 
jyothsna k
Join Date: May 2014
Posts: 18
Rep Power: 12
jyothsna k is on a distinguished road
Thank you very much
jyothsna k 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
Compile calcMassFlowC aurore OpenFOAM Programming & Development 13 March 23, 2018 08:43
[OpenFOAM] Native ParaView Reader Bugs tj22 ParaView 270 January 4, 2016 12:39
[swak4Foam] GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh gschaider OpenFOAM Community Contributions 300 October 29, 2014 19:00
Compiling dynamicTopoFvMesh for OpenFOAM 2.1.x Saxwax OpenFOAM Installation 25 November 29, 2013 06:34
UDF: DEFINE_CG_MOTION for vertical jump motion of an electrode! alban Fluent UDF and Scheme Programming 2 June 8, 2010 19:54


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