CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF error concerning math.h (http://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 10: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 15: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 05:20

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

jipaz November 19, 2013 17: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 11: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 11: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 07: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 20:50

Thank you trollreign, thank you very much!


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