Difference between revisions of "TestFloquation"

From OpenFOAMWiki
m
m
Line 71: Line 71:
  
 
== Before we start ==
 
== Before we start ==
First follow [[Howto_Use_OpenFOAM_with_Eclipse | these steps]] to import your code into Eclipse.
+
First follow [[Howto_Use_OpenFOAM_with_Eclipse | these steps]] to import your code into Eclipse. In the following subsections, the most important steps are shown.
 +
 
 
For the exemplifying figures below, “Eclipse Mars.1 (4.5.1)” with “CDT 8.8.1” is used.
 
For the exemplifying figures below, “Eclipse Mars.1 (4.5.1)” with “CDT 8.8.1” is used.
Then, (a copy of) “interFoam v2.3.x” will be imported into Eclipse. My indexer settings (Window->Preferences->C/C++->Indexer) are as follows:
+
Then, (a copy of) “interFoam v2.3.x” will be imported into Eclipse.
 +
The used indexer settings (Window->Preferences->C/C++->Indexer) are as follows:
  
[[File:Eclipse_Preferences_Indexer.png|center|]]
+
[[File:Eclipse_Preferences_Indexer.png|center|500px]]
  
 
=== Copying interFoam ===
 
=== Copying interFoam ===
Copying “interFoam” can be quickly done as follows (Linux, {{Version2.3.x}}). This assumes that the OpenFOAM environment has been sourced in the terminal:
+
Copying “interFoam” can be done quickly as follows (Linux, {{Version2.3.x}}). This assumes that the OpenFOAM environment has been sourced in the terminal:
 
<bash>$ cd $FOAM_USER_SOLVERS  
 
<bash>$ cd $FOAM_USER_SOLVERS  
 
$ cp -r $FOAM_SOLVERS/multiphase/interFoam ./interFoam_EclipseTut
 
$ cp -r $FOAM_SOLVERS/multiphase/interFoam ./interFoam_EclipseTut
Line 85: Line 87:
 
$ wclean
 
$ wclean
 
</bash>
 
</bash>
Now replace references to APPBIN to USER_APPBIN, but first see if behaviour is as expected:
+
Now replace references to APPBIN to USER_APPBIN, but first see if the behaviour is as expected:
 
<bash>$ grep -lre "FOAM_APPBIN" . | xargs -l sed -e 's/FOAM_APPBIN/FOAM_USER_APPBIN/g'
 
<bash>$ grep -lre "FOAM_APPBIN" . | xargs -l sed -e 's/FOAM_APPBIN/FOAM_USER_APPBIN/g'
 
</bash>
 
</bash>
Line 101: Line 103:
  
 
=== Including directories ===
 
