CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Is anyone using Visual Studio Code for OF-programming? (https://www.cfd-online.com/Forums/openfoam-programming-development/181476-anyone-using-visual-studio-code-programming.html)

chriss85 December 15, 2016 05:27

Is anyone using Visual Studio Code for OF-programming?
 
I was wondering if anyone is using Visual Studio Code for developing OpenFOAM applications. What are your experiences? Did you get the debugger working? How about indexing the code?

I found that the indexer fails to finish and vscode has full CPU usage, presumably because of the large code base. It also doesn't give me autocompletion. This might be linked to the unfinished indexing.

If you're using a different editor/IDE, it would be nice to hear about your experience, especially with regards to autocompletion. I'm not sure if it's even reasonable to expect it on such a huge code base using many templates and macros.

floquation December 15, 2016 06:02

Quote:

Originally Posted by chriss85 (Post 629804)
If you're using a different editor/IDE, it would be nice to hear about your experience, especially with regards to autocompletion. I'm not sure if it's even reasonable to expect it on such a huge code base using many templates and macros.

Having started as a Java programmer, Eclipse is my IDE of choice. Originally, this was a purely Java IDE, but over the course of time its large user base created plug-ins for virtually every programming language - including C++.

Does everything work flawlessly? Certainly not... OpenFoam likes to "#include" files in a copy-paste manner, e.g. to declare common variables in solvers. This is perfectly allowed in C++, but the indexer does not understand it. Consequently, virtually all symbols are unknown, and therefore you have nothing: no autocompletion, no "open declaration", etc. Well, that's depressing.

However, with some additional effort, I found a way to "fool Eclipse's indexer". This takes me from this to this. Well, that looks pretty neat!
Disadvantages:
  1. Requires some additional effort on the user's side to get it working
  2. By fooling the indexer, it partially loses the concept of "variable scope", meaning it might not show an error when something is erroneous.
  3. It doesn't work in most #included-files, like "UEqn.H". It only works in "real" C files. (I get around this while developing by simply copying the content of UEqn.H into the solver's main file. Then I have autocompletion etc. When I'm done, I copy it back and #include it.)
Advantages:
  • You have all the neat features like "autocompletion" and "open declaration"!
  • I don't think templating is an issue for the indexer (although it becomes more difficult for you to trace things)
Note that I do not have to "load" OpenFoam into Eclipse. I just specify the relevant include directories, where the indexer can search during indexing.

fedvasu December 19, 2016 15:09

Similar for Clion
 
CLion (basically Intellij for C++).

I am doing something similar with Clion as floquation has done with Eclipse.

However you won't get full IDE capabilities unless you make wmake system of OpenFOAM work with the IDE.

I came across an old tutorial which turned Netbeans into a full fledged OF IDE with wmake as the build system integrated with it.

But it was for OF-1.6, I don't think that project is maintained anymore

arvindpj December 19, 2016 16:28

Qt Creator is good too!
 
3 Attachment(s)
I find Qt Creator more flexible.
  • It does have auto-complete by default and does not require convoluted set-up as Eclipse.
  • Debugging is a breeze. It is quite similar to VS. All we I had do is specify the working directory.
  • Can be coupled with gdbOF in a simple window.

Cheers:)

PositronCascade December 26, 2016 19:36

I use Sublime Text. It is also very good editor

wyldckat December 27, 2016 14:12

Quote:

Originally Posted by chriss85 (Post 629804)
I was wondering if anyone is using Visual Studio Code for developing OpenFOAM applications. What are your experiences? Did you get the debugger working? How about indexing the code?

Quick answer: Last time I checked (3-5 years ago?), MSVC is unable to handle OpenFOAM without a lot of code readjusting. I'm mostly referring to compiling, but if it's not able to compile, then it will have a considerable hard-time parsing the source code.

The only people I know that are possibly still working on this is Hrvoje Jasak at Wikki.co.uk, who had an old version of foam-extend built with MSVC and about a year ago he asked who was interested in this: https://www.cfd-online.com/Forums/op...tml#post561683 - post #4


Nonetheless, I use MSVC occasionally only as a code editor for our work at blueCAPE in developing solvers and utilities, mostly still based on OpenFOAM 2.2.x and the project in MSVC 2008 Express and MSVC 2010 Pro; in both the source code project is configured as a "utility" and not as an actual C++ project, and the included folders from OpenFOAM are only the minimum necessary ("OpenFOAM/lnInclude" and "finiteVolume/lnInclude"). MSVC's auto-complete has a lot of difficulty in figuring out several details about how the OpenFOAM code works, so it has a lot of missing auto-complete features.

nsf December 28, 2016 03:43

Hi,

I also use qtcreator. Very little hassle, debugging and building works fine and most autocompletion works. And you can ctrl-click on a declaration and it will take you to the source. There is a somewhat outdated guide here

https://openfoamwiki.net/index.php/H...with_QtCreator

I wrote a script that sets everything up for you. It is posted on the link above but I think it might not work with recent versions of qtcreator.

Best regards
Nicolas

chriss85 January 2, 2017 07:30

Thanks for your replies, I will definitely check out QT Creator.

lt123sss September 7, 2017 03:12

Hi Arvind, I am programming with qt creator too. However, I do not know how to debug in qt creator with GDBOF. Can you give me some tips on how to implement GDB of in qt creator? Thank you very much.

Huipeng Xiao September 10, 2017 17:54

Most of people perfer to use IDE, but I use vim as text edite, gdb as debug.

Sent from my Le X620 using CFD Online Forum mobile app


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