CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Pre-Processing

vim Addon Highlight for OpenFOAM

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

Like Tree11Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   April 1, 2012, 14:15
Default vim Addon Highlight for OpenFOAM
  #1
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi all together,

i am working with OpenFOAM and vim for changing all the files. When i work with bash or c++ the nice thing is, that vim highlight the code so i decided to create a vim highlight for the standard openFOAM case files.

I am not sure if that is helpful for anybody but i wanna share it with you. Its just a beta version and not an accurate tool. I fixed some bugs but there are still some and i implemented just the standard boundary conditions and solvers.

You can give me a feedback and i ll work on a new version for that.

you can download it on:

www.holzmann-cfd.de on the button "Skripte & Addons"

Greetings
Tobi
Attached Images
File Type: jpg vimAddon.jpg (18.1 KB, 152 views)
Tobi is offline   Reply With Quote

Old   April 3, 2012, 15:15
Default
  #2
Senior Member
 
sail's Avatar
 
Vieri Abolaffio
Join Date: Jul 2010
Location: Always on the move.
Posts: 308
Rep Power: 8
sail is on a distinguished road
Hi Tobi.

Tahnks for sharing. your script seems very useful. Unfortunately i wasn't able to get it because i get an error 404 when i try to download it.

hope it is not an april's fool joke

regards

Edit: I've been succesfull eliminating the 1.1 in the filename. is it still the latest and gratest version?
__________________
http://www.leadingedge.it/
Naval architecture and CFD consultancy
sail is offline   Reply With Quote

Old   April 3, 2012, 17:16
Default
  #3
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi,

thx for the error report.
that was not really a april joke
i uploaded the file but did not rename it to 1.1 - now i ve renamed the file and the download is working.

And yes - its still the latest version.
Let me know if its useful for you!


tobi
Tobi is offline   Reply With Quote

Old   April 4, 2012, 03:33
Default
  #4
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
Nice work Tobias! Thanks for this.

I upgraded your install-script a bit, so that it will also work for non-root users of VIm
Code:
mkdir -p $HOME/.vim
mkdir -p $HOME/.vim/syntax
mkdir -p $HOME/.vim/colors

cp -i syntax/openfoam.vim $HOME/.vim/syntax/
cp -i scripts.vim $HOME/.vim/
#cat .vimrc >> $HOME/.vimrc
cp -i colors/openfoamcolor.vim $HOME/.vim/colors
Also, for the installscript, it may better to be a bit more careful with .vimrc and .vim/scripts. I can imagine that it may be better to cat >>
Bernhard is offline   Reply With Quote

Old   April 4, 2012, 12:10
Default
  #5
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
hi berhard,

thx for that new code.
i update my install file now

Thx.

Tobi


PS: the suggestion with cat is very good. I ll write a readme with short information!

Last edited by Tobi; April 4, 2012 at 12:29.
Tobi is offline   Reply With Quote

Old   April 7, 2012, 09:00
Default
  #6
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi all,

a new version of the vim Addon for OpenFOAM is avaiable on my homepage.

Have fun!

Tobi
Tobi is offline   Reply With Quote

Old   April 22, 2012, 08:37
Default
  #7
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
HI all,

its avaiable on git

https://github.com/shor-ty/vimExtensionOF

Tobi
Tobi is offline   Reply With Quote

Old   April 26, 2012, 01:43
Default
  #8
Senior Member
 
Karl-Johan Nogenmyr
Join Date: Mar 2009
Location: Linköping
Posts: 255
Rep Power: 12
kalle is on a distinguished road
Nice! Thanks for sharing!

Some mod may make it more precise though:

Code:
let cnum = 1
while 1
   if (getline(cnum) =~ 'FoamFile')
      setfiletype openfoam
      colorscheme openfoamcolorBlackWhite
      break
   elseif (cnum == 20)
      break
   endif
   let cnum += 1
endwhile


Kalle
Tobi likes this.
kalle is offline   Reply With Quote

