diff --git a/applications/utilities/postProcessing/sampling/sample/sampleDict b/applications/utilities/postProcessing/sampling/sample/sampleDict index c34ce71daf..b983a35a11 100644 --- a/applications/utilities/postProcessing/sampling/sample/sampleDict +++ b/applications/utilities/postProcessing/sampling/sample/sampleDict @@ -150,29 +150,29 @@ surfaces interpolate true; } - movingWall_constant + walls_constant { type patch; - patchName movingWall; + patches ( ".*Wall.*" ); // Optional: whether to leave as faces (=default) or triangulate // triangulate false; } - movingWall_interpolated + walls_interpolated { type patch; - patchName movingWall; + patches ( ".*Wall.*" ); interpolate true; // Optional: whether to leave as faces (=default) or triangulate // triangulate false; } - movingNearWall_interpolated + nearWalls_interpolated { // Sample cell values off patch. Does not need to be the near-wall // cell, can be arbitrarily far away. type patchInternalField; - patchName movingWall; + patches ( ".*Wall.*" ); distance 0.0001; interpolate true; // Optional: whether to leave as faces (=default) or triangulate diff --git a/src/sampling/sampledSurface/sampledPatch/sampledPatch.C b/src/sampling/sampledSurface/sampledPatch/sampledPatch.C index 97ca76f68c..6f180dcd86 100644 --- a/src/sampling/sampledSurface/sampledPatch/sampledPatch.C +++ b/src/sampling/sampledSurface/sampledPatch/sampledPatch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,15 +46,14 @@ Foam::sampledPatch::sampledPatch ( const word& name, const polyMesh& mesh, - const word& patchName, + const wordReList& patchNames, const bool triangulate ) : sampledSurface(name, mesh), - patchName_(patchName), + patchNames_(patchNames), triangulate_(triangulate), - needsUpdate_(true), - patchFaceLabels_(0) + needsUpdate_(true) {} @@ -66,10 +65,9 @@ Foam::sampledPatch::sampledPatch ) : sampledSurface(name, mesh, dict), - patchName_(dict.lookup("patchName")), + patchNames_(dict.lookup("patches")), triangulate_(dict.lookupOrDefault("triangulate", false)), - needsUpdate_(true), - patchFaceLabels_(0) + needsUpdate_(true) {} @@ -81,6 +79,20 @@ Foam::sampledPatch::~sampledPatch() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +const Foam::labelList& Foam::sampledPatch::patchIDs() const +{ + if (patchIDs_.empty()) + { + patchIDs_ = mesh().boundaryMesh().patchSet + ( + patchNames_, + false + ).sortedToc(); + } + return patchIDs_; +} + + bool Foam::sampledPatch::needsUpdate() const { return needsUpdate_; @@ -97,7 +109,10 @@ bool Foam::sampledPatch::expire() sampledSurface::clearGeom(); MeshStorage::clear(); + patchIDs_.clear(); + patchIndex_.clear(); patchFaceLabels_.clear(); + patchStart_.clear(); needsUpdate_ = true; return true; @@ -111,31 +126,67 @@ bool Foam::sampledPatch::update() return false; } - const label patchI = mesh().boundaryMesh().findPatchID(patchName_); - - if (patchI != -1) + label sz = 0; + forAll(patchIDs(), i) { - const polyPatch& p = mesh().boundaryMesh()[patchI]; - this->storedPoints() = p.localPoints(); - this->storedFaces() = p.localFaces(); + label patchI = patchIDs()[i]; + const polyPatch& pp = mesh().boundaryMesh()[patchI]; - // an identity map - patchFaceLabels_.setSize(faces().size()); - forAll(patchFaceLabels_, i) + if (isA(pp)) { - patchFaceLabels_[i] = i; + FatalErrorIn("sampledPatch::update()") + << "Cannot sample an empty patch. Patch " << pp.name() + << exit(FatalError); } - // triangulate uses remapFaces() - // - this is somewhat less efficient since it recopies the faces - // that we just created, but we probably don't want to do this - // too often anyhow. - if (triangulate_) + sz += pp.size(); + } + + // For every face (or triangle) the originating patch and local face in the + // patch. + patchIndex_.setSize(sz); + patchFaceLabels_.setSize(sz); + patchStart_.setSize(patchIDs().size()); + labelList meshFaceLabels(sz); + + sz = 0; + + forAll(patchIDs(), i) + { + label patchI = patchIDs()[i]; + + patchStart_[i] = sz; + + const polyPatch& pp = mesh().boundaryMesh()[patchI]; + + forAll(pp, j) { - MeshStorage::triangulate(); + patchIndex_[sz] = i; + patchFaceLabels_[sz] = j; + meshFaceLabels[sz] = pp.start()+j; + sz++; } } + indirectPrimitivePatch allPatches + ( + IndirectList(mesh().faces(), meshFaceLabels), + mesh().points() + ); + + this->storedPoints() = allPatches.localPoints(); + this->storedFaces() = allPatches.localFaces(); + + + // triangulate uses remapFaces() + // - this is somewhat less efficient since it recopies the faces + // that we just created, but we probably don't want to do this + // too often anyhow. + if (triangulate_) + { + MeshStorage::triangulate(); + } + if (debug) { print(Pout); @@ -148,10 +199,7 @@ bool Foam::sampledPatch::update() // remap action on triangulation -void Foam::sampledPatch::remapFaces -( - const labelUList& faceMap -) +void Foam::sampledPatch::remapFaces(const labelUList& faceMap) { // recalculate the cells cut if (&faceMap && faceMap.size()) @@ -161,11 +209,27 @@ void Foam::sampledPatch::remapFaces ( UIndirectList