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/)
-   -   math.h: no such file or directory SOS!SOS! (https://www.cfd-online.com/Forums/fluent-udf/200130-math-h-no-such-file-directory-sos-sos.html)

yanghai March 25, 2018 07:17

math.h: no such file or directory SOS!SOS!
 
Dear all:

when i load the udf, there will be occur:math.h :no such file or directory. the fluent is fluent 16.0.and visual studio is belong to 2010.
i have install and uninstall the fluent and visual studio many times, but it doesn't work. anyone know it ? It's been bothering me for a long time.

nepomnyi December 22, 2019 18:48

The same problem!
 
I have the same problem. I use ANSYS 2019R2 on Windows10. I've written a simple UDF, I included math.h. I launched the interpreter. It says the following: "math.h: No such file or directory".


So, I join the question of the author of this post: if anybody knows how to solve it, please, share the solution.


Thank you very much in advance.


Ivan

AlexanderZ December 22, 2019 23:00

ВАНЯ, compile your code

nepomnyi December 23, 2019 17:24

Thank you very much Alexander. With your hint, I've managed to launch my UDF (though, not the way you suggested).


For those experiencing the problem with math.h file, I'd like to describe my problem and show how I solved it.


1) Description of my simulation.
I'm simulating a 3-D water-air flow in a vertical round pipe. I am using ANSYS FLUENT 2019R2 on Windows 10. I am not using visual studio. Any manipulations with UDFs (loading/unloading, compiling and so on) I am doing using FLUENT window (in workbench: Setup -> User-Defined -> Functions).
My pipe has a constant velocity water inlet at the bottom, constant pressure outlet at the top, time dependent air velocity inlet at the side (i.e., gas is being supplied through a horizontal pipe adjacent to the main vertical pipe near the bottom of the vertical pipe).


2) Description of my UDF with which I experienced problems.

For a time dependent gas velocity inlet I've written a UDF. I wanted my time dependent gas velocity obey a sin law. That is why I had to introduce a sin function to my code. I read in the Internet that if I have a sin function in the code, I must include math.h header file. I did that. I also used PI constant which is specified in the code as M_PI. Here's my code with math.h:


#include "udf.h"
#include "math.h"


DEFINE_PROFILE(unsteady_velocity, thread, position)
{
face_t f;
real t = CURRENT_TIME;

begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) = -0.15 * ( 1 + sin(t+3*M_PI/2.00) );
}
end_f_loop(f, thread)
}


3) Description of the problem.
First I tried to interpret my UDF. That didn't work. ANSYS showed me an error that it can't find math.h file.
I don't know what "interpret a UDF" means in ANSYS because C is not an interpreted language, it is a compiled language.



4) Solution of the problem.
It appears to be that if I include "udf.h" header file, I can freely use sin function and I don't need to include "math.h" header file. I did not check if the same is true for the PI constant M_PI - instead I just changed the M_PI constant to "3.14" because it was not crucial for me.
It appears to be that if I have "udf.h" header file only and I don't have other header files such as "math.h", I can interpret my UDF. Otherwise, I have to compile it as AlexanderZ suggested.
So, I tried to compile my UDF with both "math.h" and "M_PI" in it. I failed. I got an error. But apparently, I couldn't compile it because of my computer. Namely, I used my university network. But if one wants to compile a UDF he should do it on his computer's hard drive. Also, I have some other computer problems which I didn't try to understand.
My solution. 1) I changed "M_PI" to "3.14". 2) I deleted "math.h" because "udf.h" can easily handle sin function. 3) I interpreted my UDF. 4) Just for a case I place my UDF to the case and data folder <your project name>_files --> dp0 --> FFF --> Fluent. My resultant working code is:


#include "udf.h"

DEFINE_PROFILE(unsteady_velocity, thread, position)
{
face_t f;
real t = CURRENT_TIME;

begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) = -0.15 * ( 1 + sin(t+3*3.14/2.00) );
}
end_f_loop(f, thread)
}


5) Conclusions.
- If you have problems with math.h try to delete it and go just with udf.h. Interpret your UDF - don't compile it. It worked in my case.
- If you still have to use math.h, then you need to compile your code. Compiling can be a challenge (I failed to compile my UDF eventually). Some things you need to do to compile a UDF. 1) Bring your project to your local hard drive - it shouldn't be stored on a cloud or on your enterprise network. 2) Put your UDF code into <your project name>_files --> dp0 --> FFF --> Fluent - this is a directory where your case and data files are stored.


Ivan

AlexanderZ December 24, 2019 00:34

the only way to solve problem with math.h is to compile UDF
of course, no math.h - no problem


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