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

UDF error concerning math.h

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

Like Tree17Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 25, 2013, 05:44
Unhappy UDF error concerning math.h
  #1
New Member
 
Marie
Join Date: Oct 2013
Location: Knk
Posts: 24
Rep Power: 12
KITetima is on a distinguished road
Hi,

I compiled my UDF on fluent v145 and I have got this error concerning math.h

However in my header I donīt add math.h (I have tried with and I have no changes). I have also download a new math.h file and remplace it in my ansys\v145\....\src\math.h file.

Copied C:\Users\urdfa\Desktop\UDF essai\25_10_files\dp0\FFF\MECH/C:\Users\urdfa\Desktop\UDF essai\25_10_files\dp0\FFF\MECH\vitesse.c to libudf\src
Copied C:\Program Files\ANSYS Inc\v145\fluent\fluent14.5.0\src\udf.h to libudf\src
************************************************** ************************
** NOTE: user_nt.udf file is outdated. So, recreating the file for 2d ...
************************************************** ***********************
(system "copy "C:\PROGRA~1\ANSYSI~1\v145\fluent"\fluent14.5.0\sr c\makefile_nt.udf "libudf\win64\2d\makefile" ")
1 Datei(en) kopiert.
(chdir "libudf")()
(chdir "win64\2d")()
# Generating ud_io1.h
vitesse.c
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: Syntaxfehler: ','
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2143: Syntaxfehler: Es fehlt ')' vor 'Konstante'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2143: Syntaxfehler: Es fehlt '{' vor 'Konstante'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: Syntaxfehler: 'Konstante'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: Syntaxfehler: ')'


I also add my UDF Perharps the error comes from my UDF, but I have found no error with Visual Studio)


/************************************************** *********************
vprofile.c
UDF for specifying steady-state velocity profile boundary condition
************************************************** **********************/
#include "udf.h"

DEFINE_PROFILE(x_velocity,thread,position)
{
real x[ND_ND]; /* this will hold the position vector */
real y;
face_t f;

begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x[1];
F_PROFILE(f, thread, position) = 5;
}
end_f_loop(f, thread)
}


Thank you in advance for any idea concerning my issue.
KITetima is offline   Reply With Quote

Old   October 27, 2013, 09:30
Default
  #2
New Member
 
Laszlo A.
Join Date: Oct 2013
Location: Bristol, UK
Posts: 4
Blog Entries: 1
Rep Power: 12
trollreign is on a distinguished road
I am trying the exact same thing and I am getting the same error.

My UDF is pretty similar to yours, I am trying to implement a user-defined velocity profile on my boundary using an UDF. When I try to compile it, it gives the same errors with the math.h file located in Visual Studio 12.

Done.
Deleted old libudf\win64\2d\libudf.dll
1 file(s) copied.
Copied J:\CFD\004_vertflow\velocity_profile.c to libudf\src
(system "copy "C:\PROGRA~1\ANSYSI~1\v140\fluent"\fluent14.0.0\sr c\makefile_nt.udf "libudf\win64\2d\makefile" ")
1 file(s) copied.
(chdir "libudf")()
(chdir "win64\2d")()
# Generating ud_io1.h
velocity_profile.c
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: syntax error : ','
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2143: syntax error : missing ')' before 'constant'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2143: syntax error : missing '{' before 'constant'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: syntax error : 'constant'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: syntax error : ')'

Done.



Further information for those trying to help.
1. I also tried to get a math.h file from the internet and load it as a header file on the right of the screen. This way it also gave the same errors from the math.h file located in the Visual Studio 12 folder's VC library, AND in addition some errors from the other math.h header file I attached. In any case, it looks for the math.h file of VS12, whether you attached it or not.

2. Visual Studio 12 is actually the Microsoft Visual Studio 2013 Express that Microsoft released recently. Is it possible that their math.h file is simply wrong? Or that it is not compatible with Fluent 14.0 for some reason?

3. If I try to load the profile after building it with errors, I get the following error message:

The UDF library you are trying to load (libudf) is not compiled for 2d on the curent platform (win64).
The system cannot find the file specified.

J:\CFD\004_vertflow\libudf\win64\2d\libudf.dll



So it seems that the .dll file was not created. Somehow the dll should be linked but it isn't.
In a video on YouTube I saw that the right message Fluent should give would be: http://www.youtube.com/watch?v=rT3a-Lu7LI4
trollreign is offline   Reply With Quote

