How to compile fluent udf on win64 (Simple and Step by Step)
Compiling udf could be quite tricky due to the details that could be caused possible errors. On the other, for many simulations, udfs are essential. Udfs provide flexibility and are powerful tools. Unfortunately, compiling udfs for the first time, could be challenging. Many small details are in in fact should be remembered so that finally compiling process be successful. Here, we are providing most of the points that you have to do for compiling to be successful.
1- You have to install Visual Studio. I used Visual Studio 2010. But you can try other version too. Visual Studio needed because it contains C++ compiler. Udfs are C files which C++ compiler can compile them.
2- Install fluent if you do not have it. Any particular version of Fluent can be used.
3- Define environment variable for fluent.exe so that it can be run from command prompt in any directory. For doing this, go to the start, type “Edit system environment variables”. In opened windows click on “Environment variables”. This windows contains two parts. In both of them, find “path” in the variables column and then click edit. In new windows click “new” and then past the address of folder which contains fluent.exe. In my case the address is “C:Program FilesAN’SYS Incv145fluentntbinwin64”. Then press OK. Do same process for the “System variables” too.
4- Now, make a new folder in arbitrary place. Put your cas and udf file there.
5- Go to start, find Visual Studio folder, find “Visual Studio x64 cross tools” and click on.
6- Navigate to the folder that contains cas and udf file. You can use command “cd” to navigate.
7- Once you are in folder, type fluent and press enter. Now, fluent must start.
8- Load you cas file. After that, from menu go to “Define>User-Defined>Function>Compiled”. Now click on add and select your udf. After that click on Build. After building finish, click on load. If everything is fine, you should not warned any error. Following images shows the successful compiling and load.
If you get any errors and you could not compile the udf successfully, do not worry, because it could be related to following details. So, consider following notes.
1- The extension of udf file is “c” not “C”. So, if your udf file extension is capital c change it to small c.
2- Remember that there should be no space between Define Macro and parenthesis. I mean it should not be like this: “DEFINE_CG_MOTION (piston1,dt,vel,omega,time,dtime)”
3- Before using your main udf, consider using following simple udf, to make sure your udf typos error does not the main reasons for compiling error.
DEFINE_CG_MOTION(piston1,dt,vel,omega,time,dtime)
{
vel[0] = 0.0;
vel[1] = 0.01;
}
4- If you compiled your udf successfully and now you want to change it and compile it again, remember to clean “udflib” folder that generated during previous compiling. For doing this, you need to first close the fluent and then delete the udflib folder.
If you follow everything and you still have problems, do not hesitate to contact us ([email protected])! We will be happy to help you.
Altayrd Tech
برچسب:
نویسنده: سجاد مهدوی