diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C index fdcba3e50f..f4c929be99 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C @@ -55,11 +55,12 @@ template<> const char* Foam::NamedEnum < Foam::functionObjects::fieldValues::surfaceFieldValue::selectionTypes, - 3 + 4 >::names[] = { "faceZone", "patch", + "patches", "sampledSurface" }; @@ -89,7 +90,7 @@ const char* Foam::NamedEnum const Foam::NamedEnum < Foam::functionObjects::fieldValues::surfaceFieldValue::selectionTypes, - 3 + 4 > Foam::functionObjects::fieldValues::surfaceFieldValue::selectionTypeNames; const Foam::NamedEnum @@ -101,21 +102,26 @@ const Foam::NamedEnum // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces() +void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces +( + const word& zoneName +) { - label zoneId = mesh_.faceZones().findIndex(selectionName_); + const label zoneId = mesh_.faceZones().findIndex(zoneName); if (zoneId < 0) { FatalErrorInFunction << type() << " " << name() << ": " << selectionTypeNames[selectionType_] - << "(" << selectionName_ << "):" << nl - << " Unknown face zone name: " << selectionName_ + << "(" << zoneName << "):" << nl + << " Unknown face zone name: " << zoneName << ". Valid face zones are: " << mesh_.faceZones().toc() << nl << exit(FatalError); } + selectionName_ = zoneName; + // Ensure addressing is built on all processes mesh_.polyBFacePatches(); mesh_.polyBFacePatchFaces(); @@ -172,44 +178,45 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces() } -void Foam::functionObjects::fieldValues::surfaceFieldValue::setPatchFaces() +void Foam::functionObjects::fieldValues::surfaceFieldValue::setPatchesFaces +( + const labelList& patchis +) { - const label patchId = mesh_.boundaryMesh().findIndex(selectionName_); + selectionName_.clear(); - if (patchId < 0) - { - FatalErrorInFunction - << type() << " " << name() << ": " - << selectionTypeNames[selectionType_] - << "(" << selectionName_ << "):" << nl - << " Unknown patch name: " << selectionName_ - << ". Valid patch names are: " - << mesh_.boundaryMesh().names() << nl - << exit(FatalError); - } - - const fvPatch& fvp = mesh_.boundary()[patchId]; - - faceId_ = identityMap(fvp.size()); - facePatchId_ = labelList(fvp.size(), patchId); - faceSign_ = labelList(fvp.size(), 1); - - // If we have selected a cyclic, also include any associated processor - // cyclic faces - forAll(mesh_.boundary(), patchi) + faceId_.clear(); + facePatchId_.clear(); + faceSign_.clear(); + + forAll(patchis, i) { + const label patchi = patchis[i]; const fvPatch& fvp = mesh_.boundary()[patchi]; - if - ( - isA(fvp) - && refCast(fvp).referPatchIndex() - == patchId - ) + selectionName_.append((i ? " " : "") + fvp.name()); + + faceId_.append(identityMap(fvp.size())); + facePatchId_.append(labelList(fvp.size(), patchi)); + faceSign_.append(labelList(fvp.size(), 1)); + + // If we have selected a cyclic, also include any associated processor + // cyclic faces + forAll(mesh_.boundary(), pcPatchj) { - faceId_.append(identityMap(fvp.size())); - facePatchId_.append(labelList(fvp.size(), patchi)); - faceSign_.append(labelList(fvp.size(), 1)); + const fvPatch& pcFvp = mesh_.boundary()[pcPatchj]; + + if + ( + isA(pcFvp) + && refCast(pcFvp).referPatchIndex() + == patchi + ) + { + faceId_.append(identityMap(pcFvp.size())); + facePatchId_.append(labelList(pcFvp.size(), pcPatchj)); + faceSign_.append(labelList(pcFvp.size(), 1)); + } } } @@ -217,18 +224,61 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setPatchFaces() } -void Foam::functionObjects::fieldValues::surfaceFieldValue::sampledSurfaceFaces +void Foam::functionObjects::fieldValues::surfaceFieldValue::setPatchesFaces +( + const wordReList& patchNames +) +{ + labelList patchis; + + forAll(patchNames, i) + { + const labelList patchiis = + mesh_.boundaryMesh().findIndices(patchNames[i]); + + if (patchiis.empty()) + { + FatalErrorInFunction + << type() << " " << this->name() << ": " + << selectionTypeNames[selectionType_] + << "(" << patchNames[i] << "):" << nl + << " Unknown patch name: " << patchNames[i] + << ". Valid patch names are: " + << mesh_.boundaryMesh().names() << nl + << exit(FatalError); + } + + patchis.append(patchiis); + } + + setPatchesFaces(patchis); +} + + +void Foam::functionObjects::fieldValues::surfaceFieldValue::setPatchFaces +( + const wordRe& patchName +) +{ + setPatchesFaces(wordReList(1, patchName)); + + selectionName_ = + patchName.isPattern() ? '"' + patchName + '"' : string(patchName); +} + + +void +Foam::functionObjects::fieldValues::surfaceFieldValue::setSampledSurfaceFaces ( const dictionary& dict ) { - surfacePtr_ = sampledSurface::New - ( - name(), - mesh_, - dict.subDict("sampledSurfaceDict") - ); + surfacePtr_ = sampledSurface::New(name(), mesh_, dict); + surfacePtr_().update(); + + selectionName_ = surfacePtr_().name(); + nFaces_ = returnReduce(surfacePtr_().faces().size(), sumOp