CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > SU2

How To Debug SU2 Code

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 24, 2023, 04:08
Default How To Debug SU2 Code
  #1
New Member
 
Liming Yang
Join Date: Sep 2023
Posts: 29
Rep Power: 3
CFDWhite is on a distinguished road
Hello SU2 community,

I have compiled on ubuntu using the methods given on the website, and I would like to learn more about SU2 implementation by debugging the code.

I have no experience debugging such large code, how can I debug and learn this code?

Thank you for the help!
CFDWhite is offline   Reply With Quote

Old   October 24, 2023, 17:43
Default
  #2
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 676
Rep Power: 21
bigfootedrockmidget is on a distinguished road
Hi,
I am very happy with visual studio code, which you can download for free here:

https://code.visualstudio.com/download


vscode will definitely help in debugging. If you have no experience with debugging or vscode, you can start with a very small c++ program that you have written and play with that, and you can follow some of the documentation on the visualstudio website.



When you are ready to play with su2 in vscode, just recompile it with debugging support and start a debugging session for a simple test case inside vscode. Hope this helps.
bigfootedrockmidget is offline   Reply With Quote

Old   October 28, 2023, 11:10
Default
  #3
New Member
 
Liming Yang
Join Date: Sep 2023
Posts: 29
Rep Power: 3
CFDWhite is on a distinguished road
Hello, I am also trying to debug su2 code using VS code recently. I can debug a simple program like “Hello world”, but I still have some confusion debugging su2:

1.I have compiled according to the method of the official website, do I need to debug again in VS code?

2.I understand that debugging must start with a certain part (class), so where should I debug and learn the code, or can I debug it as a whole?

3.Should I write the tasks.json file during my specific operation? Or is it automatically generated?

4.Since I am new to CFD, which part would you recommend to start reading and learning?

Some of the questions may be obvious, but your advice will be of great importance to me, and I would be grateful if you could give me some experience.
Attached Images
File Type: jpg Debug.jpg (94.1 KB, 19 views)
CFDWhite is offline   Reply With Quote

Old   October 28, 2023, 14:15
Default
  #4
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 676
Rep Power: 21
bigfootedrockmidget is on a distinguished road
Hi, When compiling with meson, just add -Ddebug=true --optimization=0 and switch off mpi if you do not specifically want to debug mpi stuff: -Dwith-mpi=disabled




In vscode, just choose 'open folder' and select the main SU2 folder containing everything. Then go to "Run and Debug", choose "add configuration" and choose "C/C++ (GDB) Launch".
Then add in the configuration the program name 'folder/to/su2/SU2_CFD' and the arguments 'config.cfg' and the working directory 'folder/to/setup', and then click the 'play' icon to start debugging. If you do not set any breakpoints, your test case should simply run until the end or until an error occurs. First start with a small working testcase to see if it works.
Then, you could go to e.g. SU2_CFD.cpp and place some breakpoints there. Depending on where you would like to do some debugging, just go to that specific file and place the breakpoints.



If you would like to get some idea of where you end up in the code, you can also inspect the definitions of the functions, e.g. StartSolver() and see what they do.
bigfootedrockmidget is offline   Reply With Quote

Old   November 4, 2023, 08:37
Default
  #5
New Member
 
Liming Yang
Join Date: Sep 2023
Posts: 29
Rep Power: 3
CFDWhite is on a distinguished road
Quote:
Originally Posted by bigfootedrockmidget View Post
Hi, When compiling with meson, just add -Ddebug=true --optimization=0 and switch off mpi if you do not specifically want to debug mpi stuff: -Dwith-mpi=disabled




In vscode, just choose 'open folder' and select the main SU2 folder containing everything. Then go to "Run and Debug", choose "add configuration" and choose "C/C++ (GDB) Launch".
Then add in the configuration the program name 'folder/to/su2/SU2_CFD' and the arguments 'config.cfg' and the working directory 'folder/to/setup', and then click the 'play' icon to start debugging. If you do not set any breakpoints, your test case should simply run until the end or until an error occurs. First start with a small working testcase to see if it works.
Then, you could go to e.g. SU2_CFD.cpp and place some breakpoints there. Depending on where you would like to do some debugging, just go to that specific file and place the breakpoints.