Old   April 26, 2012, 12:04
Default
  #9
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
sounds very good - i ll implement it next week when I am back on my personal computer

thanks good idea


>>> Changed <<<

Last edited by Tobi; April 27, 2012 at 02:45.
Tobi is offline   Reply With Quote

Old   March 14, 2013, 04:40
Default
  #10
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi all,

I made some changes during the last half year.

Now I ll update for the version 2.2.x and adding new keywords.

Have fun.
Bernhard likes this.
Tobi is offline   Reply With Quote

Old   March 14, 2013, 09:24
Default
  #11
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Quote:
Originally Posted by Tobi View Post
Hi all together,


you can download it on:

www.holzmann-cfd.de on the button "Skripte & Addons"
The new links is:

http://www.holzmann-cfd.de/index.php...im-highlighter
Tobi is offline   Reply With Quote

Old   November 30, 2013, 16:09
Default
  #12
New Member
 
Karel Vacha
Join Date: Nov 2013
Location: Czech Republic
Posts: 1
Rep Power: 0
Karel is on a distinguished road
Hi,

thanks for sharing this, it works perfectly.
I have been using highlighting for c++ till now, but this one is much better.

Karel
Tobi likes this.
Karel is offline   Reply With Quote

Old   December 2, 2013, 07:48
Default
  #13
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi Karel,

thanks for your feedback.

I am going to extend the keywords in my winter holyday.

I Keep you posted
Tobi is offline   Reply With Quote

Old   December 2, 2013, 08:48
Default
  #14
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
What might help you, is the following command from the $FOAM_SRC directory.

Code:
grep -oh "TypeName(\"[A-Za-z0-9]*\")" -r * | cut -d\" -f2
TypeName defines the name in the runtime selectiontable, so this is basically what you put in all the dictionaries
Tobi likes this.
Bernhard is offline   Reply With Quote

Old   November 4, 2014, 06:38
Default
  #15
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hello all,

I added new keywords to the vim Extension and also changed the tab size to 4 spaces.
At the moment I switch all my repositories from github to the bitbucket server. Therefor you find the latest version here:

https://bitbucket.org/shor-ty/vimextensionopenfoam
__________________
Best regards,
Tobias Holzmann

Some interesting OpenFOAM tutorials and videos on www.Holzmann-cfd.de
Tobi is offline   Reply With Quote

Old   November 17, 2014, 10:50
Default
  #16
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hello all,

I reorganized the file tree in the vim extension. Now you can add things very easy and it looks like the openfoam tree:
Code:
.
├── openfoam
│   ├── 0
│   │   ├── BC.vim
│   │   └── foamVariables.vim
│   ├── constant
│   │   ├── polyMesh
│   │   │   ├── blockMeshDict.vim
│   │   │   └── boundary.vim
│   │   ├── radiationProperties.vim
│   │   ├── RASProperties.vim
│   │   ├── regionProperties.vim
│   │   ├── solidThermophysicalProperties.vim
│   │   ├── thermodynamicProperties.vim
│   │   ├── transportProperties.vim
│   │   └── turbulenceProperties.vim
│   ├── general.vim
│   └── system
│       ├── changeDictionaryDict.vim
│       ├── controlDictFunctions.vim
│       ├── controlDict.vim
│       ├── decomposePar.vim
│       ├── fvSchemes.vim
│       ├── fvSolution.vim
│       ├── setFieldsDict.vim
│       └── snappyHexMeshDict.vim
└── openfoam.vim
If you want to add new syntax highlighting, just add a new file or edit the existing one.
The next days I will check out the colour schemes again to be more flexible.

Additionally I added a new check in the install script.
Have fun,...
__________________
Best regards,
Tobias Holzmann

Some interesting OpenFOAM tutorials and videos on www.Holzmann-cfd.de
Tobi is offline   Reply With Quote

Old   November 18, 2014, 11:05
Default
  #17
Member
 
Logan Page
Join Date: Sep 2010
Posts: 38
Rep Power: 6
Logan Page is on a distinguished road
Out of interest what addon/s do you use for code completion, jumping around the OpenFoam source code, compiling, debugging, etc. in vim?
Logan Page is offline   Reply With Quote

