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

Help me Debugging Fluent UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By pakk
  • 1 Post By pakk
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 5, 2021, 04:47
Default Help me Debugging Fluent UDF
  #1
New Member
 
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5
cudau.95 is on a distinguished road
Can you help me How to Debug Fluent UDF c++ in visual Studio?
cudau.95 is offline   Reply With Quote

Old   August 5, 2021, 06:21
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Probably, it depends on how much you are willing to cooperate.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   August 5, 2021, 06:38
Default
  #3
New Member
 
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5
cudau.95 is on a distinguished road
Quote:
Originally Posted by pakk View Post
Probably, it depends on how much you are willing to cooperate.
Code:
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
I tried it . But it not oki .
cudau.95 is offline   Reply With Quote

Old   August 5, 2021, 06:56
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
"Not oki". Can you be more specific? What went wrong? What happened? Which step was the problem? Where do you need help? What is your UDF?

The less info you give, the less we can help...
cudau.95 likes this.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   August 5, 2021, 09:33
Default
  #5
New Member
 
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5
cudau.95 is on a distinguished road
Quote:
Originally Posted by pakk View Post
"Not oki". Can you be more specific? What went wrong? What happened? Which step was the problem? Where do you need help? What is your UDF?

The less info you give, the less we can help...
Thank you for the reply pakk! I get an error described in the following video.

https://youtu.be/Jo6kgdzbGRM


My udf.

Code:
#include "udf.h"
#include "IF97.h" 
using namespace IF97;
using namespace std;
const real gauge = 101325;
//real temperature = 300;
DEFINE_PROPERTY(water_density,c,t)
{
 real density = 998.2;
 real temperature = C_T(c,t);
 real pressure = C_P(c,t) + gauge;
 if(((273.15<=temperature<=1073.15)&&(pressure<=100000000))||((1073.15<=temperature<=2273.15)&&(pressure<=50000000)))
     {
 	    density = rhomass_Tp(temperature,pressure);
     }
 return density;
}
when I enable udf density property for steam Fluent gets the error "floating-point exception fluent udf" or error crash crash auto exit. So I want to debug to see where my UDF is wrong. Hope you will help me.

Code:
 Stabilizing pressure coupled to enhance linear solver robustness.
        Stabilizing pressure coupled using GMRES to enhance linear solver robustness.

Experiencing convergence difficulties - temporarily relaxing and trying again...

Experiencing convergence difficulties - temporarily relaxing and trying again...

Experiencing convergence difficulties - temporarily relaxin
Error at Node 1: floating point exception

Error at Node 0: floating point exception
g and trying again...

Experiencing convergence difficulties - temporarily relaxing and trying again...
        Stabilizing pressure coupled to enhance linear solver robustness.
        Stabilizing pressure coupled using GMRES to enhance linear solver robustness.

Experiencing convergence difficulties - temporarily relaxing and trying again...

Divergence detected in AMG solver: pressure coupled        Stabilizing temperature to enhance linear solver robustness.
        Stabilizing temperature using GMRES to enhance linear solver robustness.

Divergence detected in AMG solver: temperature
Divergence detected in AMG solver: pressure coupled
Divergence detected in AMG solver: temperature
Error at host: floating point exception

===============Message from the Cortex Process================================

Compute processes interrupted. Processing can be resumed.

==============================================================================

Error: floating point exception
Error Object: #f

Last edited by cudau.95; August 5, 2021 at 21:41.
cudau.95 is offline   Reply With Quote

Old   August 5, 2021, 09:59
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
The following does not do what you think it does, it should be split into two different statements:
Code:
(273.15<=temperature<=1073.15)
Otherwise, I can't see problems.
Initialize your simulation, don't run, look at the densities and see if they make sense. Then run 1 iteration, and look at the density again.

I don't think breakpoints in VS will help you.
cudau.95 likes this.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   August 5, 2021, 11:23
Default
  #7
New Member
 
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5
cudau.95 is on a distinguished road
Quote:
Originally Posted by pakk View Post
The following does not do what you think it does, it should be split into two different statements:
Code:
(273.15<=temperature<=1073.15)
Otherwise, I can't see problems.
Initialize your simulation, don't run, look at the densities and see if they make sense. Then run 1 iteration, and look at the density again.

I don't think breakpoints in VS will help you.
Thank park ! I will try it. ! But if possible can you tell me how to set breakpoints in VS ?
cudau.95 is offline   Reply With Quote

Old   August 5, 2021, 12:15
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
I see that you found another thread where this is explained in ten steps, and you requested screenshots of every step...

Be a bit more concrete! Say what you tried, and where you failed. You will get more useful answers in that way...
cudau.95 likes this.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   August 5, 2021, 22:50
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 pakk View Post
I see that you found another thread where this is explained in ten steps, and you requested screenshots of every step...

Be a bit more concrete! Say what you tried, and where you failed. You will get more useful answers in that way...
Thank for pakk. Error "floating-point exception fluent" I fixed it. Thank you !.

