ENH: add ZoneMesh::inZone method that returns a PackedBoolList

- useful for generating combined zones. Eg,

      cellZone combined
      (
          "combinedZone",
          czm.inZone(key).used(),
          ZoneI,
          *this
      );
This commit is contained in:
Mark Olesen
2010-08-06 17:03:15 +02:00
parent e12581bffc
commit aa6b918bca
11 changed files with 81 additions and 40 deletions

View File

@ -302,6 +302,24 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::findIndex
} }
template<class ZoneType, class MeshType>
Foam::PackedBoolList Foam::ZoneMesh<ZoneType, MeshType>::inZone
(
const keyType& key
) const
{
PackedBoolList lst;
const labelList indices = this->findIndices(key);
forAll(indices, i)
{
lst |= static_cast<const labelList&>(this->operator[](indices[i]));
}
return lst;
}
template<class ZoneType, class MeshType> template<class ZoneType, class MeshType>
Foam::label Foam::ZoneMesh<ZoneType, MeshType>::findZoneID Foam::label Foam::ZoneMesh<ZoneType, MeshType>::findZoneID
( (

View File

@ -25,7 +25,7 @@ Class
Foam::ZoneMesh Foam::ZoneMesh
Description Description
List of mesh zones A list of mesh zones.
SourceFiles SourceFiles
ZoneMesh.C ZoneMesh.C
@ -37,8 +37,9 @@ SourceFiles
#include "List.H" #include "List.H"
#include "regIOobject.H" #include "regIOobject.H"
#include "HashSet.H"
#include "pointFieldsFwd.H" #include "pointFieldsFwd.H"
#include "Map.H"
#include "PackedBoolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -140,6 +141,9 @@ public:
//- Return zone index for the first match, return -1 if not found //- Return zone index for the first match, return -1 if not found
label findIndex(const keyType&) const; label findIndex(const keyType&) const;
//- Mark all elements that are in the matching zones
PackedBoolList inZone(const keyType&) const;
//- Clear addressing //- Clear addressing
void clearAddressing(); void clearAddressing();

View File

@ -47,7 +47,7 @@ const char * const Foam::cellZone::labelsName = "cellLabels";
Foam::cellZone::cellZone Foam::cellZone::cellZone
( (
const word& name, const word& name,
const labelList& addr, const unallocLabelList& addr,
const label index, const label index,
const cellZoneMesh& zm const cellZoneMesh& zm
) )
@ -86,7 +86,7 @@ Foam::cellZone::cellZone
Foam::cellZone::cellZone Foam::cellZone::cellZone
( (
const cellZone& cz, const cellZone& cz,
const labelList& addr, const unallocLabelList& addr,
const label index, const label index,
const cellZoneMesh& zm const cellZoneMesh& zm
) )
@ -154,7 +154,14 @@ void Foam::cellZone::operator=(const cellZone& zn)
} }
void Foam::cellZone::operator=(const labelList& addr) void Foam::cellZone::operator=(const unallocLabelList& addr)
{
clearAddressing();
labelList::operator=(addr);
}
void Foam::cellZone::operator=(const Xfer<labelList>& addr)
{ {
clearAddressing(); clearAddressing();
labelList::operator=(addr); labelList::operator=(addr);

View File

@ -113,7 +113,7 @@ public:
cellZone cellZone
( (
const word& name, const word& name,
const labelList& addr, const unallocLabelList& addr,
const label index, const label index,
const cellZoneMesh& const cellZoneMesh&
); );
@ -141,7 +141,7 @@ public:
cellZone cellZone
( (
const cellZone&, const cellZone&,
const labelList& addr, const unallocLabelList& addr,
const label index, const label index,
const cellZoneMesh& const cellZoneMesh&
); );
@ -169,7 +169,7 @@ public:
// and zone mesh // and zone mesh
virtual autoPtr<cellZone> clone virtual autoPtr<cellZone> clone
( (
const labelList& addr, const unallocLabelList& addr,
const label index, const label index,
const cellZoneMesh& zm const cellZoneMesh& zm
) const ) const
@ -215,11 +215,14 @@ public:
// Member Operators // Member Operators
//- Assign to zone clearing demand-driven data //- Assign to zone, clearing demand-driven data
void operator=(const cellZone&); void operator=(const cellZone&);
//- Assign addressing clearing demand-driven data //- Assign addressing, clearing demand-driven data
void operator=(const labelList&); void operator=(const unallocLabelList&);
//- Assign addressing, clearing demand-driven data
void operator=(const Xfer<labelList>&);
// I-O // I-O

View File

@ -180,7 +180,7 @@ void Foam::faceZone::checkAddressing() const
Foam::faceZone::faceZone Foam::faceZone::faceZone
( (
const word& name, const word& name,
const labelList& addr, const unallocLabelList& addr,
const boolList& fm, const boolList& fm,
const label index, const label index,
const faceZoneMesh& zm const faceZoneMesh& zm
@ -242,7 +242,7 @@ Foam::faceZone::faceZone
Foam::faceZone::faceZone Foam::faceZone::faceZone
( (
const faceZone& fz, const faceZone& fz,
const labelList& addr, const unallocLabelList& addr,
const boolList& fm, const boolList& fm,
const label index, const label index,
const faceZoneMesh& zm const faceZoneMesh& zm
@ -392,7 +392,7 @@ void Foam::faceZone::clearAddressing()
void Foam::faceZone::resetAddressing void Foam::faceZone::resetAddressing
( (
const labelList& addr, const unallocLabelList& addr,
const boolList& flipMap const boolList& flipMap
) )
{ {
@ -414,7 +414,7 @@ void Foam::faceZone::updateMesh(const mapPolyMesh& mpm)
forAll(*this, i) forAll(*this, i)
{ {
label faceI = operator[](i); const label faceI = operator[](i);
if (faceMap[faceI] >= 0) if (faceMap[faceI] >= 0)
{ {
@ -454,7 +454,7 @@ bool Foam::faceZone::checkParallelSync(const bool report) const
boolList neiZoneFlip(mesh.nFaces()-mesh.nInternalFaces(), false); boolList neiZoneFlip(mesh.nFaces()-mesh.nInternalFaces(), false);
forAll(*this, i) forAll(*this, i)
{ {
label faceI = operator[](i); const label faceI = operator[](i);
if (!mesh.isInternalFace(faceI)) if (!mesh.isInternalFace(faceI))
{ {
@ -469,13 +469,12 @@ bool Foam::faceZone::checkParallelSync(const bool report) const
forAll(*this, i) forAll(*this, i)
{ {
label faceI = operator[](i); const label faceI = operator[](i);
const label patchI = bm.whichPatch(faceI);
label patchI = bm.whichPatch(faceI);
if (patchI != -1 && bm[patchI].coupled()) if (patchI != -1 && bm[patchI].coupled())
{ {
label bFaceI = faceI-mesh.nInternalFaces(); const label bFaceI = faceI-mesh.nInternalFaces();
// Check face in zone on both sides // Check face in zone on both sides
if (myZoneFace[bFaceI] != neiZoneFace[bFaceI]) if (myZoneFace[bFaceI] != neiZoneFace[bFaceI])

View File

@ -154,7 +154,7 @@ public:
faceZone faceZone
( (
const word& name, const word& name,
const labelList& addr, const unallocLabelList& addr,
const boolList& fm, const boolList& fm,
const label index, const label index,
const faceZoneMesh& zm const faceZoneMesh& zm
@ -184,7 +184,7 @@ public:
faceZone faceZone
( (
const faceZone&, const faceZone&,
const labelList& addr, const unallocLabelList& addr,
const boolList& fm, const boolList& fm,
const label index, const label index,
const faceZoneMesh& const faceZoneMesh&
@ -214,7 +214,7 @@ public:
// and zone mesh // and zone mesh
virtual autoPtr<faceZone> clone virtual autoPtr<faceZone> clone
( (
const labelList& addr, const unallocLabelList& addr,
const boolList& fm, const boolList& fm,
const label index, const label index,
const faceZoneMesh& zm const faceZoneMesh& zm
@ -279,7 +279,7 @@ public:
virtual void clearAddressing(); virtual void clearAddressing();
//- Reset addressing and flip map (clearing demand-driven data) //- Reset addressing and flip map (clearing demand-driven data)
virtual void resetAddressing(const labelList&, const boolList&); virtual void resetAddressing(const unallocLabelList&, const boolList&);
//- Check zone definition. Return true if in error. //- Check zone definition. Return true if in error.
virtual bool checkDefinition(const bool report = false) const; virtual bool checkDefinition(const bool report = false) const;

View File

@ -46,7 +46,7 @@ const char* const Foam::pointZone::labelsName = "pointLabels";
Foam::pointZone::pointZone Foam::pointZone::pointZone
( (
const word& name, const word& name,
const labelList& addr, const unallocLabelList& addr,
const label index, const label index,
const pointZoneMesh& zm const pointZoneMesh& zm
) )
@ -85,7 +85,7 @@ Foam::pointZone::pointZone
Foam::pointZone::pointZone Foam::pointZone::pointZone
( (
const pointZone& pz, const pointZone& pz,
const labelList& addr, const unallocLabelList& addr,
const label index, const label index,
const pointZoneMesh& zm const pointZoneMesh& zm
) )
@ -154,7 +154,14 @@ void Foam::pointZone::operator=(const pointZone& zn)
} }
void Foam::pointZone::operator=(const labelList& addr) void Foam::pointZone::operator=(const unallocLabelList& addr)
{
clearAddressing();
labelList::operator=(addr);
}
void Foam::pointZone::operator=(const Xfer<labelList>& addr)
{ {
clearAddressing(); clearAddressing();
labelList::operator=(addr); labelList::operator=(addr);

View File

@ -112,7 +112,7 @@ public:
pointZone pointZone
( (
const word& name, const word& name,
const labelList& addr, const unallocLabelList& addr,
const label index, const label index,
const pointZoneMesh& const pointZoneMesh&
); );
@ -140,7 +140,7 @@ public:
pointZone pointZone
( (
const pointZone&, const pointZone&,
const labelList& addr, const unallocLabelList& addr,
const label index, const label index,
const pointZoneMesh& const pointZoneMesh&
); );
@ -170,7 +170,7 @@ public:
( (
const pointZoneMesh& zm, const pointZoneMesh& zm,
const label index, const label index,
const labelList& addr const unallocLabelList& addr
) const ) const
{ {
return autoPtr<pointZone> return autoPtr<pointZone>
@ -218,11 +218,14 @@ public:
// Member Operators // Member Operators
//- Assign to zone clearing demand-driven data //- Assign to zone, clearing demand-driven data
void operator=(const pointZone&); void operator=(const pointZone&);
//- Assign addressing clearing demand-driven data //- Assign addressing, clearing demand-driven data
void operator=(const labelList&); void operator=(const unallocLabelList&);
//- Assign addressing, clearing demand-driven data
void operator=(const Xfer<labelList>&);
// I-O // I-O

View File

@ -85,7 +85,7 @@ void Foam::zone::calcLookupMap() const
Foam::zone::zone Foam::zone::zone
( (
const word& name, const word& name,
const labelList& addr, const unallocLabelList& addr,
const label index const label index
) )
: :
@ -128,7 +128,7 @@ Foam::zone::zone
Foam::zone::zone Foam::zone::zone
( (
const zone& z, const zone& z,
const labelList& addr, const unallocLabelList& addr,
const label index const label index
) )
: :

View File

@ -101,7 +101,7 @@ public:
zone zone
( (
const word& name, const word& name,
const labelList& addr, const unallocLabelList& addr,
const label index const label index
); );
@ -127,7 +127,7 @@ public:
zone zone
( (
const zone&, const zone&,
const labelList& addr, const unallocLabelList& addr,
const label index const label index
); );