|
[Sponsors] |
April 29, 2009, 18:35 |
Foam Version as a compile-time macro
|
#1 |
Senior Member
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25 |
Just a suggestion, but perhaps it would be useful to have the Foam version as a compile-time macro. For example, something like this for OF-1.5:
#define FOAM_MAJOR_REVISION 1 #define FOAM_MINOR_REVISION 5 Or something on similar lines (Maybe passed in to g++ with a -D option). Considering how member functions change over revisions, (like faceOwner instead of allOwner in polyMesh, for instance), backward compatibility is sometimes an issue. I agree that it makes code uglier because of #ifdefs all around the source code, but it might be handy to have... |
|
May 25, 2009, 05:36 |
|
#2 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,694
Rep Power: 40 |
Quote:
For example, 1.5 == -DPROJECT_VERSION=1005000. Unfortunately this breaks down horribly when versions contain non-digits (eg, like 1.5.x). I would thus avoid using it at all. IMO the better method is to keep your code up-to-date with the latest developments and use branching within git if you also need to maintain code for legacy versions. This is not only much cleanier to read than piles of #ifdefs, but also avoids strange and possibly hard to trace bugs. For example, if you'd moved from 1.5 to 1.5.x, the wrong chunk would get evaluated here: Code:
#if PROJECT_VERSION >= 1005000 chunk1 ... #else chunk2 ... #endif |
||
January 7, 2019, 02:13 |
|
#3 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,694
Rep Power: 40 |
Quote:
Someone brought this old thread back to my attention, so I figured it could make sense to update it. The OPENFOAM compiler define, which is a 4-digit value corresponding to the api version, can be used for transitional features etc. Eg, Code:
#if (OPENFOAM >= 1812) Info<< "using some OpenFOAM-v1812 version" << nl; #else Info<< "using some other version" << nl; #endif The value is defined within the wmake rules, so it should correspond to the currently active OpenFOAM environment/version. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Physical Reason for stability of Implicit Schemes? | radhakrishnan | Main CFD Forum | 26 | October 3, 2023 22:05 |
SimpleFoam k and epsilon bounded | nedved | OpenFOAM Running, Solving & CFD | 16 | March 4, 2017 08:30 |
Superlinear speedup in OpenFOAM 13 | msrinath80 | OpenFOAM Running, Solving & CFD | 18 | March 3, 2015 05:36 |
IcoFoam parallel woes | msrinath80 | OpenFOAM Running, Solving & CFD | 9 | July 22, 2007 02:58 |
unsteady calcs in FLUENT | Sanjay Padhiar | Main CFD Forum | 1 | March 31, 1999 12:32 |