From 5d3596b25e66c04ee0399dc42244dc5ea2fc816e Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Wed, 5 Oct 2011 16:58:28 +0100 Subject: [PATCH] Update for cylindrical CS and default inDegrees check --- .../mixerGgiFvMesh/mixerGgiFvMesh.C | 31 ++++++++++----- .../mixerGgiFvMesh/mixerGgiFvMesh.H | 6 +-- .../dynamicFvMesh/turboFvMesh/turboFvMesh.C | 30 +++++++++++---- .../dynamicFvMesh/turboFvMesh/turboFvMesh.H | 6 +-- .../mixerFvMesh/mixerFvMesh.C | 31 ++++++++++----- .../mixerFvMesh/mixerFvMesh.H | 6 +-- .../multiMixerFvMesh/mixerRotor.C | 38 ++++++++++++++----- .../multiMixerFvMesh/mixerRotor.H | 6 +-- 8 files changed, 107 insertions(+), 47 deletions(-) diff --git a/src/dynamicMesh/dynamicFvMesh/mixerGgiFvMesh/mixerGgiFvMesh.C b/src/dynamicMesh/dynamicFvMesh/mixerGgiFvMesh/mixerGgiFvMesh.C index 9c1a37e50..5061f9f80 100644 --- a/src/dynamicMesh/dynamicFvMesh/mixerGgiFvMesh/mixerGgiFvMesh.C +++ b/src/dynamicMesh/dynamicFvMesh/mixerGgiFvMesh/mixerGgiFvMesh.C @@ -255,17 +255,30 @@ Foam::mixerGgiFvMesh::mixerGgiFvMesh ) ).subDict(typeName + "Coeffs") ), - csPtr_ + cs_ ( - coordinateSystem::New - ( - "coordinateSystem", - dict_.subDict("coordinateSystem") - ) + "coordinateSystem", + dict_.subDict("coordinateSystem") ), rpm_(readScalar(dict_.lookup("rpm"))), movingPointsMaskPtr_(NULL) { + // Make sure the coordinate system does not operate in degrees + // Bug fix, HJ, 3/Oct/2011 + if (!cs_.inDegrees()) + { + WarningIn("mixerGgiFvMesh::mixerGgiFvMesh(const IOobject& io)") + << "Mixer coordinate system is set to operate in radians. " + << "Changing to rad for correct calculation of angular velocity." + << nl + << "To remove this message please add entry" << nl << nl + << "inDegrees true;" << nl << nl + << "to the specification of the coordinate system" + << endl; + + cs_.inDegrees() = true; + } + addZonesAndModifiers(); Info<< "Mixer mesh:" << nl @@ -299,12 +312,12 @@ const Foam::scalarField& Foam::mixerGgiFvMesh::movingPointsMask() const bool Foam::mixerGgiFvMesh::update() { - // Rotational speed needs to be converted from rpm + // Rotational speed needs to be converted from rpm movePoints ( - csPtr_->globalPosition + cs_.globalPosition ( - csPtr_->localPosition(allPoints()) + cs_.localPosition(allPoints()) + vector(0, rpm_*360.0*time().deltaT().value()/60.0, 0) *movingPointsMask() ) diff --git a/src/dynamicMesh/dynamicFvMesh/mixerGgiFvMesh/mixerGgiFvMesh.H b/src/dynamicMesh/dynamicFvMesh/mixerGgiFvMesh/mixerGgiFvMesh.H index e3c6019c9..938375829 100644 --- a/src/dynamicMesh/dynamicFvMesh/mixerGgiFvMesh/mixerGgiFvMesh.H +++ b/src/dynamicMesh/dynamicFvMesh/mixerGgiFvMesh/mixerGgiFvMesh.H @@ -61,7 +61,7 @@ class mixerGgiFvMesh dictionary dict_; //- Coordinate system - autoPtr csPtr_; + cylindricalCS cs_; // - Rotational speed in rotations per minute (rpm) scalar rpm_; @@ -109,9 +109,9 @@ public: // Member Functions //- Return coordinate system - const coordinateSystem& cs() const + const cylindricalCS& cs() const { - return csPtr_(); + return cs_; } //- Update the mesh for both mesh motion diff --git a/src/dynamicMesh/dynamicFvMesh/turboFvMesh/turboFvMesh.C b/src/dynamicMesh/dynamicFvMesh/turboFvMesh/turboFvMesh.C index 03c629823..39e5563f8 100644 --- a/src/dynamicMesh/dynamicFvMesh/turboFvMesh/turboFvMesh.C +++ b/src/dynamicMesh/dynamicFvMesh/turboFvMesh/turboFvMesh.C @@ -173,16 +173,30 @@ Foam::turboFvMesh::turboFvMesh ) ).subDict(typeName + "Coeffs") ), - csPtr_ + cs_ ( - coordinateSystem::New - ( - "coordinateSystem", - dict_.subDict("coordinateSystem") - ) + "coordinateSystem", + dict_.subDict("coordinateSystem") ), movingPointsPtr_(NULL) { + // Make sure the coordinate system does not operate in degrees + // Bug fix, HJ, 3/Oct/2011 + if (!cs_.inDegrees()) + { + WarningIn("turboFvMesh::turboFvMesh(const IOobject& io)") + << "Mixer coordinate system is set to operate in radians. " + << "Changing to rad for correct calculation of angular velocity." + << nl + << "To remove this message please add entry" << nl << nl + << "inDegrees true;" << nl << nl + << "to the specification of the coordinate system" + << endl; + + cs_.inDegrees() = true; + } + + Info<< "Turbomachine Mixer mesh:" << nl << " origin: " << cs().origin() << nl << " axis : " << cs().axis() << endl; @@ -215,9 +229,9 @@ bool Foam::turboFvMesh::update() { movePoints ( - csPtr_->globalPosition + cs_.globalPosition ( - csPtr_->localPosition(allPoints()) + cs_.localPosition(allPoints()) + movingPoints()*time().deltaT().value() ) ); diff --git a/src/dynamicMesh/dynamicFvMesh/turboFvMesh/turboFvMesh.H b/src/dynamicMesh/dynamicFvMesh/turboFvMesh/turboFvMesh.H index b39d708fb..2d0026950 100644 --- a/src/dynamicMesh/dynamicFvMesh/turboFvMesh/turboFvMesh.H +++ b/src/dynamicMesh/dynamicFvMesh/turboFvMesh/turboFvMesh.H @@ -83,7 +83,7 @@ class turboFvMesh dictionary dict_; //- Coordinate system - autoPtr csPtr_; + cylindricalCS cs_; //- Markup field for points. mutable vectorField* movingPointsPtr_; @@ -124,9 +124,9 @@ public: // Member Functions //- Return coordinate system - const coordinateSystem& cs() const + const cylindricalCS& cs() const { - return csPtr_(); + return cs_; } //- Update the mesh for both mesh motion diff --git a/src/dynamicMesh/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C b/src/dynamicMesh/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C index 6c7b60b3a..e9dc88eef 100644 --- a/src/dynamicMesh/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C +++ b/src/dynamicMesh/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.C @@ -380,22 +380,35 @@ Foam::mixerFvMesh::mixerFvMesh ) ).subDict(typeName + "Coeffs") ), - csPtr_ + cs_ ( - coordinateSystem::New - ( - "coordinateSystem", - dict_.subDict("coordinateSystem") - ) + "coordinateSystem", + dict_.subDict("coordinateSystem") ), rpm_(readScalar(dict_.lookup("rpm"))), rotatingRegionMarker_ ( - dict_.lookupOrDefault("rotatingRegionMarker", csPtr_->origin()) + dict_.lookupOrDefault("rotatingRegionMarker", cs_.origin()) ), attachDetach_(dict_.lookupOrDefault("attachDetach", false)), movingPointsMaskPtr_(NULL) { + // Make sure the coordinate system does not operate in degrees + // Bug fix, HJ, 3/Oct/2011 + if (!cs_.inDegrees()) + { + WarningIn("mixerFvMesh::mixerFvMesh(const IOobject& io)") + << "Mixer coordinate system is set to operate in radians. " + << "Changing to rad for correct calculation of angular velocity." + << nl + << "To remove this message please add entry" << nl << nl + << "inDegrees true;" << nl << nl + << "to the specification of the coordinate system" + << endl; + + cs_.inDegrees() = true; + } + Info<< "Rotating region marker point: " << rotatingRegionMarker_ << " Attach-detach action = " << attachDetach_ << endl; @@ -438,9 +451,9 @@ bool Foam::mixerFvMesh::update() // Move points. Rotational speed needs to be converted from rpm movePoints ( - csPtr_->globalPosition + cs_.globalPosition ( - csPtr_->localPosition(allPoints()) + cs_.localPosition(allPoints()) + vector(0, rpm_*360.0*time().deltaT().value()/60.0, 0) *movingPointsMask() ) diff --git a/src/dynamicMesh/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.H b/src/dynamicMesh/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.H index bee262b54..951206243 100644 --- a/src/dynamicMesh/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.H +++ b/src/dynamicMesh/topoChangerFvMesh/mixerFvMesh/mixerFvMesh.H @@ -58,7 +58,7 @@ class mixerFvMesh dictionary dict_; //- Coordinate system - autoPtr csPtr_; + cylindricalCS cs_; // - Rotational speed in rotations per minute (rpm) scalar rpm_; @@ -115,9 +115,9 @@ public: // Member Functions //- Return coordinate system - const coordinateSystem& cs() const + const cylindricalCS& cs() const { - return csPtr_(); + return cs_; } //- Update the mesh for both mesh motion and topology change diff --git a/src/dynamicMesh/topoChangerFvMesh/multiMixerFvMesh/mixerRotor.C b/src/dynamicMesh/topoChangerFvMesh/multiMixerFvMesh/mixerRotor.C index a3197a2c4..fbdebc802 100644 --- a/src/dynamicMesh/topoChangerFvMesh/multiMixerFvMesh/mixerRotor.C +++ b/src/dynamicMesh/topoChangerFvMesh/multiMixerFvMesh/mixerRotor.C @@ -308,20 +308,17 @@ Foam::mixerRotor::mixerRotor : name_(name), mesh_(mesh), - csPtr_ + cs_ ( - coordinateSystem::New - ( - "coordinateSystem", - dict.subDict("coordinateSystem") - ) + "coordinateSystem", + dict.subDict("coordinateSystem") ), rpm_(readScalar(dict.lookup("rpm"))), movingSliderName_(dict.lookup("movingPatch")), staticSliderName_(dict.lookup("staticPatch")), rotatingRegionMarker_ ( - dict.lookupOrDefault("rotatingRegionMarker", csPtr_->origin()) + dict.lookupOrDefault("rotatingRegionMarker", cs_.origin()) ), invertMotionMask_ ( @@ -331,6 +328,29 @@ Foam::mixerRotor::mixerRotor attachDetach_(dict.lookupOrDefault("attachDetach", true)), movingPointsMaskPtr_(NULL) { + // Make sure the coordinate system does not operate in degrees + // Bug fix, HJ, 3/Oct/2011 + if (!cs_.inDegrees()) + { + WarningIn + ( + "mixerRotor::mixerRotor\n" + "(\n" + " const word& name,\n" + " const polyMesh& mesh,\n" + " const dictionary& dict\n" + ")" + ) << "Mixer coordinate system is set to operate in radians. " + << "Changing to rad for correct calculation of angular velocity." + << nl + << "To remove this message please add entry" << nl << nl + << "inDegrees true;" << nl << nl + << "to the specification of the coordinate system" + << endl; + + cs_.inDegrees() = true; + } + Info<< "Rotor " << name << ":" << nl << " origin : " << cs().origin() << nl << " axis : " << cs().axis() << nl @@ -365,10 +385,10 @@ Foam::tmp Foam::mixerRotor::pointMotion() const mpm = 1 - mpm; } - return csPtr_->globalPosition + return cs_.globalPosition ( // Motion vector in cymindrical coordinate system (x theta z) - csPtr_->localPosition(mesh_.allPoints()) + cs_.localPosition(mesh_.allPoints()) + vector(0, rpm_*360.0*mesh_.time().deltaT().value()/60.0, 0)*mpm ) - mesh_.allPoints(); } diff --git a/src/dynamicMesh/topoChangerFvMesh/multiMixerFvMesh/mixerRotor.H b/src/dynamicMesh/topoChangerFvMesh/multiMixerFvMesh/mixerRotor.H index e4d928160..fcb1afd8d 100644 --- a/src/dynamicMesh/topoChangerFvMesh/multiMixerFvMesh/mixerRotor.H +++ b/src/dynamicMesh/topoChangerFvMesh/multiMixerFvMesh/mixerRotor.H @@ -67,7 +67,7 @@ class mixerRotor const polyMesh& mesh_; //- Coordinate system - autoPtr csPtr_; + cylindricalCS cs_; // - Rotational speed in rotations per minute (rpm) const scalar rpm_; @@ -105,9 +105,9 @@ class mixerRotor //- Return coordinate system - const coordinateSystem& cs() const + const cylindricalCS& cs() const { - return csPtr_(); + return cs_; } //- Calculate moving mask