diff --git a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C index 6d6e81d444bbdaeb71ac5fcfe69fda785556b900..179836560a0c25dfb37474173472d0da79d798e7 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -195,7 +195,17 @@ void Foam::EulerCoordinateRotation::calcTransform Foam::EulerCoordinateRotation::EulerCoordinateRotation() : R_(sphericalTensor::I), - Rtr_(R_) + Rtr_(sphericalTensor::I) +{} + + +Foam::EulerCoordinateRotation::EulerCoordinateRotation +( + const EulerCoordinateRotation& r +) +: + R_(r.R_), + Rtr_(r.Rtr_) {} @@ -206,7 +216,7 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation ) : R_(sphericalTensor::I), - Rtr_(R_) + Rtr_(sphericalTensor::I) { calcTransform ( @@ -227,7 +237,7 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation ) : R_(sphericalTensor::I), - Rtr_(R_) + Rtr_(sphericalTensor::I) { calcTransform(phiAngle, thetaAngle, psiAngle, inDegrees); } @@ -239,9 +249,9 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation ) : R_(sphericalTensor::I), - Rtr_(R_) + Rtr_(sphericalTensor::I) { - vector rotation(dict.lookup("rotation")); + const vector rotation(dict.lookup("rotation")); calcTransform ( @@ -259,36 +269,8 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation const objectRegistry& ) : - R_(sphericalTensor::I), - Rtr_(R_) -{ - vector rotation(dict.lookup("rotation")); - - calcTransform - ( - rotation.component(vector::X), - rotation.component(vector::Y), - rotation.component(vector::Z), - dict.lookupOrDefault("degrees", true) - ); -} - - -Foam::EulerCoordinateRotation::EulerCoordinateRotation -( - const EulerCoordinateRotation& r -) -: - R_(r.R_), - Rtr_(r.Rtr_) + EulerCoordinateRotation(dict) {} -void Foam::EulerCoordinateRotation::write(Ostream& os) const -{ - os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl; - os.writeKeyword("e2") << e2() << token::END_STATEMENT << nl; - os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl; -} - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H index 984df3912d9732c9eef5c798c0409067d163c90b..53ee185b68e95af8bb8bbf27d6c4f6cfb4d5215e 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -91,7 +91,7 @@ class EulerCoordinateRotation const scalar phiAngle, const scalar thetaAngle, const scalar psiAngle, - const bool inDegrees=true + const bool inDegrees ); @@ -106,11 +106,14 @@ public: //- Construct null EulerCoordinateRotation(); + //- Construct as copy + EulerCoordinateRotation(const EulerCoordinateRotation& r); + //- Construct from rotation vector EulerCoordinateRotation ( const vector& phiThetaPsi, - const bool inDegrees=true + const bool inDegrees ); //- Construct from components of rotation vector @@ -119,17 +122,18 @@ public: const scalar phiAngle, const scalar thetaAngle, const scalar psiAngle, - const bool inDegrees=true + const bool inDegrees ); //- Construct from dictionary - EulerCoordinateRotation(const dictionary&); - - //- Construct from dictionary and mesh - EulerCoordinateRotation(const dictionary&, const objectRegistry&); + explicit EulerCoordinateRotation(const dictionary& dict); - //- Construct as copy - EulerCoordinateRotation(const EulerCoordinateRotation&); + //- Construct from dictionary and a registry (typically a mesh) + EulerCoordinateRotation + ( + const dictionary& dict, + const objectRegistry& unused + ); //- Return clone autoPtr<coordinateRotation> clone() const @@ -226,11 +230,6 @@ public: // symmetrical tensor virtual symmTensor transformVector(const vector& st) const; - - // Write - - //- Write - virtual void write(Ostream&) const; }; diff --git a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C index 24538ba0577c424b9973a2d0fe29f326d57b4072..e6a50a25d618947a709b71467f7f731c6b82c45b 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -147,6 +147,7 @@ Foam::symmTensor Foam::STARCDCoordinateRotation::transformVector return transformPrincipal(R_, st); } + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::STARCDCoordinateRotation::calcTransform @@ -195,7 +196,17 @@ void Foam::STARCDCoordinateRotation::calcTransform Foam::STARCDCoordinateRotation::STARCDCoordinateRotation() : R_(sphericalTensor::I), - Rtr_(R_) + Rtr_(sphericalTensor::I) +{} + + +Foam::STARCDCoordinateRotation::STARCDCoordinateRotation +( + const STARCDCoordinateRotation& r +) +: + R_(r.R_), + Rtr_(r.Rtr_) {} @@ -206,7 +217,7 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation ) : R_(sphericalTensor::I), - Rtr_(R_) + Rtr_(sphericalTensor::I) { calcTransform ( @@ -227,7 +238,7 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation ) : R_(sphericalTensor::I), - Rtr_(R_) + Rtr_(sphericalTensor::I) { calcTransform(rotZ, rotX, rotY, inDegrees); } @@ -239,9 +250,9 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation ) : R_(sphericalTensor::I), - Rtr_(R_) + Rtr_(sphericalTensor::I) { - vector rotation(dict.lookup("rotation")); + const vector rotation(dict.lookup("rotation")); calcTransform ( @@ -258,34 +269,9 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation const dictionary& dict, const objectRegistry& ) -{ - vector rotation(dict.lookup("rotation")); - - calcTransform - ( - rotation.component(vector::X), - rotation.component(vector::Y), - rotation.component(vector::Z), - dict.lookupOrDefault("degrees", true) - ); -} - - -Foam::STARCDCoordinateRotation::STARCDCoordinateRotation -( - const STARCDCoordinateRotation& r -) : - R_(r.R_), - Rtr_(r.Rtr_) + STARCDCoordinateRotation(dict) {} -void Foam::STARCDCoordinateRotation::write(Ostream& os) const -{ - os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl; - os.writeKeyword("e2") << e2() << token::END_STATEMENT << nl; - os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl; -} - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H index e25507005837d1350ff439d0dac5f7ea780fc353..b76da859d196abac32fc384206676baa5660108a 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -83,7 +83,7 @@ class STARCDCoordinateRotation const scalar rotZ, const scalar rotX, const scalar rotY, - const bool inDegrees=true + const bool inDegrees ); @@ -98,11 +98,14 @@ public: //- Construct null STARCDCoordinateRotation(); + //- Construct as copy + STARCDCoordinateRotation(const STARCDCoordinateRotation& r); + //- Construct from rotation vector STARCDCoordinateRotation ( const vector& rotZrotXrotY, - const bool inDegrees=true + const bool inDegrees ); //- Construct from components of rotation vector @@ -111,17 +114,19 @@ public: const scalar rotZ, const scalar rotX, const scalar rotY, - const bool inDegrees=true + const bool inDegrees ); //- Construct from dictionary - STARCDCoordinateRotation(const dictionary&); + explicit STARCDCoordinateRotation(const dictionary& dict); - //- Construct from dictionary and mesh - STARCDCoordinateRotation(const dictionary&, const objectRegistry&); + //- Construct from dictionary and a registry (typically a mesh) + STARCDCoordinateRotation + ( + const dictionary& dict, + const objectRegistry& unused + ); - //- Construct as copy - STARCDCoordinateRotation(const STARCDCoordinateRotation&); //- Return clone autoPtr<coordinateRotation> clone() const @@ -218,11 +223,6 @@ public: // symmetrical tensor virtual symmTensor transformVector(const vector& st) const; - - // Write - - //- Write - virtual void write(Ostream&) const; }; diff --git a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C index 313a51df49bb39df1efc765ffc11e5e6c38b60e1..b22c509c4df2fded47898c66135bc5350f11ce14 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,7 +32,12 @@ License namespace Foam { defineTypeNameAndDebug(axesRotation, 0); - addToRunTimeSelectionTable(coordinateRotation, axesRotation, dictionary); + addToRunTimeSelectionTable + ( + coordinateRotation, + axesRotation, + dictionary + ); addToRunTimeSelectionTable ( coordinateRotation, @@ -41,131 +46,161 @@ namespace Foam ); } -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::axesRotation::calcTransform -( - const vector& axis1, - const vector& axis2, - const axisOrder& order -) -{ - vector a = axis1/mag(axis1); - vector b = axis2; - - b = b - (b & a)*a; - - if (mag(b) < SMALL) - { - FatalErrorInFunction - << "axis1, axis2 appear co-linear: " - << axis1 << ", " << axis2 << endl - << abort(FatalError); - } - - b = b/mag(b); - vector c = a^b; - - tensor Rtr; - switch (order) - { - case e1e2: - { - Rtr = tensor(a, b, c); - break; - } - case e2e3: - { - Rtr = tensor(c, a, b); - break; - } - case e3e1: - { - Rtr = tensor(b, c, a); - break; - } - default: - { - FatalErrorInFunction - << "Unhandled axes specifictation" << endl - << abort(FatalError); - Rtr = Zero; - break; - } - } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - // Global->local transformation - Rtr_ = Rtr; +Foam::axesRotation::axesRotation() +: + R_(sphericalTensor::I), + Rtr_(sphericalTensor::I) +{} - // Local->global transformation - R_ = Rtr.T(); -} +Foam::axesRotation::axesRotation(const axesRotation& r) +: + R_(r.R_), + Rtr_(r.Rtr_) +{} -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::axesRotation::axesRotation() +Foam::axesRotation::axesRotation(const tensor& R) : - R_(sphericalTensor::I), - Rtr_(R_) + R_(R), + Rtr_(R_.T()) {} Foam::axesRotation::axesRotation ( const vector& axis, - const vector& dir + const vector& dir, + const axisOrder& order ) : R_(sphericalTensor::I), - Rtr_(R_) + Rtr_(sphericalTensor::I) { - calcTransform(axis, dir, e3e1); + setTransform(axis, dir, order); } Foam::axesRotation::axesRotation ( - const dictionary& dict + const vector& axis ) : R_(sphericalTensor::I), - Rtr_(R_) + Rtr_(sphericalTensor::I) { - operator=(dict); + direction maxCmpt = 0, dirCmpt = 1; + + scalar maxVal = mag(axis[maxCmpt]); + bool negative = (axis[maxCmpt] < 0); + + for (direction cmpt = 1; cmpt < vector::nComponents; ++cmpt) + { + const scalar val = mag(axis[cmpt]); + + if (maxVal < val) + { + maxVal = val; + maxCmpt = cmpt; + dirCmpt = maxCmpt+1; + negative = (axis[cmpt] < 0); + + if (dirCmpt >= vector::nComponents) + { + dirCmpt = 0; + } + } + } + + vector dir = Zero; + dir.component(dirCmpt) = (negative ? -1 : 1); + + setTransform(axis, dir, E3_E1); } Foam::axesRotation::axesRotation ( - const dictionary& dict, - const objectRegistry& obr + const dictionary& dict ) : R_(sphericalTensor::I), - Rtr_(R_) + Rtr_(sphericalTensor::I) { operator=(dict); } -Foam::axesRotation::axesRotation(const tensor& R) +Foam::axesRotation::axesRotation +( + const dictionary& dict, + const objectRegistry& +) : - R_(R), - Rtr_(R_.T()) + axesRotation(dict) {} -Foam::axesRotation::axesRotation(const axesRotation& r) -: - R_(r.R_), - Rtr_(r.Rtr_) -{} +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // +void Foam::axesRotation::setTransform +( + const vector& axis1, + const vector& axis2, + const axisOrder& order +) +{ + const vector a = axis1/mag(axis1); + vector b = axis2; + b = b - (b & a)*a; + + if (mag(b) < SMALL) + { + FatalErrorInFunction + << "axis1, axis2 appear to be co-linear: " + << axis1 << ", " << axis2 << endl + << abort(FatalError); + } + + b = b/mag(b); + const vector c = a^b; + + // Global->local transformation + switch (order) + { + case E1_E2: + { + Rtr_ = tensor(a, b, c); + break; + } + case E2_E3: + { + Rtr_ = tensor(c, a, b); + break; + } + case E3_E1: + { + Rtr_ = tensor(b, c, a); + break; + } + default: + { + FatalErrorInFunction + << "Unhandled axes specification" << endl + << abort(FatalError); + + break; + } + } + + // Local->global transformation + R_ = Rtr_.T(); +} -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // const Foam::tensorField& Foam::axesRotation::Tr() const { @@ -263,34 +298,28 @@ Foam::symmTensor Foam::axesRotation::transformVector void Foam::axesRotation::operator=(const dictionary& dict) { - if (debug) - { - Pout<< "axesRotation::operator=(const dictionary&) : " - << "assign from " << dict << endl; - } - vector axis1, axis2; - axisOrder order(e3e1); if (dict.readIfPresent("e1", axis1) && dict.readIfPresent("e2", axis2)) { - order = e1e2; + setTransform(axis1, axis2, E1_E2); } - else if (dict.readIfPresent("e2", axis1)&& dict.readIfPresent("e3", axis2)) + else if (dict.readIfPresent("e2", axis1) && dict.readIfPresent("e3", axis2)) { - order = e2e3; + setTransform(axis1, axis2, E2_E3); } - else if (dict.readIfPresent("e3", axis1)&& dict.readIfPresent("e1", axis2)) + else if (dict.readIfPresent("e3", axis1) && dict.readIfPresent("e1", axis2)) { - order = e3e1; + setTransform(axis1, axis2, E3_E1); } else if (dict.found("axis") || dict.found("direction")) { // Both "axis" and "direction" are required // If one is missing the appropriate error message will be generated - order = e3e1; dict.lookup("axis") >> axis1; dict.lookup("direction") >> axis2; + + setTransform(axis1, axis2, E3_E1); } else { @@ -299,16 +328,6 @@ void Foam::axesRotation::operator=(const dictionary& dict) << "found " << exit(FatalError); } - - calcTransform(axis1, axis2, order); -} - - -void Foam::axesRotation::write(Ostream& os) const -{ - os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl; - os.writeKeyword("e2") << e2() << token::END_STATEMENT << nl; - os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl; } diff --git a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H index 2f51342ba4157f25ab84773a4d99230ece625b4a..ca974fc0e9760aeeb3d93b251afe5bd16f96f67f 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,11 +25,12 @@ Class Foam::axesRotation Description - A coordinate rotation specified using global axis + A coordinate rotation specified using global axes The rotation is defined by a combination of vectors (e1/e2), (e2/e3) or (e3/e1). Any nonorthogonality will be absorbed into the second - vector. + vector. In terms of cylindrical coordinates, the 'axis' would + correspond to the \a z-axis and the 'direction' to the \a r-axis. \verbatim axesRotation @@ -66,6 +67,20 @@ class axesRotation : public coordinateRotation { +public: + + //- The order/combination of local axes for the axes-rotation definition + // Note that these follow the right-hand rule. + enum axisOrder + { + E1_E2, //!< The axis is X-dominant, the direction is Y-dominant + E2_E3, //!< The axis is Y-dominant, the direction is Z-dominant + E3_E1 //!< The axis is Z-dominant, the direction is X-dominant + }; + + +private: + // Private data //- Local-to-Global transformation tensor @@ -74,24 +89,6 @@ class axesRotation //- Global-to-Local transformation tensor tensor Rtr_; - //- The combination of local axes to be used - enum axisOrder - { - e1e2, - e2e3, - e3e1 - }; - - // Private Member Functions - - //- Calculate transformation tensor - void calcTransform - ( - const vector& axis1, - const vector& axis2, - const axisOrder& order = e3e1 - ); - public: @@ -103,20 +100,34 @@ public: //- Construct null axesRotation(); - //- Construct from 2 axes - axesRotation(const vector& axis, const vector& dir); + //- Construct as copy + axesRotation(const axesRotation& r); + + //- Construct from local to global rotation matrix + explicit axesRotation(const tensor& R); - //- Construct from dictionary - axesRotation(const dictionary&); + //- Construct from two axes (axis and direction) + axesRotation + ( + const vector& axis, + const vector& dir, + const axisOrder& order = E3_E1 + ); - //- Construct from components - axesRotation(const tensor& R); + //- Construct from a single axis using a best-guess for the second axis + // For the best-guess, the largest component value and sign of the + // axis determines the direction orientation. + explicit axesRotation(const vector& axis); - //- Construct from dictionary and mesh - axesRotation(const dictionary&, const objectRegistry&); + //- Construct from dictionary + explicit axesRotation(const dictionary& dict); - //- Construct as copy - axesRotation(const axesRotation&); + //- Construct from dictionary and a registry (typically a mesh) + axesRotation + ( + const dictionary& dict, + const objectRegistry& unused + ); //- Return clone autoPtr<coordinateRotation> clone() const @@ -139,6 +150,14 @@ public: Rtr_ = sphericalTensor::I; } + //- Set the transformation tensors from two axes (axis and direction) + void setTransform + ( + const vector& axis1, + const vector& axis2, + const axisOrder& order = E3_E1 + ); + //- Update the rotation for a list of cells virtual void updateCells(const polyMesh&, const labelList&) {} @@ -216,13 +235,8 @@ public: // Member Operators //- Assign from dictionary - void operator=(const dictionary&); - - - // Write + void operator=(const dictionary& dict); - //- Write - virtual void write(Ostream&) const; }; diff --git a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C index c9ac59b6093cc238c2aa273124f11783220d9a54..57565dbc451c3dd8c8a456f3cab50c5598e64174 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -74,4 +74,13 @@ Foam::symmTensor Foam::coordinateRotation::transformPrincipal } + +void Foam::coordinateRotation::write(Ostream& os) const +{ + os.writeEntry("e1", e1()); + os.writeEntry("e2", e2()); + os.writeEntry("e3", e3()); +} + + // ************************************************************************* // diff --git a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H index bab113c3d0fcf5d1c6a9a92cc3cac721c9116eeb..3a8396b5095d0d2be14e505b4e48ace1100e1671 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H @@ -123,7 +123,8 @@ public: //- Select constructed from dictionary and objectRegistry static autoPtr<coordinateRotation> New ( - const dictionary& dict, const objectRegistry& obr + const dictionary& dict, + const objectRegistry& obr ); //- Select constructed from dictionary @@ -216,8 +217,8 @@ public: // Write - //- Write - virtual void write(Ostream&) const = 0; + //- Write coordinateRotation as e1,e2,e3 vectors + virtual void write(Ostream& os) const; }; diff --git a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotationNew.C b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotationNew.C index b1457329ff11971407236ec23a9a120336323789..feb473421cf83a52549f9fb373ae609621f332f6 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotationNew.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotationNew.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,26 +34,15 @@ Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New const objectRegistry& obr ) { - if (debug) - { - Pout<< "coordinateRotation::New" - "(const dictionary&, const objectRegistry&) : " - << "constructing coordinateRotation" - << endl; - } - const word rotType = dict.lookup("type"); - objectRegistryConstructorTable::iterator cstrIter = - objectRegistryConstructorTablePtr_->find(rotType); + auto cstrIter = objectRegistryConstructorTablePtr_->cfind(rotType); if (!cstrIter.found()) { FatalIOErrorInFunction(dict) - << "Unknown coordinateRotation type " - << rotType << nl << nl + << "Unknown coordinateRotation type " << rotType << nl << nl << "Valid coordinateRotation types are :" << nl - << "[default: axes ]" << objectRegistryConstructorTablePtr_->sortedToc() << exit(FatalIOError); } @@ -67,23 +56,14 @@ Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New const dictionary& dict ) { - if (debug) - { - Pout<< "coordinateRotation::New(const dictionary&) : " - << "constructing coordinateRotation" - << endl; - } - const word rotType = dict.lookup("type"); - dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(rotType); + auto cstrIter = dictionaryConstructorTablePtr_->cfind(rotType); if (!cstrIter.found()) { FatalIOErrorInFunction(dict) - << "Unknown coordinateRotation type " - << rotType << nl << nl + << "Unknown coordinateRotation type " << rotType << nl << nl << "Valid coordinateRotation types are :" << nl << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalIOError); diff --git a/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.C b/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.C index 8a04eedeede54d6df1cb41c5342f468df6df90ce..3ebc07d442f4c6cb88cbfa4c310135e21fa67653 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.C @@ -67,7 +67,7 @@ void Foam::cylindrical::init tensorField& R = Rptr_(); forAll(cells, i) { - label celli = cells[i]; + const label celli = cells[i]; vector dir = cc[celli] - origin_; dir /= mag(dir) + VSMALL; @@ -92,6 +92,40 @@ void Foam::cylindrical::init // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +Foam::cylindrical::cylindrical(const cylindrical& r) +: + Rptr_(r.Rptr_, false), // clone + origin_(r.origin_), + e3_(r.e3_) +{} + + +Foam::cylindrical::cylindrical(const tensorField& R) +: + Rptr_(), + origin_(Zero), + e3_(Zero) +{ + Rptr_() = R; +} + + +Foam::cylindrical::cylindrical(const dictionary& dict) +: + Rptr_(), + origin_(), + e3_() +{ + FatalErrorInFunction + << " cylindrical can not be constructed from dictionary " + << " use the construtctor : " + "(" + " const dictionary&, const objectRegistry&" + ")" + << exit(FatalIOError); +} + + Foam::cylindrical::cylindrical ( const dictionary& dict, @@ -103,12 +137,9 @@ Foam::cylindrical::cylindrical e3_(Zero) { // If origin is specified in the coordinateSystem - if (dict.parent().found("origin")) - { - dict.parent().lookup("origin") >> origin_; - } + dict.parent().readIfPresent("origin", origin_); - // rotation axis + // Rotation axis dict.lookup("e3") >> e3_; init(obr); @@ -146,40 +177,6 @@ Foam::cylindrical::cylindrical } -Foam::cylindrical::cylindrical(const dictionary& dict) -: - Rptr_(), - origin_(), - e3_() -{ - FatalErrorInFunction - << " cylindrical can not be constructed from dictionary " - << " use the construtctor : " - "(" - " const dictionary&, const objectRegistry&" - ")" - << exit(FatalIOError); -} - - -Foam::cylindrical::cylindrical(const tensorField& R) -: - Rptr_(), - origin_(Zero), - e3_(Zero) -{ - Rptr_() = R; -} - - -Foam::cylindrical::cylindrical(const cylindrical& r) -: - Rptr_(r.Rptr_, false), // clone - origin_(r.origin_), - e3_(r.e3_) -{} - - // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // @@ -360,7 +357,7 @@ Foam::symmTensor Foam::cylindrical::transformVector void Foam::cylindrical::write(Ostream& os) const { - os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl; + os.writeEntry("e3", e3()); } diff --git a/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.H b/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.H index ff7f838420cda60a98a4c6b0c97052bbdfa56bd0..2baca6682cb40efa323b9ea43affbede922cd8a3 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.H @@ -60,7 +60,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class cylindrical Declaration + Class cylindrical Declaration \*---------------------------------------------------------------------------*/ class cylindrical @@ -96,13 +96,22 @@ public: // Constructors + //- Construct as copy + cylindrical(const cylindrical& r); + + //- Construct from tensor Field + explicit cylindrical(const tensorField& R); + + //- Construct from dictionary - for API compatibility only + explicit cylindrical(const dictionary& dict); + //- Construct from dictionary and objectRegistry - cylindrical(const dictionary&, const objectRegistry&); + cylindrical(const dictionary& dict, const objectRegistry& obr); //- Construct from components for all cells cylindrical ( - const objectRegistry&, + const objectRegistry& obr, const vector& axis, const point& origin ); @@ -110,21 +119,12 @@ public: //- Construct from components for list of cells cylindrical ( - const objectRegistry&, + const objectRegistry& obr, const vector& axis, const point& origin, const List<label>& cells ); - //- Construct from dictionary - cylindrical(const dictionary&); - - //- Construct from tensor Field - cylindrical(const tensorField&); - - //- Construct as copy - cylindrical(const cylindrical&); - //- Return clone autoPtr<coordinateRotation> clone() const { diff --git a/src/meshTools/coordinateSystems/coordinateSystemNew.C b/src/meshTools/coordinateSystems/coordinateSystemNew.C index 34b169cf0e7baf13a846da904e17697383789b66..bb4b860e86b3a1f18a5096ad1a26469a57741b11 100644 --- a/src/meshTools/coordinateSystems/coordinateSystemNew.C +++ b/src/meshTools/coordinateSystems/coordinateSystemNew.C @@ -35,10 +35,9 @@ Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New ) { const dictionary& coordDict = dict.subDict(typeName_()); - word coordType = coordDict.lookup("type"); + const word coordType = coordDict.lookup("type"); - dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(coordType); + auto cstrIter = dictionaryConstructorTablePtr_->cfind(coordType); if (!cstrIter.found()) {