But I tried to debug UDF with VS2019. I tried the following steps and it still doesn't work:

- Step1 : I Change the makefile_nt.udf ( in folder C:\Program Files\ANSYS Inc\v211\fluent\fluent21.1.0\src\udf ).

CFLAGS = /c /Za /Zi /DUDF_EXPORTING /DUDF_NT /DWIN64 /EHa /wd4224
link $(LIBS) /dll /debug /assemblydebug /out:$(TARGET)

- Step 2: I Opened Fluent from the cross-tool command prompt vs 2019
- Step 3: I compiled the UDF function
- Step 4: I opened UDF source with VS2019 (....superheat\superheat-1_files\dp0\FLU\Fluent\libudf\src)
- Step 5: I set the breakpoint ON_DEMAND function
- Step 6: From vs2019 I Attach to process fl_mpi2110.exe
- Step 7: I execute on Demand in fluent But it does not stop in a breakpoint.

Please tell me Did I make a mistake somewhere?

The video below shows the steps I did above.
https://youtu.be/CXmzR0e9BNU
cudau.95 is offline   Reply With Quote

Old   August 6, 2021, 04:16
Default
  #10
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Maybe you posted the wrong video: I only see you running Fluent from Workbench, I don't see you doing any of the steps that you mention...
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   August 7, 2021, 00:06
Default
  #11
New Member
 
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5
cudau.95 is on a distinguished road
Quote:
Originally Posted by pakk View Post
Maybe you posted the wrong video: I only see you running Fluent from Workbench, I don't see you doing any of the steps that you mention...
Hi pakk! I watched this video again. I found it correct with the steps I did above. Can you help me review it again? https://www.youtube.com/watch?v=CXmzR0e9BNU
cudau.95 is offline   Reply With Quote

Old   August 7, 2021, 00:46
Default
  #12
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Now I see the steps in the video...
I'm sure yesterday I only saw you going through all boundary condition settings in Fluent, am I going crazy?

Anyway, I don't see a mistake...
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   August 7, 2021, 08:50
Default
  #13
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
You previously linked to https://youtu.be/Jo6kgdzbGRM. I'm not going crazy.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   August 8, 2021, 15:21
Default
  #14
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Now that I have seen the video on a bigger screen, not my phone:

You get a warning at 3:09. You must have noticed, your mouse stayed there for almost 10 seconds.

It clearly said “The breakpoint will not currently be hit. No symbols have been loaded for this document.”

Did you read that? Why didn't you mention it here? Please help me understand this, why didn't you think it was important enough to mention it here?

Do you know what I would have said, at the least?

"Around 3:09, I saw a warning, which I did not really understand, but it might have something to do with my problem."
And do you know why I would have said this? Because then the person helping me could have directly gone to that warning, and they would not have to look through my entire six minute video!

Why are you not more helpful to the people who are trying to help you? Please help me understand... Don't you want your problem to be solved???
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   September 15, 2021, 09:52
Default
  #15
New Member
 
Kaicheng Chen
Join Date: May 2019
Posts: 4
Rep Power: 6
kaicheng is on a distinguished road
Hey there, what is the solution when we see this error information (the breakpoint will not currently be hit....)?
kaicheng is offline   Reply With Quote

Old   September 15, 2021, 09:56
Smile
  #16
New Member
 
Kaicheng Chen
Join Date: May 2019
Posts: 4
Rep Power: 6
kaicheng is on a distinguished road
Quote:
Originally Posted by pakk View Post
Now that I have seen the video on a bigger screen, not my phone:

You get a warning at 3:09. You must have noticed, your mouse stayed there for almost 10 seconds.

It clearly said “The breakpoint will not currently be hit. No symbols have been loaded for this document.”

Did you read that? Why didn't you mention it here? Please help me understand this, why didn't you think it was important enough to mention it here?

Do you know what I would have said, at the least?

"Around 3:09, I saw a warning, which I did not really understand, but it might have something to do with my problem."
And do you know why I would have said this? Because then the person helping me could have directly gone to that warning, and they would not have to look through my entire six minute video!

Why are you not more helpful to the people who are trying to help you? Please help me understand... Don't you want your problem to be solved???
Yeah I went through the whole post, he made some mistakes but do you know the exact answer for his question? Because I think now fluent only has parallel mode, (serial mode is replaced with 1 CPU). Which processes should we attach now?

In the end I have figured out the problem:

1. If we start with 1 solver process, it is serial mode and we just need to hook to that process.
2. It is recommended to debug with only one solver, otherwise the variables are jumping randomly.

Last edited by kaicheng; September 23, 2021 at 07:13. Reason: Ah. I have found the solution for the problem, I just need to restart the PC...
kaicheng is offline   Reply With Quote

Reply


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
A Problem of Fluent Interpreted UDF: parse error knight Fluent UDF and Scheme Programming 25 August 16, 2018 10:26
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 problem: write specific data for every iteration in a file. nnvoro Fluent UDF and Scheme Programming 1 May 27, 2013 15:26


All times are GMT -4. The time now is 01:15.