CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

The simplest way to debug Fluent UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes
  • 1 Post By gearboy
  • 6 Post By eeroi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 9, 2018, 22:16
Default The simplest way to debug Fluent UDF
  #1
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Debugging Fluent UDF is always the pain point for users. Intermediate variables can't be inspected and the source can't be traced step by step. User's progress remains stagnant especially because of inexplicable errors. Here, we recommend a UDF debugging tool that can directly inspect intermediate variables and trace the UDF source step by step.

https://vcudfstudio.bitbucket.io/dow...uent%20UDF.pdf
Oula likes this.
gearboy is offline   Reply With Quote

Old   October 5, 2019, 05:11
Default
  #2
New Member
 
Join Date: Oct 2019
Posts: 3
Rep Power: 7
eeroi is on a distinguished road
Quote:
Originally Posted by gearboy View Post
Debugging Fluent UDF is always the pain point for users. Intermediate variables can't be inspected and the source can't be traced step by step. User's progress remains stagnant especially because of inexplicable errors. Here, we recommend a UDF debugging tool that can directly inspect intermediate variables and trace the UDF source step by step.

https://vcudfstudio.bitbucket.io/dow...uent%20UDF.pdf
The simplest way? Really? How much is it then? I am sick of these marketing gimmicks.

For those of you who would prefer not to pay for shady additional software and would like to keep information free, I am proposing the following following GENUINELY-FREE-OF-CHARGE approach, which I find even simpler than your FREE-TO-TRY slash GIVE-ME-YOUR-MONEY solution:

- Remember to back original files up before you make any changes.

- Change the makefile template makefile_nt.udf (in one of the Fluent installation folders):

CFLAGS = /c /Za /Zi /DUDF_EXPORTING /DUDF_NT /DWIN64 /EHa /wd4224

link $(LIBS) /dll /debug /assemblydebug /out:$(TARGET)

In words, you add the compiler flag /Zi and linker flags /debug /assemblydebug, nothing else. These options generate the program database (.pdb) files that you'll later find in the binary output folders.

- Compile the UDF code in Fluent GUI and load the libudf library. This seems to be the best (most stable and universal) approach for compilation these days, earlier you had to run nmake in command prompt.

- Open the source file in the "libudf/src" folder in Visual Studio (a free Express version will do fine).

- In Visual Studio, attach the code to fl_mpi1950.exe (Fluent 2019R3). This works in serial mode, in parallel you may have to attach to all Fluent processes (haven't used in years, don't remember anymore). You should see debug symbols loaded in VS.

- Try adding a breakpoint on a code row. The red circle on the left hand side should be filled, if the attach was successful.

- When you run the simulation, whenever the code with the breakpoint is called within Fluent, you should now break in Visual Studio and be able to see the variable content and track program flow. Please see https://ibb.co/K2pPh6K for a screenshot.

No need to extend your wallet.



Cheers, Eero
pakk, JohnE, qwebean and 3 others like this.

Last edited by eeroi; October 6, 2019 at 04:35.
eeroi is offline   Reply With Quote

Old   October 9, 2019, 00:05
Default
  #3
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Please do not disparage a car just because you have a pair of muscular legs. Not everyone master or prefer "Marathon" like you. Quite a few people enjoy the convenience even if cars "extend their wallet".


Quote:
Originally Posted by eeroi View Post
The simplest way? Really? How much is it then? I am sick of these marketing gimmicks.

For those of you who would prefer not to pay for shady additional software and would like to keep information free, I am proposing the following following GENUINELY-FREE-OF-CHARGE approach, which I find even simpler than your FREE-TO-TRY slash GIVE-ME-YOUR-MONEY solution:

- Remember to back original files up before you make any changes.

- Change the makefile template makefile_nt.udf (in one of the Fluent installation folders):

CFLAGS = /c /Za /Zi /DUDF_EXPORTING /DUDF_NT /DWIN64 /EHa /wd4224

link $(LIBS) /dll /debug /assemblydebug /out:$(TARGET)

