|
[Sponsors] |
August 5, 2021, 05:47 |
Help me Debugging Fluent UDF
|
#1 |
New Member
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5 |
Can you help me How to Debug Fluent UDF c++ in visual Studio?
|
|
August 5, 2021, 07:21 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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". |
|
August 5, 2021, 07:38 |
|
#3 |
New Member
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5 |
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 |
|
August 5, 2021, 07:56 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
"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...
__________________
"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". |
|
August 5, 2021, 10:33 |
|
#5 | |
New Member
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5 |
Quote:
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; } 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 22:41. |
||
August 5, 2021, 10:59 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
The following does not do what you think it does, it should be split into two different statements:
Code:
(273.15<=temperature<=1073.15) 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.
__________________
"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". |
|
August 5, 2021, 12:23 |
|
#7 | |
New Member
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5 |
Quote:
|
||
August 5, 2021, 13:15 |
|
#8 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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...
__________________
"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". |
|
August 5, 2021, 23:50 |
|
#9 | |
New Member
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5 |
Quote:
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 |
||
August 6, 2021, 05:16 |
|
#10 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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". |
|
August 7, 2021, 01:06 |
|
#11 | |
New Member
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5 |
Quote:
|
||
August 7, 2021, 01:46 |
|
#12 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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". |
|
August 7, 2021, 09:50 |
|
#13 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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". |
|
August 8, 2021, 16:21 |
|
#14 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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". |
|
September 15, 2021, 10:52 |
|
#15 |
New Member
Kaicheng Chen
Join Date: May 2019
Posts: 4
Rep Power: 7 |
Hey there, what is the solution when we see this error information (the breakpoint will not currently be hit....)?
|
|
September 15, 2021, 10:56 |
|
#16 | |
New Member
Kaicheng Chen
Join Date: May 2019
Posts: 4
Rep Power: 7 |
Quote:
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 08:13. Reason: Ah. I have found the solution for the problem, I just need to restart the PC... |
||
|
|
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 11:26 |
Two questions on Fluent UDF | Steven | Fluent UDF and Scheme Programming | 7 | March 23, 2018 04:22 |
Problem running fluent with udf on batch | tobi b. | Fluent UDF and Scheme Programming | 3 | April 14, 2016 14:54 |
Running UDF with Supercomputer | roi247 | FLUENT | 4 | October 15, 2015 14:41 |
fluent udf problem: write specific data for every iteration in a file. | nnvoro | Fluent UDF and Scheme Programming | 1 | May 27, 2013 16:26 |