Old   October 27, 2013, 14:56
Default Have to replace math.h
  #3
New Member
 
Laszlo A.
Join Date: Oct 2013
Location: Bristol, UK
Posts: 4
Blog Entries: 1
Rep Power: 12
trollreign is on a distinguished road
After several hours I found a solution to the problem.

So my setup is:
- Windows 8.1 x64
- ANSYS v140 x64
- Microsoft Visual Studio 2013 Express (which is the same as Microsoft Visual Studio 12)
- Microsoft Windows Software Development Kit (SDK) 8.1
- Microsoft .NET Framework 4.5.1

The environmental variables were set, I ran Fluent from the command prompt properly with x64, the compiler was specified. The above problem occurred (see KITetima' post) at compilation.

Solution:
1. In addition to above mentioned software, install Microsoft Visual C++ Express 2010.
2. Copy the math.h file from
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include
to
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
(this is with standard installation folders)
3. Start Fluent from the VS2013 x64 Cross Tools Command Prompt. If you go to the Start screen (windows key on the keyboard) and type "Visual Studio Tools" you will find this command prompt in that folder.

Note that starting fluent from the command prompt of Visual Studio 2010 will not work, you need a 64 bit environment (x64)

Hope this helps.
trollreign is offline   Reply With Quote

Old   October 28, 2013, 04:20
Default
  #4
New Member
 
Marie
Join Date: Oct 2013
Location: Knk
Posts: 24
Rep Power: 12
KITetima is on a distinguished road
Thank you. You have solved my problem with this math.h error !
KITetima is offline   Reply With Quote

Old   November 19, 2013, 16:31
Default
  #5
New Member
 
Join Date: Aug 2012
Posts: 22
Rep Power: 13
jipaz is on a distinguished road
Lazlo and Marie, its seems Ansys Fluent is not compatible with last version of MSVS. I'm using Ansys Fluent 12.1 and I solved the same problem just copying math.h from:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include
to
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include

and now Fluent in compiling my UDF properly. Regards.
jipaz is offline   Reply With Quote

Old   December 2, 2013, 10:04
Default It worked !!!
  #6
New Member
 
J.G.E.
Join Date: Oct 2013
Posts: 2
Rep Power: 0
wayuu1981 is on a distinguished road
Man, God Bless you !! I had this problem for a long time with no solution, I tried all version of Visual Studio and nothing worked, but now you saved my life !!!

Thanks again ...
jipaz likes this.
wayuu1981 is offline   Reply With Quote

Old   December 2, 2013, 10:27
Default
  #7
New Member
 
Join Date: Aug 2012
Posts: 22
Rep Power: 13
jipaz is on a distinguished road
Because of I'm using Ansys Fluent 12.1, I had to edit the udf.bat file to indicate to Fluent has to use MSVS 12, maybe if you're using a later Fluent release, you don't have to do this.

Regards.
jipaz is offline   Reply With Quote

Old   January 23, 2014, 06:42
Default
  #8
Member
 
Piotr Prusinski
Join Date: Oct 2009
Location: Warsaw, Poland
Posts: 67
Rep Power: 16
piprus is on a distinguished road
Can I ask anyone of you to share with me just a math.h file from VS2010?
lleite likes this.
piprus is offline   Reply With Quote

Old   May 30, 2014, 22:59
Default
  #9
New Member
 
Junphy Liues
Join Date: Apr 2014
Posts: 9
Rep Power: 12
Junphy is on a distinguished road
Quote:
Originally Posted by piprus View Post
Can I ask anyone of you to share with me just a math.h file from VS2010?
This can also work well, I just tried it
Junphy is offline   Reply With Quote

Old   June 17, 2014, 06:39
Default
  #10
New Member
 
Dawie Marais
Join Date: Jan 2014
Posts: 6
Rep Power: 12
Ratel is on a distinguished road
Hi guys,

Would it be possible to please share a math.h file from VS2010 on this thread? I also have the same problem but I am having trouble installing VS2010 due to proxy issues.

Thanks!
Ratel is offline   Reply With Quote

Old   June 18, 2014, 02:11
Default
  #11
New Member
 
Dawie Marais
Join Date: Jan 2014
Posts: 6
Rep Power: 12
Ratel is on a distinguished road
Attached is the math.h file from VS2010 should anyone need it- it works very well indeed!
Attached Files
File Type: h math.h (23.2 KB, 499 views)
p36288, moghimi64, lleite and 3 others like this.
Ratel is offline   Reply With Quote

Old   July 29, 2014, 12:30
Default udf math.h error on visual studio 2013
  #12
New Member
 
WangLei
Join Date: Mar 2011
Posts: 2
Rep Power: 0
p36288 is on a distinguished road
In Visual Studio 2013, I found Line 482 in the math.h:
Code:
_CRTIMP double __cdecl cbrt(_In_ double _X);
makes the math.h error happen.
delete it or wrap with /**/, the error C2059 and C2143 would disappear, then you need not copy another math.h file.
I have no idea what's wrong with this code.
p36288 is offline   Reply With Quote

Old   February 21, 2015, 19:50
Default
  #13
New Member
 
Ugur Goktolga
Join Date: Jul 2013
Posts: 4
Rep Power: 12
mugurg is on a distinguished road
Thank you trollreign, thank you very much!
mugurg is offline   Reply With Quote

Old   November 2, 2015, 13:05
Default
  #14
Senior Member
 
shereez234's Avatar
 
M Sereez
Join Date: Jan 2014
Location: England
Posts: 352
Blog Entries: 1
Rep Power: 13
shereez234 is on a distinguished road
I just love you all The replacement of math header file in vs2012 with vs2010 was the solution for my problems too.
shereez234 is offline   Reply With Quote

Old   August 6, 2016, 06:46
Thumbs up Thanks to help in compiling UDF in Fluent
  #15
New Member
 
uday joshi
Join Date: Aug 2016
Posts: 1
Rep Power: 0
uday_joshi is on a distinguished road
Dear Friends..

Thank you all so much....

I was messed since long in compilation issue.....

You all made my Day....!!
uday_joshi is offline   Reply With Quote

Old   May 4, 2017, 09:31
Default
  #16
New Member
 
Ahmad
Join Date: May 2017
Posts: 1
Rep Power: 0
homalekpour is on a distinguished road
Thank you very much guy. Your solution saved my life
homalekpour is offline   Reply With Quote

Old   May 5, 2017, 08:46
Default
  #17
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by homalekpour View Post
Thank you very much guy. Your solution saved my life
Now you made me very curious how your life was in danger...
pakk is offline   Reply With Quote

Old   May 14, 2017, 05:20
Default
  #18
New Member
 
Sai Vishnu Vardhan Kopalli
Join Date: May 2017
Posts: 1
Rep Power: 0
VishnuME17 is on a distinguished road
Thank You very much trollreign, it worked!!!
But after loading I am receiving error 193. Please give me a way
VishnuME17 is offline   Reply With Quote

Old   January 26, 2018, 20:34
Default
  #19
New Member
 
Mahmoud alaa
Join Date: Feb 2016
Posts: 1
Rep Power: 0
mahmoud.alaa is on a distinguished road
Thank you very much!
mahmoud.alaa is offline   Reply With Quote

Old   February 16, 2018, 14:34
Default This code modification is the solution!
  #20
New Member
 
Join Date: Jan 2018
Posts: 12
Rep Power: 8
daniel_pramudita is on a distinguished road
Quote:
Originally Posted by p36288 View Post
In Visual Studio 2013, I found Line 482 in the math.h:
Code:
_CRTIMP double __cdecl cbrt(_In_ double _X);
makes the math.h error happen.
delete it or wrap with /**/, the error C2059 and C2143 would disappear, then you need not copy another math.h file.
I have no idea what's wrong with this code.
Hi all,

I was having the same trouble when trying to compile the UDF in Fluent 13. My OS is Windows 10, and I open Fluent using the x64 Native Tools Command Prompt for MS Visual Studio 2017 (yes, the latest).
In my case, the same error was found in file "corecrt_math.h", which is in the folder (and subfolders) of Windows Kits (in Program Files (x86)), not directly in the any MS Visual Studio subfolders. I guess it's just how the structure is in Windows 10.
Anyway, this guy's suggestion really saved me a lot of time and disc space . No need to install any older version of VS, and just modify the codes.

Cheers!
Daniel
daniel_pramudita is offline   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
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 07:37
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 22:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 21:38
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 04:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 04:01


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