In words, you add the compiler flag /Zi and linker flags /debug /assemblydebug, nothing else. These options generate the program database (.pdb) files that you'll later find in the binary output folders.

- Compile the UDF code in Fluent GUI and load the libudf library. This seems to be the best (most stable and universal) approach for compilation these days, earlier you had to run nmake in command prompt.

- Open the source file in the "libudf/src" folder in Visual Studio (a free Express version will do fine).

- In Visual Studio, attach the code to fl_mpi1950.exe (Fluent 2019R3). This works in serial mode, in parallel you may have to attach to all Fluent processes (haven't used in years, don't remember anymore). You should see debug symbols loaded in VS.

- Try adding a breakpoint on a code row. The red circle on the left hand side should be filled, if the attach was successful.

- When you run the simulation, whenever the code with the breakpoint is called within Fluent, you should now break in Visual Studio and be able to see the variable content and track program flow. Please see https://ibb.co/K2pPh6K for a screenshot.

No need to extend your wallet.



Cheers, Eero
gearboy is offline   Reply With Quote

Old   October 10, 2019, 00:45
Default
  #4
New Member
 
Join Date: Oct 2019
Posts: 3
Rep Power: 7
eeroi is on a distinguished road
Quote:
Originally Posted by gearboy View Post
Please do not disparage a car just because you have a pair of muscular legs. Not everyone master or prefer "Marathon" like you. Quite a few people enjoy the convenience even if cars "extend their wallet".
Marathon? You do not want to engage in this discussion. The procedure I described takes me 20 seconds to complete. A first-timer might spend 5 minutes on it, searching for the right files, compile/load/attach buttons in Fluent and Visual Studio. How is that for simplicity? Installing your software and following the pdf instructions takes more time.

What really bothers me is that you pretend to be helpful while promoting your commercial stuff. Nothing wrong with being a vendor, but you should say it openly.

Forum rules (I quote):

State your affiliation explicitly in your message if you:
Recommend a product sold by your employer.
Write bad things about a product and you are employed by a company selling similar products.

Forbidden content:
Advertising, both commercial and personal
eeroi is offline   Reply With Quote

Old   October 10, 2019, 01:43
Default
  #5
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Quote:
Originally Posted by eeroi View Post
Marathon? You do not want to engage in this discussion. The procedure I described takes me 20 seconds to complete. A first-timer might spend 5 minutes on it, searching for the right files, compile/load/attach buttons in Fluent and Visual Studio. How is that for simplicity? Installing your software and following the pdf instructions takes more time.

What really bothers me is that you pretend to be helpful while promoting your commercial stuff. Nothing wrong with being a vendor, but you should say it openly.

Forum rules (I quote):

State your affiliation explicitly in your message if you:
Recommend a product sold by your employer.
Write bad things about a product and you are employed by a company selling similar products.

Forbidden content:
Advertising, both commercial and personal
That's our fault. Sorry. We should show this is an advertisement in the title. Whether it is helpful or not depends on users. Sorry to make you angry.
gearboy is offline   Reply With Quote

Old   October 10, 2019, 03:00
Default
  #6
New Member
 
Join Date: Oct 2019
Posts: 3
Rep Power: 7
eeroi is on a distinguished road
Quote:
Originally Posted by gearboy View Post
That's our fault. Sorry. We should show this is an advertisement in the title. Whether it is helpful or not depends on users. Sorry to make you angry.
Why not edit the initial post to clearly state your commercial aims then?
eeroi is offline   Reply With Quote

Old   October 10, 2019, 03:21
Default
  #7
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Quote:
Originally Posted by eeroi View Post
Why not edit the initial post to clearly state your commercial aims then?
The forum doesn't allow editing or deleting for topic with a long histroy, only allowing reply. It was posted long time ago.
gearboy is offline   Reply With Quote

Old   August 10, 2020, 10:08
Smile
  #8
New Member
 
Rodolfo
Join Date: Jun 2020
Location: Brazil
Posts: 2
Rep Power: 0
rodolfolondero is on a distinguished road
Hello, could you provide the screenshots of the step-by-step procedure, please?

