CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF error concerning math.h (https://www.cfd-online.com/Forums/fluent-udf/125428-udf-error-concerning-math-h.html)

KITetima October 25, 2013 05:44

UDF error concerning math.h
 
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.

trollreign October 27, 2013 09:30

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 October 27, 2013 14:56

Have to replace math.h
 
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.

KITetima October 28, 2013 04:20

Thank you. You have solved my problem with this math.h error !

jipaz November 19, 2013 16:31

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.

wayuu1981 December 2, 2013 10:04

It worked !!!
 
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 December 2, 2013 10:27

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.

piprus January 23, 2014 06:42

Can I ask anyone of you to share with me just a math.h file from VS2010?

Junphy May 30, 2014 22:59

Quote:

Originally Posted by piprus (Post 471386)
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

Ratel June 17, 2014 06:39

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 June 18, 2014 02:11

1 Attachment(s)
Attached is the math.h file from VS2010 should anyone need it- it works very well indeed!

p36288 July 29, 2014 12:30

udf math.h error on visual studio 2013
 
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.

mugurg February 21, 2015 19:50

Thank you trollreign, thank you very much!

shereez234 November 2, 2015 13:05

I just love you all :D The replacement of math header file in vs2012 with vs2010 was the solution for my problems too.

uday_joshi August 6, 2016 06:46

Thanks to help in compiling UDF in Fluent
 
Dear Friends..

Thank you all so much....

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

You all made my Day....!!:):D

homalekpour May 4, 2017 09:31

Thank you very much guy. Your solution saved my life:)

pakk May 5, 2017 08:46

Quote:

Originally Posted by homalekpour (Post 647646)
Thank you very much guy. Your solution saved my life:)

Now you made me very curious how your life was in danger... ;)

VishnuME17 May 14, 2017 05:20

Thank You very much trollreign, it worked!!!
But after loading I am receiving error 193. Please give me a way

mahmoud.alaa January 26, 2018 20:34

Thank you very much!:)

daniel_pramudita February 16, 2018 14:34

This code modification is the solution!
 
Quote:

Originally Posted by p36288 (Post 503620)
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


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