CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

OpenFOAM + qtCreator - "Follow symbol under cursor" does not work

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By floquation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 22, 2017, 11:33
Default OpenFOAM + qtCreator - "Follow symbol under cursor" does not work
  #1
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15
gaza is on a distinguished road
Dear Foamers,
According to this guide

https://openfoamwiki.net/index.php/H...or#Usage_hints

in point 3.6.1 we can read
"You can open the header-file (.H) where a class or function was declared by using the tool: Follow symbol under cursor (F2)"
However it does not work for me. Does anybody know how to set up this feature?
__________________
best regards
pblasiak
gaza is offline   Reply With Quote

Old   February 22, 2017, 12:10
Default
  #2
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 20
floquation will become famous soon enough
I do not know about QtCreator; I like using Eclipse for the same purpose.

In Eclipse, the problem you describe occurs if you do not tell the indexer where the included files are. I reckon the same applies to QtCreator.

Looking at your link, section 3.3 (about Autocomplete) tells you have to specify those locations.
floquation is offline   Reply With Quote

Old   February 22, 2017, 14:27
Default
  #3
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15
gaza is on a distinguished road
Hi Kevin,
Thank you for your reply. I added lnInclude directories into includes file as described in section 3.3 (about Autocomplete, however it still does not work.
__________________
best regards
pblasiak
gaza is offline   Reply With Quote

Old   February 23, 2017, 07:44
Default
  #4
New Member
 
Daniel Plucenio
Join Date: May 2011
Posts: 7
Rep Power: 14
dplucenio is on a distinguished road
Maybe you're still missing some include directories. One thing that helped me on configuring include files was to check on the output of wmake. It will show the command passed on to gcc and anything after -I indicates directories to be included at compilation. I hope this helps
dplucenio is offline   Reply With Quote

Old   February 23, 2017, 07:49
Default
  #5
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15
gaza is on a distinguished road
Hi Daniel
So it only depends on includes file?
__________________
best regards
pblasiak
gaza is offline   Reply With Quote

Old   February 23, 2017, 08:22
Default
  #6
New Member
 
Daniel Plucenio
Join Date: May 2011
Posts: 7
Rep Power: 14
dplucenio is on a distinguished road
Those outputs I mentioned (You could probably get those from the Make/options files on your project as well, I just though it was easier for me to get them from the wmake output ) are the directories that gcc will need to find the header files your program need to compile. So I think those are also the directories qtcreator needs to find the headers existing on your files. For instance for an application that I'm currently working on these are the directories gcc needs to compile:

-I.
-IlnInclude
-I/home/daniel/Projects/OpenFOAM-dev/src/finiteVolume/lnInclude
-I/home/daniel/Projects/OpenFOAM-dev/src/meshTools/lnInclude
-I/home/daniel/Projects/OpenFOAM-dev/src/
-I/home/daniel/Projects/OpenFOAM-dev/src/OpenFOAM/lnInclude
-I/home/daniel/Projects/OpenFOAM-dev/src/OSspecific/POSIX/lnInclude

So I added at my "project.includes":
.
$$(FOAM_INST_DIR)/OpenFOAM-dev/src/finiteVolume/lnInclude
$$(FOAM_INST_DIR)/OpenFOAM-dev/src/meshTools/lnInclude
$$(FOAM_INST_DIR)/OpenFOAM-dev/src
$$(FOAM_INST_DIR)/OpenFOAM-dev/src/OpenFOAM/lnInclude
$$(FOAM_INST_DIR)/OpenFOAM-dev/src/OSspecific/POSIX/lnInclude
/lnInclude

FOAM_INST_DIR is an environment variable pointing to your openFoam installation directory. If you want to use those, it's a good idea to open qt creator from the terminal session where you have your openFOAM variables set. Let me know if this helped
dplucenio is offline   Reply With Quote

Old   February 23, 2017, 08:39
Default
  #7
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15
gaza is on a distinguished road
Unfortunately it does not help.
I would like for example jump to the function
Code:
 turbulence->divDevReff(U)
__________________
best regards
pblasiak
gaza is offline   Reply With Quote

Old   February 23, 2017, 09:15
Default
  #8
New Member
 
Daniel Plucenio
Join Date: May 2011
Posts: 7
Rep Power: 14
dplucenio is on a distinguished road
Alright, those things that I mentioned would help you on jumping to files. In order to get better autocompletion on qtCreator, one thing that helped me wast to include the header files that has the declarations of the type that i am interested in. The url you linked gives you a hint about that: "Notice that Qt Creator will only be able to autocomplete in files which call the respective definition. OpenFOAM coding style often include standard routines inside the algorithm by #include calls. The compiler accepts this, but it is not a good programming practice. In this case, if you try to edit the routine file createFields.H, you will not have autocompletation of things defined in fvCFD.H. Autocompletation will work only in the file where #include "fvCFD.H" is written."

So what happens is that sometimes the includes on you application (despite it is compiling) do not carry the declaration of the symbol. Maybe the header files that you're currently including only have forward declarations of it, I really don't know. But you need to add the correspondent header file wich carries the declaration of the symbol you're interested in. For instance, in my case to have autocompletion on IOobject type, I had to add #include "OpenFOAM/db/IOobject/IOobject.H" on my .C file.

In your case it seems that you want the header with IncompressibleTurbulenceModel declaration (which has devRhoReff method). Then you would need to add:

Code:
#include "TurbulenceModels/incompressible/IncompressibleTurbulenceModel/IncompressibleTurbulenceModel.H"
If you're not having any trouble on compiling it thant it's ok. I had to add

Code:
    -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
on my Make/options but I got qtCreator to autocomplete with IncompressibleTurbulenceModel
dplucenio is offline   Reply With Quote

Old   February 23, 2017, 09:37
Default
  #9
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 20
floquation will become famous soon enough
Quote:
Originally Posted by dplucenio View Post
For instance, in my case to have autocompletion on IOobject type, I had to add #include "OpenFOAM/db/IOobject/IOobject.H" on my .C file.
Wait, you are adding #include-s to the actual C-code just to make autocompletion work? That seems very undesirable to say the least.
In Eclipse, I can add include-directories and individual include-files to the indexer's input to achieve that very same purpose. I assume QtCreator has a similar feature?

But yes, you are right in principle. In Eclipse, I also had to include very specific header files to make the turbulence library be recognised by the indexer.
dplucenio likes this.
floquation is offline   Reply With Quote

Old   February 23, 2017, 09:55
Default
  #10
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15
gaza is on a distinguished road
This is my changed includes file, however it still does not jump to divDevReff function
Code:
.
#include "/home/przemek/OpenFOAM/OpenFOAM-v1606+/src/TurbulenceModels/incompressible/IncompressibleTurbulenceModel/IncompressibleTurbulenceModel.H"
/home/przemek/OpenFOAM/OpenFOAM-v1606+/src/TurbulenceModels/turbulenceModels/lnInclude
/home/przemek/OpenFOAM/OpenFOAM-v1606+/src/TurbulenceModels/incompressible/lnInclude
/home/przemek/OpenFOAM/OpenFOAM-v1606+/src/transportModels
/home/przemek/OpenFOAM/OpenFOAM-v1606+/src/transportModels/incompressible/singlePhaseTransportModel
/home/przemek/OpenFOAM/OpenFOAM-v1606+/src/finiteVolume/lnInclude
/home/przemek/OpenFOAM/OpenFOAM-v1606+/src/meshTools/lnInclude
/home/przemek/OpenFOAM/OpenFOAM-v1606+/src/sampling/lnInclude
/lnInclude
/home/przemek/OpenFOAM/OpenFOAM-v1606+/src/OpenFOAM/lnInclude
/home/przemek/OpenFOAM/OpenFOAM-v1606+/src/OSspecific/POSIX/lnInclude
__________________
best regards
pblasiak
gaza is offline   Reply With Quote

Old   February 23, 2017, 10:04
Default
  #11
New Member
 
Daniel Plucenio
Join Date: May 2011
Posts: 7
Rep Power: 14
dplucenio is on a distinguished road
Oh, I mean
#include "/home/przemek/OpenFOAM/OpenFOAM-v1606+/src/TurbulenceModels/incompressible/IncompressibleTurbulenceModel/IncompressibleTurbulenceModel.H"

should be added to you aplication .C file. You probably already have

"#include "fvCFD.H" there somewhere. So, try adding

#include "TurbulenceModels/incompressible/IncompressibleTurbulenceModel/IncompressibleTurbulenceModel.H"

In order to get qtcreator to find TurbulenceModels directory, I think you need to add

/home/przemek/OpenFOAM/OpenFOAM-v1606+/src

To your project.include file. This (/home/przemek/OpenFOAM/OpenFOAM-v1606+/src) is always nice to have added so you can easily include anything else you need. You can use https://cpp.openfoam.org to search for the types you're interested in
dplucenio is offline   Reply With Quote

Old   February 23, 2017, 10:07
Default
  #12
New Member
 
Daniel Plucenio
Join Date: May 2011
Posts: 7
Rep Power: 14
dplucenio is on a distinguished road
Quote:
Originally Posted by floquation View Post
Wait, you are adding #include-s to the actual C-code just to make autocompletion work? That seems very undesirable to say the least.
In Eclipse, I can add include-directories and individual include-files to the indexer's input to achieve that very same purpose. I assume QtCreator has a similar feature?

But yes, you are right in principle. In Eclipse, I also had to include very specific header files to make the turbulence library be recognised by the indexer.
As a matter of fact you're right. On qtcreator there's also a "YourProject.files" file where I could add

$$(FOAM_INST_DIR)/OpenFOAM-dev/src/db/IOobject/IOobject.H"

So no need to #include files on my .C source file anymore. Thanks this will be very helpful
dplucenio is offline   Reply With Quote

Old   February 23, 2017, 19:20
Default
  #13
New Member
 
Daniel Plucenio
Join Date: May 2011
Posts: 7
Rep Power: 14
dplucenio is on a distinguished road
However, I couldn't see how this would be any disadvantageous at all :/. In fact my take on it is that it's kind of good practice when you're working with C++ and want to use any data type, to add its correspondent header. Say you're using std::vector for instance in your .cpp file but chose not to #include <vector> because you know that a header from a 3rd part library already includes it. Whenever the implementation of this 3rd party library changes, your .cpp will stop compiling.
And this practice also won't add any compile overhead as well, since every .cpp file is compiled independently do generate its object file, the header will be added for sure in order to compile. And thanks to header guards, will be added only once.
dplucenio is offline   Reply With Quote

Old   February 24, 2017, 03:24
Default
  #14
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 20
floquation will become famous soon enough
Quote:
Originally Posted by dplucenio View Post
However, I couldn't see how this would be any disadvantageous at all :/. In fact my take on it is that it's kind of good practice when you're working with C++ and want to use any data type, to add its correspondent header. Say you're using std::vector for instance in your .cpp file but chose not to #include <vector> because you know that a header from a 3rd part library already includes it. Whenever the implementation of this 3rd party library changes, your .cpp will stop compiling.
And this practice also won't add any compile overhead as well, since every .cpp file is compiled independently do generate its object file, the header will be added for sure in order to compile. And thanks to header guards, will be added only once.
Your argument makes sense. I'm not experienced enough in C++ to know all best practices and especially the why-s of those practices. So if there are indeed no caveats to it, then yes, you should add them to your own code.
The reason I mentioned what I said in my previous post and the reason I emphasise "to your own code" is that I also use an IDE to read OF's source code, as it allows me to quickly navigate through it. In this case, I still wouldn't consider it a good idea to add #include-s to OF's source code - just to be able to navigate it, especially since there is an alternative that leaves the source code intact.
floquation is offline   Reply With Quote

Old   September 12, 2020, 08:06
Default Qt creator versus Eclipse
  #15
New Member
 
Prabhu Kankatala
Join Date: Sep 2020
Posts: 2
Rep Power: 0
Prabs27 is on a distinguished road
Hello all,

I have read through your discussion and reckoned that there are a few differences between using Qt creator and Eclipse. Can you enlighten me with your experience in general ? I am currently considering to use an IDE for developing a turbine model solver (psioFoamTurbine.ALM.C) of an extended package of OpenFOAM, so indeed the solver is an already modified version of openFOAM solver pisoFOAM.

other primary reasons to choose an IDE over textedit are

1. Find usages of member functions
2. jump to declarations and header files to understand implementations of different formulae

3. Make changes and try to develop my new version.




Regards

Prabhu
Prabs27 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
How to work with third order (rank 3) tensor fields in openFOAM? FernandoSoares OpenFOAM Programming & Development 1 July 5, 2023 17:03
OpenFOAM Training: Programming CFD Course 12-13 and 19-20 April 2016 cfd.direct OpenFOAM Announcements from Other Sources 0 January 14, 2016 10:19
CGNS Compiling Diego Main CFD Forum 17 December 21, 2014 01:40
OpenFOAM does not work any more! kiddmax OpenFOAM Installation 12 June 25, 2013 02:56
POSDAT problem piotka STAR-CD 4 June 12, 2009 08:43


All times are GMT -4. The time now is 03:32.