=== Including directories ===
Then, in the case of “interFoam”, add the following include directories (Project->Properties->C/C++ General->Paths and Symbols), as described [[Howto_Use_OpenFOAM_with_Eclipse#Launching_C.2B.2B_project | here]]:
+
After importing the project into Eclipse, (in the case of “interFoam”) add the following include directories (Project->Properties->C/C++ General->Paths and Symbols), as described [[Howto_Use_OpenFOAM_with_Eclipse#Launching_C.2B.2B_project | here]]:
  
[[File:Eclipse_interFoam_includeDirs.png|center|]]
+
[[File:Eclipse_interFoam_includeDirs.png|center|600px]]
  
 
This will enable Eclipse's indexer to find all included headers (see the following figure). It will, however, not recognize all symbols yet. We must first feed the indexer with more information.
 
This will enable Eclipse's indexer to find all included headers (see the following figure). It will, however, not recognize all symbols yet. We must first feed the indexer with more information.
  
[[File:Eclipse_interFoam_EclipseTut_justLoaded.png|center|]]
+
[[File:Eclipse_interFoam_EclipseTut_justLoaded.png|center|800px]]
  
  
Line 118: Line 120:
 
First, go to (Window->Preferences->C/C++->Property Pages Settings) and tick the box 'Display “Include Files” tab on Paths and Symbols page':
 
First, go to (Window->Preferences->C/C++->Property Pages Settings) and tick the box 'Display “Include Files” tab on Paths and Symbols page':
  
[[File:Eclipse_WindowPreferences_IncludeFiles.png|center|]]
+
[[File:Eclipse_WindowPreferences_IncludeFiles.png|center|600px]]
  
Now go to (Project->Properties->C/C++ General->Paths and Symbols->Include Files) and add all header files which Eclipse is complaining about. Do not forget to rebuild the index. For example, add “createTime.H” for the variable “runTime” to be recognized:
+
Now go to (Project->Properties->C/C++ General->Paths and Symbols->Include Files) and add all header files which Eclipse is complaining about. Do not forget to rebuild the index, if your Eclipse does not do so automatically. For example, add “createTime.H” for the variable “runTime” to be recognized:
  
<insert images: add_createTime.png && createTime_added.png>
+
[[File:Eclipse_add_createTime.png|center|600px]]
[[File:Eclipse_add_createTime.png|center|]]
+
[[File:Eclipse_createTime_added.png|center|800px]]
[[File:Eclipse_createTime_added.png|center|]]
+
  
  
 
Note that the method “run” from the variable “runTime” is not yet recognized. (Actually, no method will be recognized.) For it to be recognized, “Time.H” must also be added. Or rather: “fvCFD.H” must be added, because this is the file which includes “Time.H” in our project. “fvCFD.H” must be included before “createTime.H”. I am not sure why the order matters, but it is probably because “fvCFD.H” includes “Time.H”, which must be known before “createTime.H” is interpreted.
 
Note that the method “run” from the variable “runTime” is not yet recognized. (Actually, no method will be recognized.) For it to be recognized, “Time.H” must also be added. Or rather: “fvCFD.H” must be added, because this is the file which includes “Time.H” in our project. “fvCFD.H” must be included before “createTime.H”. I am not sure why the order matters, but it is probably because “fvCFD.H” includes “Time.H”, which must be known before “createTime.H” is interpreted.
  
Continuing this process for all errors, we eventually end up with the following list of includes. (Note that the order does again matter for some files.)
+
Continuing this process for all errors, we eventually end up with the following list of includes (for interFoam v.2.3.x). (Note that the order does again matter for some files.)
  
<insert image: all_included_files.png>
+
[[File:Eclipse_all_included_files.png|center|600px]]
  
 
Including “pEqn.H” and “UEqn.H” is optional. It is required to make the variable “UEqn” and “pEqn” known in the C-file, but it is not required to remove the errors in the case of “interFoam”, because “interFoam” does not use those variables in the C-file. The final result is then:
 
Including “pEqn.H” and “UEqn.H” is optional. It is required to make the variable “UEqn” and “pEqn” known in the C-file, but it is not required to remove the errors in the case of “interFoam”, because “interFoam” does not use those variables in the C-file. The final result is then:
  
<insert image: final_no_error_result.png>
+
[[File:Eclipse_final_no_error_result.png|center|800px]]
 +
 
 +
Now, in your “UEqn.H”, “pEqn.H” and “createFields.H” you will still see “Syntax error”. At the time of writing, it is not yet know how to solve this issue. If you do know, please share it with the rest of us. Also, as was mentioned in the disadvantages, you will not have autocompletion within these files, and F3 works only partially (it shows a list of possible functions, rather than choosing the correct function). In your C-file, however, everything works perfectly (as can be seen in the figure above). Now, if you'd copy the content of e.g. “UEqn.H” into your C file, it is fully functional: both autocompletion and F3 work flawlessly. Although it is not completely convenient to do so, this does permit us to use Eclipse's powerful features!
 +
 
 +
 
 +
 
 +
 
 +
 
 +
== Pro tips ==
 +
=== Using XML ===
 +
It is as well possible to use XML to do the above, instead of using Eclipse's GUI to add each included file one-at-a-time. Within your project directory, Eclipse has created a hidden file called “.cproject”. Within this file, the link to all included files and directories are saved. You may as well edit this file yourself, and then refresh your project inside Eclipse (select project, press F5).
 +
 
 +
For the above “interFoam” example, the following lines were added by Eclipse:
 +
 
 +
<xml><option id="gnu.cpp.compiler.option.include.paths.812006697" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/OpenFOAM/lnInclude&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/finiteVolume/lnInclude&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/OSspecific/POSIX/lnInclude&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/turbulenceModels/incompressible/turbulenceModel/lnInclude&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/transportModels/&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/transportModels/interfaceProperties/lnInclude&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/transportModels/incompressible/lnInclude&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/transportModels/twoPhaseMixture/lnInclude&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/transportModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/fvOptions/lnInclude&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/meshTools/lnInclude&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/sampling/lnInclude&quot;"/>
 +
</option>
 +
<option id="gnu.cpp.compiler.option.include.files.607748979" name="Include files (-include)" superClass="gnu.cpp.compiler.option.include.files" valueType="includeFiles">
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/finiteVolume/lnInclude/fvCFD.H&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/OpenFOAM/lnInclude/createTime.H&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/OpenFOAM/lnInclude/createMesh.H&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/fvOptions/lnInclude/fvIOoptionList.H&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/finiteVolume/lnInclude/readPISOControls.H&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/transportModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude/immiscibleIncompressibleTwoPhaseMixture.H&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${FOAM_SRC}/turbulenceModels/incompressible/turbulenceModel/lnInclude/turbulenceModel.H&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/interFoam_EclipseTut/createFields.H}&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/interFoam_EclipseTut/UEqn.H}&quot;"/>
 +
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/interFoam_EclipseTut/pEqn.H}&quot;"/>
 +
</option>
 +
<option id="gnu.cpp.compiler.option.preprocessor.def.1367553323" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
 +
<listOptionValue builtIn="false" value="WM_DP=1"/>
 +
</option>
 +
</xml>
 +
 
 +
You could as well add these lines manually to “.cproject”. This trick allows you to easily and quickly include all directories/files in a new project. So the 'labour-intensive' disadvantage is no longer a problem. The lines should be within the XML-tag “tool”, which looks something like:
 +
 
 +
<xml><tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.784993940" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
 +
 +
</tool>
 +
</xml>
  
Now, in your “UEqn.H”, “pEqn.H” and “createFields.H” you will still see “Syntax error”. I do not yet know how to solve this issue. If you do know, please share it with the rest of us. Also, as was mentioned in the disadvantages, you will not have autocompletion within these files, and F3 works only partially (it shows a list of possible functions, rather than picking the correct function by itself). In your C-file, however, everything works perfectly (as can be seen in the figure above). Now, if you'd copy the content of e.g. “UEqn.H” into your C file, it is fully functional: both autocompletion and F3 work flawlessly. Although it is not completely convenient to do so, this does permit us to use Eclipse's powerful features.
+
And while we're at it: you could do the same for the build targets (wmake and wclean).

Revision as of 13:15, 24 March 2016