Quote:
Originally Posted by eeroi View Post
The simplest way? Really? How much is it then? I am sick of these marketing gimmicks.

For those of you who would prefer not to pay for shady additional software and would like to keep information free, I am proposing the following following GENUINELY-FREE-OF-CHARGE approach, which I find even simpler than your FREE-TO-TRY slash GIVE-ME-YOUR-MONEY solution:

- Remember to back original files up before you make any changes.

- Change the makefile template makefile_nt.udf (in one of the Fluent installation folders):

CFLAGS = /c /Za /Zi /DUDF_EXPORTING /DUDF_NT /DWIN64 /EHa /wd4224

link $(LIBS) /dll /debug /assemblydebug /out:$(TARGET)

In words, you add the compiler flag /Zi and linker flags /debug /assemblydebug, nothing else. These options generate the program database (.pdb) files that you'll later find in the binary output folders.

- Compile the UDF code in Fluent GUI and load the libudf library. This seems to be the best (most stable and universal) approach for compilation these days, earlier you had to run nmake in command prompt.

- Open the source file in the "libudf/src" folder in Visual Studio (a free Express version will do fine).

- In Visual Studio, attach the code to fl_mpi1950.exe (Fluent 2019R3). This works in serial mode, in parallel you may have to attach to all Fluent processes (haven't used in years, don't remember anymore). You should see debug symbols loaded in VS.

- Try adding a breakpoint on a code row. The red circle on the left hand side should be filled, if the attach was successful.

- When you run the simulation, whenever the code with the breakpoint is called within Fluent, you should now break in Visual Studio and be able to see the variable content and track program flow. Please see https://ibb.co/K2pPh6K for a screenshot.

No need to extend your wallet.



Cheers, Eero
rodolfolondero is offline   Reply With Quote

Old   August 5, 2021, 06:42
Default
  #9
New Member
 
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5
cudau.95 is on a distinguished road
Quote:
Originally Posted by eeroi View Post
The simplest way? Really? How much is it then? I am sick of these marketing gimmicks.

For those of you who would prefer not to pay for shady additional software and would like to keep information free, I am proposing the following following GENUINELY-FREE-OF-CHARGE approach, which I find even simpler than your FREE-TO-TRY slash GIVE-ME-YOUR-MONEY solution:

- Remember to back original files up before you make any changes.

- Change the makefile template makefile_nt.udf (in one of the Fluent installation folders):

CFLAGS = /c /Za /Zi /DUDF_EXPORTING /DUDF_NT /DWIN64 /EHa /wd4224

link $(LIBS) /dll /debug /assemblydebug /out:$(TARGET)

In words, you add the compiler flag /Zi and linker flags /debug /assemblydebug, nothing else. These options generate the program database (.pdb) files that you'll later find in the binary output folders.

- Compile the UDF code in Fluent GUI and load the libudf library. This seems to be the best (most stable and universal) approach for compilation these days, earlier you had to run nmake in command prompt.

- Open the source file in the "libudf/src" folder in Visual Studio (a free Express version will do fine).

- In Visual Studio, attach the code to fl_mpi1950.exe (Fluent 2019R3). This works in serial mode, in parallel you may have to attach to all Fluent processes (haven't used in years, don't remember anymore). You should see debug symbols loaded in VS.

- Try adding a breakpoint on a code row. The red circle on the left hand side should be filled, if the attach was successful.

- When you run the simulation, whenever the code with the breakpoint is called within Fluent, you should now break in Visual Studio and be able to see the variable content and track program flow. Please see https://ibb.co/K2pPh6K for a screenshot.

No need to extend your wallet.



Cheers, Eero
Hello, could you provide the screenshots of the step-by-step procedure, please?
cudau.95 is offline   Reply With Quote

Old   September 15, 2021, 10:41
Default
  #10
New Member
 
Kaicheng Chen
Join Date: May 2019
Posts: 4
Rep Power: 6
kaicheng is on a distinguished road
Quote:
Originally Posted by eeroi View Post
The simplest way? Really? How much is it then? I am sick of these marketing gimmicks.

