From afdbf9a553e5818baa31354f12d4c798dbd77f09 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs@hunt.opencfd.co.uk> Date: Fri, 27 Feb 2009 12:33:11 +0000 Subject: [PATCH] faceZone derived --- .../cfdTools/general/MRF/MRFZone.C | 81 ++++++++++++++++++- .../cfdTools/general/MRF/MRFZone.H | 20 +++-- 2 files changed, 91 insertions(+), 10 deletions(-) diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C index 8bc4d3b9381..42cd06c6d56 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.C @@ -29,6 +29,10 @@ License #include "volFields.H" #include "surfaceFields.H" #include "fvMatrices.H" +#include "PackedList.H" +#include "syncTools.H" + +#include "faceSet.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -39,12 +43,15 @@ Foam::MRFZone::MRFZone(const fvMesh& mesh, Istream& is) dict_(is), cellZoneID_(mesh_.cellZones().findZoneID(name_)), faceZoneID_(mesh_.faceZones().findZoneID(name_)), + outsideFaces_(0), patchNames_(dict_.lookup("patches")), origin_(dict_.lookup("origin")), axis_(dict_.lookup("axis")), omega_(dict_.lookup("omega")), Omega_("Omega", omega_*axis_) { + const polyBoundaryMesh& patches = mesh_.boundaryMesh(); + axis_ = axis_/mag(axis_); Omega_ = omega_*axis_; @@ -65,18 +72,78 @@ Foam::MRFZone::MRFZone(const fvMesh& mesh, Istream& is) if (!faceZoneFound) { - FatalErrorIn + WarningIn ( "Foam::MRFZone::MRFZone(const fvMesh& , const dictionary&)" ) << "cannot find MRF faceZone " << name_ - << exit(FatalError); + << " ; taking faces on outside of cellZone." + << endl; + + // Determine faces in cell zone + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // (does not construct cells) + + const labelList& own = mesh_.faceOwner(); + const labelList& nei = mesh_.faceNeighbour(); + + // Cells in zone + PackedBoolList zoneCell(mesh_.nCells()); + + if (cellZoneID_ != -1) + { + const labelList& cellLabels = mesh_.cellZones()[cellZoneID_]; + forAll(cellLabels, i) + { + zoneCell[cellLabels[i]] = 1u; + } + } + + + // Faces in zone + PackedBoolList zoneFacesSet(mesh_.nFaces()); + + for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++) + { + if + ( + zoneCell.get(own[faceI]) == 1u + || zoneCell.get(nei[faceI]) == 1u + ) + { + zoneFacesSet[faceI] = 1u; + } + } + syncTools::syncFaceList(mesh_, zoneFacesSet, orEqOp<unsigned int>()); + + + // Transfer to labelList + label n = zoneFacesSet.count(); + outsideFaces_.setSize(n); + n = 0; + forAll(zoneFacesSet, faceI) + { + if (zoneFacesSet.get(faceI) == 1u) + { + outsideFaces_[n++] = faceI; + } + } + + Info<< nl + << "MRFZone " << name_ << " : found " + << returnReduce(outsideFaces_.size(), sumOp<label>()) + << " faces inside cellZone." << endl; + + + // Flag use of outsideFaces + faceZoneID_ = -2; } + patchLabels_.setSize(patchNames_.size()); forAll(patchNames_, i) { - patchLabels_[i] = mesh_.boundaryMesh().findPatchID(patchNames_[i]); + patchLabels_[i] = patches.findPatchID(patchNames_[i]); if (patchLabels_[i] == -1) { @@ -125,7 +192,13 @@ void Foam::MRFZone::relativeFlux(surfaceScalarField& phi) const const vector& origin = origin_.value(); const vector& Omega = Omega_.value(); - const labelList& faces = mesh_.faceZones()[faceZoneID_]; + // Use either zone faces or outsideFaces_ + const labelList& faces = + ( + faceZoneID_ == -2 + ? outsideFaces_ + : mesh_.faceZones()[faceZoneID_] + ); forAll(faces, i) { diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H index 3ffb4e461a8..7c489ed25bb 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H @@ -26,7 +26,7 @@ Class Foam::MRFZone Description - MRF zone definition based on both cell and face zones and parameters + MRF zone definition based on cell zone and optional face zone and parameters obtained from a control dictionary constructed from the given stream. The rotation of the MRF region is defined by an origin and axis of @@ -68,18 +68,26 @@ class MRFZone const fvMesh& mesh_; - word name_; + const word name_; - dictionary dict_; + const dictionary dict_; label cellZoneID_; + + //- label of face zone with faces on outside of cell zone. + // If -2 determines outside faces itself label faceZoneID_; - wordList patchNames_; + + //- outside faces (only if faceZoneID = -2) + labelList outsideFaces_; + + + const wordList patchNames_; labelList patchLabels_; - dimensionedVector origin_; + const dimensionedVector origin_; dimensionedVector axis_; - dimensionedScalar omega_; + const dimensionedScalar omega_; dimensionedVector Omega_; -- GitLab