From 92bb9316476caf209f1b09e0011ec0c5574b995b Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Thu, 21 Aug 2014 18:39:38 +0100 Subject: [PATCH] Coordinate systems in degrees I/O bug fix --- src/foam/coordinateSystems/coordinateSystem.H | 34 +++++++++---------- src/foam/coordinateSystems/cylindricalCS.C | 28 +++++++++++++-- src/foam/coordinateSystems/cylindricalCS.H | 14 ++++++-- .../coordinateSystems/ellipticCylindricalCS.C | 27 ++++++++++++++- .../coordinateSystems/ellipticCylindricalCS.H | 14 ++++++-- .../parabolicCylindricalCS.C | 28 +++++++++++++-- .../parabolicCylindricalCS.H | 14 ++++++-- src/foam/coordinateSystems/sphericalCS.C | 28 +++++++++++++-- src/foam/coordinateSystems/sphericalCS.H | 13 +++++-- src/foam/coordinateSystems/toroidalCS.C | 6 ++-- src/foam/coordinateSystems/toroidalCS.H | 7 ++-- .../constant/polyMesh/blockMeshDict.m4 | 8 ++--- .../simpleFoam/mixingPlaneDomADomB/boundary | 2 +- .../constant/polyMesh/boundary | 2 +- 14 files changed, 180 insertions(+), 45 deletions(-) diff --git a/src/foam/coordinateSystems/coordinateSystem.H b/src/foam/coordinateSystems/coordinateSystem.H index 774c0b6b9..de077199f 100644 --- a/src/foam/coordinateSystems/coordinateSystem.H +++ b/src/foam/coordinateSystems/coordinateSystem.H @@ -402,31 +402,31 @@ public: virtual dictionary dict(bool ignoreType = false) const; - // Edit + // Edit - //- Rename - virtual void rename(const word& newName) - { - name_ = newName; - } + //- Rename + virtual void rename(const word& newName) + { + name_ = newName; + } - //- Edit access to origin - point& origin() - { - return origin_; - } + //- Edit access to origin + point& origin() + { + return origin_; + } - // Write + // Write - //- Write - virtual void write(Ostream&) const; + //- Write + virtual void write(Ostream&) const; - //- Write dictionary - virtual void writeDict(Ostream&, bool subDict = true) const; + //- Write dictionary + virtual void writeDict(Ostream&, bool subDict = true) const; - // Transformations + // Transformations //- Convert from position in local coordinate system to // global Cartesian position diff --git a/src/foam/coordinateSystems/cylindricalCS.C b/src/foam/coordinateSystems/cylindricalCS.C index 262dd4ff2..455cf67a1 100644 --- a/src/foam/coordinateSystems/cylindricalCS.C +++ b/src/foam/coordinateSystems/cylindricalCS.C @@ -25,7 +25,6 @@ License #include "cylindricalCS.H" -#include "Switch.H" #include "mathematicalConstants.H" #include "boundBox.H" #include "addToRunTimeSelectionTable.H" @@ -152,7 +151,7 @@ bool Foam::cylindricalCS::inDegrees() const } -bool& Foam::cylindricalCS::inDegrees() +Foam::Switch& Foam::cylindricalCS::inDegrees() { return inDegrees_; } @@ -254,4 +253,29 @@ Foam::tmp Foam::cylindricalCS::globalToLocal } +void Foam::cylindricalCS::write(Ostream& os) const +{ + coordinateSystem::write(os); + os << "inDegrees: " << inDegrees() << endl; +} + + +void Foam::cylindricalCS::writeDict(Ostream& os, bool subDict) const +{ + if (subDict) + { + os << indent << nl + << indent << token::BEGIN_BLOCK << incrIndent << nl; + } + + coordinateSystem::writeDict(os, false); + os.writeKeyword("inDegrees") << inDegrees_ << token::END_STATEMENT << nl; + + if (subDict) + { + os << decrIndent << indent << token::END_BLOCK << endl; + } +} + + // ************************************************************************* // diff --git a/src/foam/coordinateSystems/cylindricalCS.H b/src/foam/coordinateSystems/cylindricalCS.H index c5a036b2f..6fbda90cd 100644 --- a/src/foam/coordinateSystems/cylindricalCS.H +++ b/src/foam/coordinateSystems/cylindricalCS.H @@ -36,7 +36,7 @@ SourceFiles #define cylindricalCS_H #include "coordinateSystem.H" -#include "typeInfo.H" +#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,7 +54,7 @@ class cylindricalCS // Private data members //- Are angles in degrees? (default = true) - bool inDegrees_; + Switch inDegrees_; protected: @@ -156,8 +156,16 @@ public: bool inDegrees() const; //- Non-const access to inDegrees - bool& inDegrees(); + Switch& inDegrees(); + + // Write + + //- Write + virtual void write(Ostream&) const; + + //- Write dictionary + virtual void writeDict(Ostream&, bool subDict = true) const; }; diff --git a/src/foam/coordinateSystems/ellipticCylindricalCS.C b/src/foam/coordinateSystems/ellipticCylindricalCS.C index 20ac5b1e1..107dea3a4 100644 --- a/src/foam/coordinateSystems/ellipticCylindricalCS.C +++ b/src/foam/coordinateSystems/ellipticCylindricalCS.C @@ -165,7 +165,7 @@ bool Foam::ellipticCylindricalCS::inDegrees() const } -bool& Foam::ellipticCylindricalCS::inDegrees() +Foam::Switch& Foam::ellipticCylindricalCS::inDegrees() { return inDegrees_; } @@ -255,4 +255,29 @@ Foam::tmp Foam::ellipticCylindricalCS::globalToLocal } +void Foam::ellipticCylindricalCS::write(Ostream& os) const +{ + coordinateSystem::write(os); + os << "inDegrees: " << inDegrees() << endl; +} + + +void Foam::ellipticCylindricalCS::writeDict(Ostream& os, bool subDict) const +{ + if (subDict) + { + os << indent << nl + << indent << token::BEGIN_BLOCK << incrIndent << nl; + } + + coordinateSystem::writeDict(os, false); + os.writeKeyword("inDegrees") << inDegrees_ << token::END_STATEMENT << nl; + + if (subDict) + { + os << decrIndent << indent << token::END_BLOCK << endl; + } +} + + // ************************************************************************* // diff --git a/src/foam/coordinateSystems/ellipticCylindricalCS.H b/src/foam/coordinateSystems/ellipticCylindricalCS.H index 6efb8fe51..77f4d3818 100644 --- a/src/foam/coordinateSystems/ellipticCylindricalCS.H +++ b/src/foam/coordinateSystems/ellipticCylindricalCS.H @@ -44,6 +44,7 @@ Authors #define ellipticCylindricalCS_H #include "coordinateSystem.H" +#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -64,7 +65,7 @@ class ellipticCylindricalCS const scalar a_; //- Are angles in degrees? (default = true) - bool inDegrees_; + Switch inDegrees_; protected: @@ -171,7 +172,16 @@ public: bool inDegrees() const; //- Non-const access to inDegrees - bool& inDegrees(); + Switch& inDegrees(); + + + // Write + + //- Write + virtual void write(Ostream&) const; + + //- Write dictionary + virtual void writeDict(Ostream&, bool subDict = true) const; }; diff --git a/src/foam/coordinateSystems/parabolicCylindricalCS.C b/src/foam/coordinateSystems/parabolicCylindricalCS.C index 3d0586738..bdb9aacc9 100644 --- a/src/foam/coordinateSystems/parabolicCylindricalCS.C +++ b/src/foam/coordinateSystems/parabolicCylindricalCS.C @@ -25,7 +25,6 @@ License #include "parabolicCylindricalCS.H" #include "mathematicalConstants.H" -#include "Switch.H" #include "boundBox.H" #include "addToRunTimeSelectionTable.H" @@ -119,7 +118,7 @@ bool Foam::parabolicCylindricalCS::inDegrees() const } -bool& Foam::parabolicCylindricalCS::inDegrees() +Foam::Switch& Foam::parabolicCylindricalCS::inDegrees() { return inDegrees_; } @@ -227,4 +226,29 @@ Foam::tmp Foam::parabolicCylindricalCS::globalToLocal } +void Foam::parabolicCylindricalCS::write(Ostream& os) const +{ + coordinateSystem::write(os); + os << "inDegrees: " << inDegrees() << endl; +} + + +void Foam::parabolicCylindricalCS::writeDict(Ostream& os, bool subDict) const +{ + if (subDict) + { + os << indent << nl + << indent << token::BEGIN_BLOCK << incrIndent << nl; + } + + coordinateSystem::writeDict(os, false); + os.writeKeyword("inDegrees") << inDegrees_ << token::END_STATEMENT << nl; + + if (subDict) + { + os << decrIndent << indent << token::END_BLOCK << endl; + } +} + + // ************************************************************************* // diff --git a/src/foam/coordinateSystems/parabolicCylindricalCS.H b/src/foam/coordinateSystems/parabolicCylindricalCS.H index ceac77522..8e0bcafcc 100644 --- a/src/foam/coordinateSystems/parabolicCylindricalCS.H +++ b/src/foam/coordinateSystems/parabolicCylindricalCS.H @@ -41,6 +41,7 @@ SourceFiles #define parabolicCylindricalCS_H #include "coordinateSystem.H" +#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -58,7 +59,7 @@ class parabolicCylindricalCS // Private data members //- Are angles in degrees? (default = true) - bool inDegrees_; + Switch inDegrees_; protected: @@ -134,7 +135,16 @@ public: bool inDegrees() const; //- Non-const access to inDegrees - bool& inDegrees(); + Switch& inDegrees(); + + + // Write + + //- Write + virtual void write(Ostream&) const; + + //- Write dictionary + virtual void writeDict(Ostream&, bool subDict = true) const; }; diff --git a/src/foam/coordinateSystems/sphericalCS.C b/src/foam/coordinateSystems/sphericalCS.C index 299abb3d4..85d54c6fd 100644 --- a/src/foam/coordinateSystems/sphericalCS.C +++ b/src/foam/coordinateSystems/sphericalCS.C @@ -26,7 +26,6 @@ License #include "sphericalCS.H" #include "one.H" -#include "Switch.H" #include "mathematicalConstants.H" #include "boundBox.H" #include "addToRunTimeSelectionTable.H" @@ -150,7 +149,7 @@ bool Foam::sphericalCS::inDegrees() const } -bool& Foam::sphericalCS::inDegrees() +Foam::Switch& Foam::sphericalCS::inDegrees() { return inDegrees_; } @@ -274,4 +273,29 @@ Foam::tmp Foam::sphericalCS::globalToLocal } +void Foam::sphericalCS::write(Ostream& os) const +{ + coordinateSystem::write(os); + os << "inDegrees: " << inDegrees() << endl; +} + + +void Foam::sphericalCS::writeDict(Ostream& os, bool subDict) const +{ + if (subDict) + { + os << indent << nl + << indent << token::BEGIN_BLOCK << incrIndent << nl; + } + + coordinateSystem::writeDict(os, false); + os.writeKeyword("inDegrees") << inDegrees_ << token::END_STATEMENT << nl; + + if (subDict) + { + os << decrIndent << indent << token::END_BLOCK << endl; + } +} + + // ************************************************************************* // diff --git a/src/foam/coordinateSystems/sphericalCS.H b/src/foam/coordinateSystems/sphericalCS.H index ab9d540b9..801881b9e 100644 --- a/src/foam/coordinateSystems/sphericalCS.H +++ b/src/foam/coordinateSystems/sphericalCS.H @@ -36,6 +36,7 @@ SourceFiles #define sphericalCS_H #include "coordinateSystem.H" +#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,7 +54,7 @@ class sphericalCS // Private data members //- Are angles in degrees? (default = true) - bool inDegrees_; + Switch inDegrees_; protected: @@ -154,8 +155,16 @@ public: bool inDegrees() const; //- Non-const access to inDegrees - bool& inDegrees(); + Switch& inDegrees(); + + // Write + + //- Write + virtual void write(Ostream&) const; + + //- Write dictionary + virtual void writeDict(Ostream&, bool subDict = true) const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/foam/coordinateSystems/toroidalCS.C b/src/foam/coordinateSystems/toroidalCS.C index 4101496bd..59ae33326 100644 --- a/src/foam/coordinateSystems/toroidalCS.C +++ b/src/foam/coordinateSystems/toroidalCS.C @@ -25,7 +25,6 @@ License #include "toroidalCS.H" #include "mathematicalConstants.H" -#include "Switch.H" #include "boundBox.H" #include "addToRunTimeSelectionTable.H" @@ -106,7 +105,7 @@ bool Foam::toroidalCS::inDegrees() const } -bool& Foam::toroidalCS::inDegrees() +Foam::Switch& Foam::toroidalCS::inDegrees() { return inDegrees_; } @@ -205,7 +204,7 @@ void Foam::toroidalCS::writeDict(Ostream& os, bool subDict) const { if (subDict) { - os << indent << name() << nl + os << indent << nl << indent << token::BEGIN_BLOCK << incrIndent << nl; } @@ -218,4 +217,5 @@ void Foam::toroidalCS::writeDict(Ostream& os, bool subDict) const } } + // ************************************************************************* // diff --git a/src/foam/coordinateSystems/toroidalCS.H b/src/foam/coordinateSystems/toroidalCS.H index d8c5acc63..61ce8ea60 100644 --- a/src/foam/coordinateSystems/toroidalCS.H +++ b/src/foam/coordinateSystems/toroidalCS.H @@ -39,6 +39,7 @@ SourceFiles #define toroidalCS_H #include "coordinateSystem.H" +#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,7 +61,7 @@ class toroidalCS scalar radius_; //- Are angles in degrees? (default = true) - bool inDegrees_; + Switch inDegrees_; // Private Member Functions @@ -133,7 +134,7 @@ public: bool inDegrees() const; //- Non-const access to inDegrees - bool& inDegrees(); + Switch& inDegrees(); //- Return radius scalar radius() const @@ -145,7 +146,7 @@ public: virtual void write(Ostream&) const; //- Write dictionary - virtual void writeDict(Ostream&, bool subDict=true) const; + virtual void writeDict(Ostream&, bool subDict = true) const; }; diff --git a/tutorials/incompressible/MRFSimpleFoam/axialTurbine_mixingPlane/constant/polyMesh/blockMeshDict.m4 b/tutorials/incompressible/MRFSimpleFoam/axialTurbine_mixingPlane/constant/polyMesh/blockMeshDict.m4 index 18d24fd98..d75c949a9 100644 --- a/tutorials/incompressible/MRFSimpleFoam/axialTurbine_mixingPlane/constant/polyMesh/blockMeshDict.m4 +++ b/tutorials/incompressible/MRFSimpleFoam/axialTurbine_mixingPlane/constant/polyMesh/blockMeshDict.m4 @@ -290,7 +290,7 @@ boundary origin (0 0 0); axis (0 0 1); direction (1 0 0); - degrees false; //Use radians + inDegrees false; //Use radians //Equivalent axis/direction definition: //e3 (0 0 1); //e1 (1 0 0); @@ -376,7 +376,7 @@ boundary origin (0 0 0); axis (0 0 1); direction (1 0 0); - degrees false; //Use radians + inDegrees false; //Use radians //Equivalent axis/direction definition: //e3 (0 0 1); //e1 (1 0 0); @@ -405,7 +405,7 @@ boundary origin (0 0 0); axis (0 0 1); direction (1 0 0); - degrees false; //Use radians + inDegrees false; //Use radians //Equivalent axis/direction definition: //e3 (0 0 1); //e1 (1 0 0); @@ -498,7 +498,7 @@ boundary origin (0 0 0); axis (0 0 1); direction (1 0 0); - degrees false; //Use radians + inDegrees false; //Use radians //Equivalent axis/direction definition: //e3 (0 0 1); //e1 (1 0 0); diff --git a/tutorials/incompressible/simpleFoam/mixingPlaneDomADomB/boundary b/tutorials/incompressible/simpleFoam/mixingPlaneDomADomB/boundary index 5d37d27fa..875051598 100644 --- a/tutorials/incompressible/simpleFoam/mixingPlaneDomADomB/boundary +++ b/tutorials/incompressible/simpleFoam/mixingPlaneDomADomB/boundary @@ -55,7 +55,7 @@ FoamFile origin (0 0 0); e1 (1 0 0); e3 (0 0 1); - degrees false; //Use radians + inDegrees false; //Use radians } ribbonPatch { diff --git a/tutorials/incompressible/simpleFoam/mixingPlaneDomADomB/constant/polyMesh/boundary b/tutorials/incompressible/simpleFoam/mixingPlaneDomADomB/constant/polyMesh/boundary index 5d37d27fa..875051598 100644 --- a/tutorials/incompressible/simpleFoam/mixingPlaneDomADomB/constant/polyMesh/boundary +++ b/tutorials/incompressible/simpleFoam/mixingPlaneDomADomB/constant/polyMesh/boundary @@ -55,7 +55,7 @@ FoamFile origin (0 0 0); e1 (1 0 0); e3 (0 0 1); - degrees false; //Use radians + inDegrees false; //Use radians } ribbonPatch {