Old   November 19, 2014, 15:51
Default
  #18
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Dear all,

I am happy to let you know that I finished the version 3.0.
This contains a lot news. Especially the syntax in the files which looks like that now:
Code:
"----------------------------------------------"
" Contributor: Tobias Holzmann                 "
" Last Change: November 2014                   "
" Version:     3.0                             "
" Email:       Tobias.Holzmann@Holzmann-cfd.de "
"----------------------------------------------"


" thermophysicalProperties
"-------------------------------------------------------------------------------


    "- Special behavior of specie mixture
    syn match thermodynamicSpecie2
    \ " \=specie\{1} \=
    \\| \=mixture\{1} \="
    hi link thermodynamicSpecie2 foam256_keyOnLeftSide


    "- Special behavior of specie at the end
    syn match thermodynamicSpecie1
    \ " \{1}specie\{1};\{1}"
    hi link thermodynamicSpecie1 foam256_keyOnRightSide


    "- Dictionarys (main)
    syn match thermodynamicDict
    \ "^thermoType
    \\|^mixture"
    hi link thermodynamicDict foam256_dictionary


    "- Special keywords on the left side
    syn keyword thermodynamicKeys
    \ thermo
    \ equationOfState
    \ energy
    \ thermodynamics
    \ transport
    hi link thermodynamicKeys foam256_keyOnLeftSide


    "- Thermodynamic models etc.
    syn keyword thermodynamicSettings
    \ nMoles
    \ molWeight
    \ Tlow
    \ Tcommon
    \ Thigh
    \ highCpCoeffs
    \ lowCpCoeffs
    \ CpCoeffs
    \ muCoeffs
    \ kappaCoeffs
  • code is much more readable
  • line size of each line is limited to 80 characters
  • additional checkouts in the script.vim to check in a better way and let the color be more consistent
  • I also created a bash function which will check automatically the available BC and insert them to the file (at the moment not published, but I will insert it)
  • New color schemes with 256 color support now and its a lot easier to change the colors now and modify it like you want
  • A lot of new keywords added


Available at bitbucket.org/shor-ty


I hope its useful for anybody using vim!
Feel free to modify the files and push it to the repository.



@Logan: Plugins for C++, Jumping with buffers and ":b# or number" for compiling I think you can do it because you can do everything in vim. I have to look for that.
__________________
Best regards,
Tobias Holzmann

Some interesting OpenFOAM tutorials and videos on www.Holzmann-cfd.de
Tobi is offline   Reply With Quote

Old   November 20, 2014, 06:53
Default
  #19
Member
 
Logan Page
Join Date: Sep 2010
Posts: 38
Rep Power: 6
Logan Page is on a distinguished road
Here is what I've been able to sort out in vim to get it to be a complete IDE for OpenFOAM


Syntax Highlighting:
At the moment I'm using standard C++ syntax highlighting, but will be trying out Tobi's addon soon.

Code completion and jumping to definitions/declarations etc:

I was able to get the YouCompleteMe addon for vim (https://github.com/Valloric/YouCompleteMe) to work very nicely with OpenFoam.

Compiling:
A simple key binding to wmake in vim
Code:
nmap <silent> <Leader>mf :!wmake %:p:h<CR>
Debugging:
Haven't looked into this yet
Tobi likes this.
Logan Page is offline   Reply With Quote

Old   November 20, 2014, 06:59
Default
  #20
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,086
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Please notice that my stuff is not for coding.
Its only for the openfoam cases.

For completition also use
Code:
CTRL-N or P
And the wmake - its clear (:

Thanks for the link for code completition. I think its similar to: http://www.vim.org/scripts/script.php?script_id=1520
Maybe this would be very nice to have in the FOAM files too!
__________________
Best regards,
Tobias Holzmann

Some interesting OpenFOAM tutorials and videos on www.Holzmann-cfd.de
Tobi is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 14:50.