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

How can I debug a su program?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 28, 2022, 23:10
Default How can I debug a su program?
  #1
Member
 
zhangqiang
Join Date: Nov 2022
Posts: 43
Rep Power: 3
zhang-qiang is on a distinguished road
Usually, I learn an algorithm by debug it. The SU2 tutorial show the usage of SU2 by: SU_CFD.exe xxx.cfg. In this way, how can I step into the original code?

Can I debug it by visual studio or VS code or other compilers? Could someone provide some instruction?

Any suggestion is appreciated~~~
zhang-qiang is offline   Reply With Quote

Old   November 29, 2022, 15:20
Default
  #2
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 640
Rep Power: 19
bigfootedrockmidget is on a distinguished road
Hi,
1. download the source code:
https://github.com/su2code/SU2

2. compile su2 yourself, either in linux or windows:
https://su2code.github.io/docs_v7/Bu...2-Linux-MacOS/ (recommended)

https://su2code.github.io/docs_v7/Build-SU2-Windows/
Then install VScode and your favorite debugger, make sure you compile su2 in debugging mode and run it from withing VScode.
bigfootedrockmidget is offline   Reply With Quote

Old   December 1, 2022, 01:37
Default
  #3
Member
 
zhangqiang
Join Date: Nov 2022
Posts: 43
Rep Power: 3
zhang-qiang is on a distinguished road
Thank you very much for kindly reply.

I have compile su2 in my computer. I usually use visual studio and CMakeLists.txt to build project. The instruction of SU2 recommand command style to run code. I am confuzed about how to build su2 projection in visual studio.

1. Can I build projection in visual studio and include su2 library? Could you please give me more details about how to include su2 library in visual studio?

2. Could you please give me more details about how to include su2 in VScode?
zhang-qiang is offline   Reply With Quote

Old   December 1, 2022, 06:06
Default
  #4
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 640
Rep Power: 19
bigfootedrockmidget is on a distinguished road
Hi,
In vscode, it is sufficient to just open the main project folder called SU2 to start working with it. For debugging you only have to configure VScode such that it can find the debugger, and you'll have to create a configuration file that calls the SU2 executable and the config file. For more information, please have a look at one of the many VScode (or other) tutorials
bigfootedrockmidget is offline   Reply With Quote

Old   December 1, 2022, 11:41
Default
  #5
Member
 
zhangqiang
Join Date: Nov 2022
Posts: 43
Rep Power: 3
zhang-qiang is on a distinguished road
If VScode calls the SU2 executable, can I step into the source code?
zhang-qiang is offline   Reply With Quote

Old   December 2, 2022, 04:17
Default
  #6
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 640
Rep Power: 19
bigfootedrockmidget is on a distinguished road
Yes, please go through a VSCode tutorial, and also go through the docs at

https://code.visualstudio.com/docs/languages/cpp
https://code.visualstudio.com/docs/cpp/config-linux
https://code.visualstudio.com/docs/cpp/config-mingw


If you are not familiar yet with debugging, please start with the simple "Hello World" example on the visualstudio website to get familiar with the basics.
bigfootedrockmidget is offline   Reply With Quote

Old   December 5, 2022, 08:52
Default
  #7
Member
 
zhangqiang
Join Date: Nov 2022
Posts: 43
Rep Power: 3
zhang-qiang is on a distinguished road
Thank you very much for the kindly reply~~~ I will try it.
zhang-qiang is offline   Reply With Quote

Old   December 31, 2022, 01:14
Default
  #8
Member
 
zhangqiang
Join Date: Nov 2022
Posts: 43
Rep Power: 3
zhang-qiang is on a distinguished road
I have read some information about using vscode to debug code. In this webpage https://code.visualstudio.com/docs/languages/cpp, the steps to debug a c++ is:

1. Prepare a fold and c++ code, for example: HelloWorld.cpp
2. Terminal > Run Build Task

In order to debug su2 program with vscode, I still some questions:
1. Is SU2/SU2_CFD/src/SU2_CFD.cpp the HelloWorld.cpp?
2. How should I set the tasks.json file?

Any suggestion is appreciated~~~
zhang-qiang is offline   Reply With Quote

Old   January 1, 2023, 10:40
Default
  #9
Member
 
zhangqiang
Join Date: Nov 2022
Posts: 43
Rep Power: 3
zhang-qiang is on a distinguished road
Firstly, compile SU2 in debug: python ./meson.py build --buildtype=debugoptimized.

Then, implement a launch.json.

Finally, I can debug into SU2 project.
zhang-qiang is offline   Reply With Quote

Old   October 28, 2023, 11:08
Default
  #10
New Member
 
Liming Yang
Join Date: Sep 2023
Posts: 29
Rep Power: 3
CFDWhite is on a distinguished road
Quote:
Originally Posted by zhang-qiang View Post
Firstly, compile SU2 in debug: python ./meson.py build --buildtype=debugoptimized.

Then, implement a launch.json.

Finally, I can debug into SU2 project.
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.
CFDWhite is offline   Reply With Quote

Old   October 28, 2023, 11:13
Default
  #11
New Member
 
Liming Yang
Join Date: Sep 2023
Posts: 29
Rep Power: 3
CFDWhite is on a distinguished road
Quote:
Originally Posted by zhang-qiang View Post
Firstly, compile SU2 in debug: python ./meson.py build --buildtype=debugoptimized.

Then, implement a launch.json.

Finally, I can debug into SU2 project.
Hello, maybe I am stupid to ask this question, how did you achieve these two steps?

I am very confused about how this works in VScode, I would appreciate it if you could explain in more detail.
Attached Images
File Type: jpg Debug.jpg (94.1 KB, 14 views)
CFDWhite is offline   Reply With Quote

Reply

Tags
debug

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[General] Extracting ParaView Data into Python Arrays Jeffzda ParaView 30 November 6, 2023 22:00
Finding the corresponding debug switch Tobi OpenFOAM Programming & Development 8 October 14, 2020 10:23
Recursive output of Foam::word in gdb print command chengdi OpenFOAM Programming & Development 1 July 19, 2017 21:19
Update boundary conditions calculated by an external program CedricVH OpenFOAM 2 January 15, 2010 12:55
debug program zhujianguo Phoenics 0 July 21, 2003 05:36


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