diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C index f09f38d4ee..c9452c67fc 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C @@ -230,15 +230,16 @@ Foam::MRFZone::MRFZone ( const word& name, const fvMesh& mesh, - const dictionary& dict + const dictionary& dict, + const word& cellZoneName ) : mesh_(mesh), name_(name), coeffs_(dict), active_(readBool(coeffs_.lookup("active"))), - cellZoneName_(coeffs_.lookup("cellZone")), - cellZoneID_(mesh_.cellZones().findZoneID(cellZoneName_)), + cellZoneName_(cellZoneName), + cellZoneID_(), excludedPatchNames_ ( coeffs_.lookupOrDefault("nonRotatingPatches", wordList(0)) @@ -253,6 +254,13 @@ Foam::MRFZone::MRFZone } else { + if (cellZoneName == word::null) + { + coeffs_.lookup("cellZone") >> cellZoneName_; + } + + cellZoneID_ = mesh_.cellZones().findZoneID(cellZoneName_); + const polyBoundaryMesh& patches = mesh_.boundaryMesh(); axis_ = axis_/mag(axis_); @@ -268,7 +276,13 @@ Foam::MRFZone::MRFZone { FatalErrorIn ( - "MRFZone(const word&, const fvMesh&, const dictionary&)" + "MRFZone" + "(" + "const word&, " + "const fvMesh&, " + "const dictionary&, " + "const word&" + ")" ) << "cannot find MRF patch " << excludedPatchNames_[i] << exit(FatalError); @@ -283,7 +297,13 @@ Foam::MRFZone::MRFZone { FatalErrorIn ( - "MRFZone(const word&, const fvMesh&, const dictionary&)" + "MRFZone" + "(" + "const word&, " + "const fvMesh&, " + "const dictionary&, " + "const word&" + ")" ) << "cannot find MRF cellZone " << cellZoneName_ << exit(FatalError); @@ -328,7 +348,7 @@ void Foam::MRFZone::addCoriolis } -void Foam::MRFZone::addCoriolis(fvVectorMatrix& UEqn) const +void Foam::MRFZone::addCoriolis(fvVectorMatrix& UEqn, const bool rhs) const { if (cellZoneID_ == -1) { @@ -342,10 +362,21 @@ void Foam::MRFZone::addCoriolis(fvVectorMatrix& UEqn) const const vector Omega = this->Omega(); - forAll(cells, i) + if (rhs) { - label celli = cells[i]; - Usource[celli] -= V[celli]*(Omega ^ U[celli]); + forAll(cells, i) + { + label celli = cells[i]; + Usource[celli] += V[celli]*(Omega ^ U[celli]); + } + } + else + { + forAll(cells, i) + { + label celli = cells[i]; + Usource[celli] -= V[celli]*(Omega ^ U[celli]); + } } } @@ -353,7 +384,8 @@ void Foam::MRFZone::addCoriolis(fvVectorMatrix& UEqn) const void Foam::MRFZone::addCoriolis ( const volScalarField& rho, - fvVectorMatrix& UEqn + fvVectorMatrix& UEqn, + const bool rhs ) const { if (cellZoneID_ == -1) @@ -368,10 +400,21 @@ void Foam::MRFZone::addCoriolis const vector Omega = this->Omega(); - forAll(cells, i) + if (rhs) { - label celli = cells[i]; - Usource[celli] -= V[celli]*rho[celli]*(Omega ^ U[celli]); + forAll(cells, i) + { + label celli = cells[i]; + Usource[celli] += V[celli]*rho[celli]*(Omega ^ U[celli]); + } + } + else + { + forAll(cells, i) + { + label celli = cells[i]; + Usource[celli] -= V[celli]*rho[celli]*(Omega ^ U[celli]); + } } } diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H index 5c6e05e2d3..5d379f2e40 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H @@ -144,7 +144,13 @@ public: // Constructors //- Construct from fvMesh - MRFZone(const word& name, const fvMesh& mesh, const dictionary& dict); + MRFZone + ( + const word& name, + const fvMesh& mesh, + const dictionary& dict, + const word& cellZoneName = word::null + ); //- Return clone autoPtr clone() const @@ -185,13 +191,20 @@ public: ) const; //- Add the Coriolis force contribution to the momentum equation - void addCoriolis(fvVectorMatrix& UEqn) const; + // Adds to the lhs of the equation; optionally add to rhs + void addCoriolis + ( + fvVectorMatrix& UEqn, + const bool rhs = false + ) const; //- Add the Coriolis force contribution to the momentum equation + // Adds to the lhs of the equation; optionally add to rhs void addCoriolis ( const volScalarField& rho, - fvVectorMatrix& UEqn + fvVectorMatrix& UEqn, + const bool rhs = false ) const; //- Make the given absolute velocity relative within the MRF region