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

Can we use "astyle" to transform our code to the OpenFOAM coding style?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By bigphil

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 22, 2016, 09:14
Default Can we use "astyle" to transform our code to the OpenFOAM coding style?
  #1
Super Moderator
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34
bigphil will become famous soon enoughbigphil will become famous soon enough
Hi all,

The OpenFOAM coding style is nicely set out here: http://openfoam.org/dev/coding-style-guide/

To conform to this style, we can of course make changes to our text editor (or IDE) config files to help us when writing the code;
alternatively, we could post-process the code files to the correct style after writing them using a tool such astyle (http://astyle.sourceforge.net), for example. The second approach is obviously helpful when people send you ugly code.

Does anybody have any advice/thoughts/experience on using a post-processing tool to clean-up code?

From a quick look through the astyle documentation, I have found that using the following command gets close, but it is not quite correct (e.g. operators + and - should be padded by spaces but * and / should not; also indentations seem to be 8 spaces in some places, ...):
Code:
astyle --style=bsd --indent=spaces=4 --indent-classes --indent-col1-comments --break-blocks --pad-oper --pad-header --delete-empty-lines --align-pointer=type --align-reference=type --convert-tabs --max-code-length=80 --mode=c myOpenFOAMClass.C
Philip
aron1991 and ilhado like this.
bigphil 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
OpenFOAM v3.0+ ?? SBusch OpenFOAM 22 December 26, 2016 15:24
Why do code crash when OpenFOAM is combined with VTK? Algis OpenFOAM Programming & Development 0 February 2, 2016 12:43
OpenFOAM Foundation releases OpenFOAMŪ 3.0.0 CFDFoundation OpenFOAM Announcements from OpenFOAM Foundation 1 November 7, 2015 16:16
Coupling code aster with openfoam som87 OpenFOAM Running, Solving & CFD 0 December 11, 2012 10:58
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 16:56


All times are GMT -4. The time now is 13:37.