If you would like to get some idea of where you end up in the code, you can also inspect the definitions of the functions, e.g. StartSolver() and see what they do.
Thank you for your detailed knowledge. However, I still have some confusion
I have successfully compiled with meson as shown in Figure 1.

Then I debug in vscode, I opened the folder called SU2-master that containing the main SU2 folder like Figure 2.

Next I create the launch file like Figure 3, I think the setting method in the figure can achieve the same result as the setting method described by you. If I misunderstand something, please advise me.

But the results were not good;

1.Error like Figure 4. My file location is shown in the figure, so how should my program name be set?

2.Vscode does not seem to support CLI11, have you encountered this problem? How was it resolved?

Thanks a lot.
CFDWhite is offline   Reply With Quote

Old   November 5, 2023, 03:43
Default
  #6
New Member
 
Liming Yang
Join Date: Sep 2023
Posts: 29
Rep Power: 3
CFDWhite is on a distinguished road
Quote:
Originally Posted by CFDWhite View Post
Thank you for your detailed knowledge. However, I still have some confusion
I have successfully compiled with meson as shown in Figure 1.

Then I debug in vscode, I opened the folder called SU2-master that containing the main SU2 folder like Figure 2.

Next I create the launch file like Figure 3, I think the setting method in the figure can achieve the same result as the setting method described by you. If I misunderstand something, please advise me.

But the results were not good;

1.Error like Figure 4. My file location is shown in the figure, so how should my program name be set?

2.Vscode does not seem to support CLI11, have you encountered this problem? How was it resolved?

Thanks a lot.
I don't know why the picture can't be uploaded, please add as follows
Attached Images
File Type: jpg 6.jpg (79.0 KB, 23 views)
CFDWhite is offline   Reply With Quote

Old   November 5, 2023, 05:58
Default
  #7
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 676
Rep Power: 21
bigfootedrockmidget is on a distinguished road
You should compile it with meson, also inside vscode. And you already compiled it, so now you just need to launch the debugger.
bigfootedrockmidget is offline   Reply With Quote

Old   November 5, 2023, 07:29
Default
  #8
New Member
 
Liming Yang
Join Date: Sep 2023
Posts: 29
Rep Power: 3
CFDWhite is on a distinguished road
Quote:
Originally Posted by bigfootedrockmidget View Post
You should compile it with meson, also inside vscode. And you already compiled it, so now you just need to launch the debugger.
I did compile with meson, but I'm not sure if it's related to vscode. Also, when I use debug directly, I get an error like the one shown in the figure, is this normal?
Attached Images
File Type: jpg 7.jpg (154.5 KB, 29 views)
File Type: jpg 8.jpg (159.1 KB, 21 views)
CFDWhite is offline   Reply With Quote

Old   September 7, 2024, 06:49
Default
  #9
New Member
 
Jimin.Zhang
Join Date: May 2024
Posts: 8
Rep Power: 2
2770363742@qq.com is on a distinguished road
Quote:
Originally Posted by CFDWhite View Post
Hello SU2 community,

I have compiled on ubuntu using the methods given on the website, and I would like to learn more about SU2 implementation by debugging the code.

I have no experience debugging such large code, how can I debug and learn this code?

Thank you for the help!
Hello, I recently encountered the same issue as you and I'm not sure how to debug SU2 in VSCode. Did you manage to solve the problem? Could you please share your solution? Thank you.
2770363742@qq.com 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
3D Windturbine simulation in SU2 k.vimalakanthan SU2 15 October 12, 2023 06:53
Fortran->Assembly : How to remove redundant non-vectorized code? aerosayan Main CFD Forum 6 November 20, 2020 06:37
Damper in aeroelastic NACA64A010 SU2 testcase: need to access the source code? kiloWatt SU2 3 November 11, 2020 04:23
SU2 7.0.7 Built on CentOS 7, parallel computation pyscript mpi exit error? EternalSeekerX SU2 3 October 9, 2020 19:28
The FOAM Documentation Project - SHUT-DOWN holger_marschall OpenFOAM 242 March 7, 2013 13:30


All times are GMT -4. The time now is 12:54.