From 3a066beebb24e090f23a31a20ed12a1a15e759ee Mon Sep 17 00:00:00 2001 From: sergio Date: Wed, 4 Apr 2012 15:15:24 +0100 Subject: [PATCH] ENH: Adding run time modifiable for MRFZone dictionary --- .../cfdTools/general/MRF/MRFZone.C | 32 +++++++++++++++++-- .../cfdTools/general/MRF/MRFZone.H | 13 ++++---- .../cfdTools/general/MRF/MRFZones.C | 29 ++++++++++++++++- .../cfdTools/general/MRF/MRFZones.H | 12 +++++++ 4 files changed, 76 insertions(+), 10 deletions(-) diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C index d2f8caeb23..ab1837b1f6 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C @@ -32,6 +32,7 @@ License #include "faceSet.H" #include "geometricOneField.H" + // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineTypeNameAndDebug(Foam::MRFZone, 0); @@ -273,8 +274,8 @@ Foam::MRFZone::MRFZone(const fvMesh& mesh, Istream& is) } } - bool cellZoneFound = (cellZoneID_ != -1); + reduce(cellZoneFound, orOp()); if (!cellZoneFound) @@ -307,6 +308,7 @@ void Foam::MRFZone::addCoriolis const scalarField& V = mesh_.V(); vectorField& ddtUc = ddtU.internalField(); const vectorField& Uc = U.internalField(); + const vector& Omega = Omega_.value(); forAll(cells, i) @@ -328,6 +330,7 @@ void Foam::MRFZone::addCoriolis(fvVectorMatrix& UEqn) const const scalarField& V = mesh_.V(); vectorField& Usource = UEqn.source(); const vectorField& U = UEqn.psi(); + const vector& Omega = Omega_.value(); forAll(cells, i) @@ -353,6 +356,7 @@ void Foam::MRFZone::addCoriolis const scalarField& V = mesh_.V(); vectorField& Usource = UEqn.source(); const vectorField& U = UEqn.psi(); + const vector& Omega = Omega_.value(); forAll(cells, i) @@ -368,6 +372,7 @@ void Foam::MRFZone::relativeVelocity(volVectorField& U) const const volVectorField& C = mesh_.C(); const vector& origin = origin_.value(); + const vector& Omega = Omega_.value(); const labelList& cells = mesh_.cellZones()[cellZoneID_]; @@ -395,7 +400,8 @@ void Foam::MRFZone::relativeVelocity(volVectorField& U) const { label patchFacei = excludedFaces_[patchi][i]; U.boundaryField()[patchi][patchFacei] -= - (Omega ^ (C.boundaryField()[patchi][patchFacei] - origin)); + (Omega + ^ (C.boundaryField()[patchi][patchFacei] - origin)); } } } @@ -406,6 +412,7 @@ void Foam::MRFZone::absoluteVelocity(volVectorField& U) const const volVectorField& C = mesh_.C(); const vector& origin = origin_.value(); + const vector& Omega = Omega_.value(); const labelList& cells = mesh_.cellZones()[cellZoneID_]; @@ -475,6 +482,7 @@ void Foam::MRFZone::absoluteFlux void Foam::MRFZone::correctBoundaryVelocity(volVectorField& U) const { const vector& origin = origin_.value(); + const vector& Omega = Omega_.value(); // Included patches @@ -496,4 +504,24 @@ void Foam::MRFZone::correctBoundaryVelocity(volVectorField& U) const } +Foam::Ostream& Foam::operator<<(Ostream& os, const MRFZone& MRF) +{ + os << indent << nl; + os.write(MRF.name_) << nl; + os << token::BEGIN_BLOCK << incrIndent << nl; + os.writeKeyword("origin") << MRF.origin_ << token::END_STATEMENT << nl; + os.writeKeyword("axis") << MRF.axis_ << token::END_STATEMENT << nl; + os.writeKeyword("omega") << MRF.omega_ << token::END_STATEMENT << nl; + + if (MRF.excludedPatchNames_.size()) + { + os.writeKeyword("nonRotatingPatches") << MRF.excludedPatchNames_ + << token::END_STATEMENT << nl; + } + + os << decrIndent << token::END_BLOCK << nl; + + return os; +} + // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H index 0a4f21bf65..5c5cd245c0 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H @@ -48,6 +48,7 @@ SourceFiles #include "surfaceFieldsFwd.H" #include "fvMatricesFwd.H" #include "fvMatrices.H" +#include "DataEntry.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -87,7 +88,7 @@ class MRFZone const dimensionedVector origin_; dimensionedVector axis_; - const dimensionedScalar omega_; + dimensionedScalar omega_; dimensionedVector Omega_; @@ -205,13 +206,11 @@ public: void correctBoundaryVelocity(volVectorField& U) const; - // Ostream Operator + // IOstream operator + + friend Ostream& operator<<(Ostream& os, const MRFZone& MRF); + - friend Ostream& operator<<(Ostream& os, const MRFZone&) - { - notImplemented("Ostream& operator<<(Ostream& os, const MRFZone&)"); - return os; - } }; diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZones.C b/src/finiteVolume/cfdTools/general/MRF/MRFZones.C index d1c961afec..fa35898f0e 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZones.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZones.C @@ -49,8 +49,28 @@ Foam::MRFZones::MRFZones(const fvMesh& mesh) IOobject::NO_WRITE ), MRFZone::iNew(mesh) + ), + mesh_(mesh) +{ + if + ( + Pstream::parRun() + && + ( + regIOobject::fileModificationChecking == timeStampMaster + || regIOobject::fileModificationChecking == inotifyMaster + ) ) -{} + { + WarningIn("MRFZones(const fvMesh&)") + << "The MRFZones are not run time modifiable\n" + << " using 'timeStampMaster' or 'inotifyMaster'\n" + << " for the entry fileModificationChecking\n" + << " in the etc/controlDict.\n" + << " Use 'timeStamp' instead." + << endl; + } +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -161,4 +181,11 @@ void Foam::MRFZones::correctBoundaryVelocity(volVectorField& U) const } +bool Foam::MRFZones::readData(Istream& is) +{ + PtrList::read(is, MRFZone::iNew(mesh_)); + return is.good(); +} + + // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZones.H b/src/finiteVolume/cfdTools/general/MRF/MRFZones.H index 8df9d428be..f5b43bce29 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZones.H +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZones.H @@ -52,6 +52,11 @@ class MRFZones : public IOPtrList { + // Private data + + //- Reference to mesh + const fvMesh& mesh_; + // Private Member Functions @@ -109,6 +114,13 @@ public: //- Correct the boundary velocity for the roation of the MRF region void correctBoundaryVelocity(volVectorField& U) const; + + + // I-O + + //- Read from Istream + virtual bool readData(Istream&); + };