Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

How can we run the UDF codes in the Visual Studio Code.

    • Xbuddyin
      Subscriber

      Dear Friends,

      I would like to write the program for my project using the UDF in Ansys 18.1. Generally,

      I write the c program in the notepad++ and interpret using the function> interpreted> browse (upload my c file)> click on interpret. If everything works fine it shows me the link of path link in the TUI of Ansys.

      cpp -I"C:PROGRA~1ANSYSI~1v181fluentfluent18.1.0/src/main" -

      ..

      ..

      ..

      -I"C:PROGRA~1ANSYSI~1v181fluentfluent18.1.0/cortex/src" -I"C:PROGRA~1ANSYSI~1v181fluentfluent18.1.0/client/src" -I"C:PROGRA~1ANSYSI~1v181fluentfluent18.1.0/multiport/src" -I. -DUDFCONFIG_H="" "C:/Users/XXXX/Desktop/XXXbox/1/XXXXSimulation/xxxxx/Simulation/Run05examp/XXXX_UDF.c"

      I moved forward to add this UDF into the boundary conditions. Can we use both compile and interpret functions in Ansys for any User-defined C program?

      A. When I used the compiled for the c program then I just use function> compiled>add (source fuel)> build> load (is it the right way ). Do I need to add something in header files too? Do we need to create a different library for each program?

      B. Can we use the visual studio code instead of the visual studio? will it make difference? I am using the latest visual studio code V1.63.2 available? I have installed already Code Runner and Mingw for the C compilation.

    • Rob
      Forum Moderator
      Most UDFs can be interpreted and all can be compiled. There are a few macros that require compilation. To use the compilers in Fluent they need setting up, but also that you have all the correct versions and components for that version of Fluent. As Microsoft keep moving things and changing what's available we've added a CLANG compiler into Fluent at 2020Rx : I recommend updating as R18 is now about to be 5 versions out of date.
    • Amine Ben Hadj Ali
      Ansys Employee
      Please update the software you are using.
      Compiling requires a compiler. Release 18 is quite old and you require there a VS compiler. If you cannot move to a newer version and you cannot install VS Compiler (you need to go the documentation and check which VS studio was officially supported there and hope that you can download it and use it) then work on Linux System.
    • Xbuddyin
      Subscriber
      I will ask for an update from my office, Meanwhile any comment on this: Can we use the visual studio code instead of the visual studio? will it make difference? I am using the latest visual studio code V1.63.2 available? I have installed already Code Runner and Mingw for the C compilation. When I tried to run the same program using the visual studio code it gives me the following error about the storage class, invalid preprocessing directive, and error on the expected identifier. I tried to check many online solutions, I am not getting well my answer how can we fix this? I am not sure How can we get #include UDF.h directive for the visual studio code. Can we run the code in the visual studio code and then compile into the fluent it will be bit easy for large program.


    • Rob
      Forum Moderator
      It is possible to cobble bits of compilers together to then compile code for Fluent, but how that's done isn't something I can discuss on here: I'm not allowed to and also don't know how it's done.
      As suggests 2021R2 and shortly 2022R1 are the better option as they have built in compilers. The problem is not so much with Fluent in the older versions but in the way the Microsoft compilers are installed and set up.
Viewing 4 reply threads
  • The topic ‘How can we run the UDF codes in the Visual Studio Code.’ is closed to new replies.