For those of you who would prefer not to pay for shady additional software and would like to keep information free, I am proposing the following following GENUINELY-FREE-OF-CHARGE approach, which I find even simpler than your FREE-TO-TRY slash GIVE-ME-YOUR-MONEY solution:

- Remember to back original files up before you make any changes.

- Change the makefile template makefile_nt.udf (in one of the Fluent installation folders):

CFLAGS = /c /Za /Zi /DUDF_EXPORTING /DUDF_NT /DWIN64 /EHa /wd4224

link $(LIBS) /dll /debug /assemblydebug /out:$(TARGET)

In words, you add the compiler flag /Zi and linker flags /debug /assemblydebug, nothing else. These options generate the program database (.pdb) files that you'll later find in the binary output folders.

- Compile the UDF code in Fluent GUI and load the libudf library. This seems to be the best (most stable and universal) approach for compilation these days, earlier you had to run nmake in command prompt.

- Open the source file in the "libudf/src" folder in Visual Studio (a free Express version will do fine).

- In Visual Studio, attach the code to fl_mpi1950.exe (Fluent 2019R3). This works in serial mode, in parallel you may have to attach to all Fluent processes (haven't used in years, don't remember anymore). You should see debug symbols loaded in VS.

- Try adding a breakpoint on a code row. The red circle on the left hand side should be filled, if the attach was successful.

- When you run the simulation, whenever the code with the breakpoint is called within Fluent, you should now break in Visual Studio and be able to see the variable content and track program flow. Please see https://ibb.co/K2pPh6K for a screenshot.

No need to extend your wallet.



Cheers, Eero
Hey I have followed all steps, however, I failed at this step after attaching the code to the process:

- Try adding a breakpoint on a code row. The red circle on the left hand side should be filled, if the attach was successful.

The error is "The breakpoint will not currently be hit, no symbols have been loaded for this document". I have attached to all Fluent processes named fl_mpi2020.exe.

Does anyone have an idea how to solve this?

Thank you in advance

In the end I have solved the problem, everything is working after following the guideline from erroi. Thank you!!!!

Just some comments: For parallel simulation we need to hook the code to all processes named with fl_mpixxxx.exe, and it is highly recommended to debug with serial mode.

Last edited by kaicheng; September 23, 2021 at 07:21. Reason: Found solution for the question post before
kaicheng is offline   Reply With Quote

Old   December 18, 2023, 08:41
Default
  #11
New Member
 
Join Date: Feb 2023
Posts: 2
Rep Power: 0
this_is_mayhem is on a distinguished road
Do you know how to change these flags for built-in compiler? Because these steps
Quote:
Originally Posted by eeroi View Post
- Change the makefile template makefile_nt.udf (in one of the Fluent installation folders):

CFLAGS = /c /Za /Zi /DUDF_EXPORTING /DUDF_NT /DWIN64 /EHa /wd4224

link $(LIBS) /dll /debug /assemblydebug /out:$(TARGET)
affect only MSVC compiler
this_is_mayhem is offline   Reply With Quote

Old   January 6, 2024, 16:39
Default Video instructions using VSCode on windows
  #12
New Member
 
Abdullah Al Amin
Join Date: Oct 2011
Posts: 3
Rep Power: 14
nirjhor is on a distinguished road
I have prepared a video instruction for those who are struggling. The youtube video is here: https://www.youtube.com/watch?v=sK7u416BOas and the github repo link is here: https://github.com/neoceph/Fluent-UDF
nirjhor is offline   Reply With Quote

Reply

Tags
debug, fluent, udf


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Two questions on Fluent UDF Steven Fluent UDF and Scheme Programming 7 March 23, 2018 03:22
Problem running fluent with udf on batch tobi b. Fluent UDF and Scheme Programming 3 April 14, 2016 13:54
Running UDF with Supercomputer roi247 FLUENT 4 October 15, 2015 13:41
fluent UDF external library lapack problem Rick FLUENT 0 May 7, 2008 10:16
UDF problem caused by various version of Fluent Yurong FLUENT 3 January 15, 2006 10:57


All times are GMT -4. The time now is 23:56.