CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

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

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

Like Tree2Likes
  • 2 Post By bigphil

LinkBack Thread Tools Search this Thread Display Modes
Old   December 22, 2016, 08:14
Default Can we use "astyle" to transform our code to the OpenFOAM coding style?
Super Moderator
bigphil's Avatar
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,089
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:

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 (, 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, ...):
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
aron1991 and ilhado like this.
bigphil is offline   Reply With Quote


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 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 14:24
Why do code crash when OpenFOAM is combined with VTK? Algis OpenFOAM Programming & Development 0 February 2, 2016 11:43
OpenFOAM Foundation releases OpenFOAMŪ 3.0.0 CFDFoundation OpenFOAM Announcements from OpenFOAM Foundation 1 November 7, 2015 15:16
Coupling code aster with openfoam som87 OpenFOAM Running, Solving & CFD 0 December 11, 2012 09:58
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 15:56

All times are GMT -4. The time now is 20:33.