ENH: add faceZone::resetAddressing with constant flipMap

- remove unused static variable, use updated hashtable methods
This commit is contained in:
Mark Olesen
2017-10-04 08:55:00 +02:00
parent 44cfc93b82
commit 24577907a1
17 changed files with 281 additions and 258 deletions

View File

@ -76,100 +76,102 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
label addPointZone(const polyMesh& mesh, const word& name) label addPointZone(polyMesh& mesh, const word& name)
{ {
label zoneID = mesh.pointZones().findZoneID(name); pointZoneMesh& zones = mesh.pointZones();
label zoneID = zones.findZoneID(name);
if (zoneID != -1) if (zoneID != -1)
{ {
Info<< "Reusing existing pointZone " Info<< "Reusing existing pointZone " << zones[zoneID].name()
<< mesh.pointZones()[zoneID].name()
<< " at index " << zoneID << endl; << " at index " << zoneID << endl;
}
else
{
pointZoneMesh& pointZones = const_cast<polyMesh&>(mesh).pointZones();
zoneID = pointZones.size();
Info<< "Adding pointZone " << name << " at index " << zoneID << endl;
pointZones.setSize(zoneID+1); return zoneID;
pointZones.set
(
zoneID,
new pointZone
(
name,
labelList(0),
zoneID,
pointZones
)
);
} }
zoneID = zones.size();
Info<< "Adding pointZone " << name << " at index " << zoneID << endl;
zones.setSize(zoneID+1);
zones.set
(
zoneID,
new pointZone
(
name,
labelList(0),
zoneID,
zones
)
);
return zoneID; return zoneID;
} }
label addFaceZone(const polyMesh& mesh, const word& name) label addFaceZone(polyMesh& mesh, const word& name)
{ {
label zoneID = mesh.faceZones().findZoneID(name); faceZoneMesh& zones = mesh.faceZones();
label zoneID = zones.findZoneID(name);
if (zoneID != -1) if (zoneID != -1)
{ {
Info<< "Reusing existing faceZone " << mesh.faceZones()[zoneID].name() Info<< "Reusing existing faceZone " << zones[zoneID].name()
<< " at index " << zoneID << endl; << " at index " << zoneID << endl;
}
else
{
faceZoneMesh& faceZones = const_cast<polyMesh&>(mesh).faceZones();
zoneID = faceZones.size();
Info<< "Adding faceZone " << name << " at index " << zoneID << endl;
faceZones.setSize(zoneID+1); return zoneID;
faceZones.set
(
zoneID,
new faceZone
(
name,
labelList(0),
boolList(),
zoneID,
faceZones
)
);
} }
zoneID = zones.size();
Info<< "Adding faceZone " << name << " at index " << zoneID << endl;
zones.setSize(zoneID+1);
zones.set
(
zoneID,
new faceZone
(
name,
labelList(0),
boolList(),
zoneID,
zones
)
);
return zoneID; return zoneID;
} }
label addCellZone(const polyMesh& mesh, const word& name) label addCellZone(polyMesh& mesh, const word& name)
{ {
label zoneID = mesh.cellZones().findZoneID(name); cellZoneMesh& zones = mesh.cellZones();
label zoneID = zones.findZoneID(name);
if (zoneID != -1) if (zoneID != -1)
{ {
Info<< "Reusing existing cellZone " << mesh.cellZones()[zoneID].name() Info<< "Reusing existing cellZone " << zones[zoneID].name()
<< " at index " << zoneID << endl; << " at index " << zoneID << endl;
}
else
{
cellZoneMesh& cellZones = const_cast<polyMesh&>(mesh).cellZones();
zoneID = cellZones.size();
Info<< "Adding cellZone " << name << " at index " << zoneID << endl;
cellZones.setSize(zoneID+1); return zoneID;
cellZones.set
(
zoneID,
new cellZone
(
name,
labelList(0),
zoneID,
cellZones
)
);
} }
zoneID = zones.size();
Info<< "Adding cellZone " << name << " at index " << zoneID << endl;
zones.setSize(zoneID+1);
zones.set
(
zoneID,
new cellZone
(
name,
labelList(0),
zoneID,
zones
)
);
return zoneID; return zoneID;
} }
@ -340,13 +342,9 @@ int main(int argc, char *argv[])
if (perfectCover) if (perfectCover)
{ {
// Add empty zone for resulting internal faces // Add empty zone for resulting internal faces
label cutZoneID = addFaceZone(mesh, cutZoneName); const label cutZoneID = addFaceZone(mesh, cutZoneName);
mesh.faceZones()[cutZoneID].resetAddressing mesh.faceZones()[cutZoneID].resetAddressing(isf.xfer(), false);
(
isf,
boolList(masterPatch.size(), false)
);
// Add the perfect interface mesh modifier // Add the perfect interface mesh modifier
stitcher.set stitcher.set
@ -370,11 +368,7 @@ int main(int argc, char *argv[])
label masterZoneID = addFaceZone(mesh, mergePatchName + "MasterZone"); label masterZoneID = addFaceZone(mesh, mergePatchName + "MasterZone");
mesh.faceZones()[masterZoneID].resetAddressing mesh.faceZones()[masterZoneID].resetAddressing(isf.xfer(), false);
(
isf,
boolList(masterPatch.size(), false)
);
// Slave patch // Slave patch
const polyPatch& slavePatch = mesh.boundaryMesh()[slavePatchName]; const polyPatch& slavePatch = mesh.boundaryMesh()[slavePatchName];
@ -387,19 +381,11 @@ int main(int argc, char *argv[])
} }
label slaveZoneID = addFaceZone(mesh, mergePatchName + "SlaveZone"); label slaveZoneID = addFaceZone(mesh, mergePatchName + "SlaveZone");
mesh.faceZones()[slaveZoneID].resetAddressing mesh.faceZones()[slaveZoneID].resetAddressing(osf.xfer(), false);
(
osf,
boolList(slavePatch.size(), false)
);
// Add empty zone for cut faces // Add empty zone for cut faces
label cutZoneID = addFaceZone(mesh, cutZoneName); const label cutZoneID = addFaceZone(mesh, cutZoneName);
mesh.faceZones()[cutZoneID].resetAddressing mesh.faceZones()[cutZoneID].resetAddressing(labelList(0), false);
(
labelList(0),
boolList(0, false)
);
// Add the sliding interface mesh modifier // Add the sliding interface mesh modifier

View File

@ -247,17 +247,7 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::whichZone
const label objectIndex const label objectIndex
) const ) const
{ {
const Map<label>& zm = zoneMap(); return zoneMap().lookup(objectIndex, -1);
Map<label>::const_iterator zmIter = zm.find(objectIndex);
if (zmIter == zm.end())
{
return -1;
}
else
{
return zmIter();
}
} }
@ -579,13 +569,13 @@ bool Foam::ZoneMesh<ZoneType, MeshType>::checkParallelSync
template<class ZoneType, class MeshType> template<class ZoneType, class MeshType>
void Foam::ZoneMesh<ZoneType, MeshType>::movePoints(const pointField& p) void Foam::ZoneMesh<ZoneType, MeshType>::movePoints(const pointField& pts)
{ {
PtrList<ZoneType>& zones = *this; PtrList<ZoneType>& zones = *this;
forAll(zones, zonei) forAll(zones, zonei)
{ {
zones[zonei].movePoints(p); zones[zonei].movePoints(pts);
} }
} }

View File

@ -176,7 +176,7 @@ 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& key) const; label findIndex(const keyType& key) const;
//- Find zone index given a name //- Find zone index given a name, return -1 if not found
label findZoneID(const word& zoneName) const; label findZoneID(const word& zoneName) const;
//- Mark cells that match the zone specification //- Mark cells that match the zone specification
@ -191,12 +191,12 @@ public:
//- Check zone definition. Return true if in error. //- Check zone definition. Return true if in error.
bool checkDefinition(const bool report = false) const; bool checkDefinition(const bool report = false) const;
//- Check whether all procs have all zones and in same order. Return //- Check whether all procs have all zones and in same order.
// true if in error. // \return True if any errors.
bool checkParallelSync(const bool report = false) const; bool checkParallelSync(const bool report = false) const;
//- Correct zone mesh after moving points //- Correct zone mesh after moving points
void movePoints(const pointField& p); void movePoints(const pointField& pts);
//- writeData member function required by regIOobject //- writeData member function required by regIOobject
bool writeData(Ostream& os) const; bool writeData(Ostream& os) const;

View File

@ -33,8 +33,6 @@ Description
#include "cellZone.H" #include "cellZone.H"
#include "cellZoneMeshFwd.H" #include "cellZoneMeshFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -36,10 +36,10 @@ Description
namespace Foam namespace Foam
{ {
template<class Zone, class MeshType> class ZoneMesh;
class cellZone; class cellZone;
class polyMesh; class polyMesh;
template<class Zone, class MeshType> class ZoneMesh;
typedef ZoneMesh<cellZone, polyMesh> cellZoneMesh; typedef ZoneMesh<cellZone, polyMesh> cellZoneMesh;
} }

View File

@ -33,8 +33,6 @@ Description
#include "faceZone.H" #include "faceZone.H"
#include "faceZoneMeshFwd.H" #include "faceZoneMeshFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -36,10 +36,10 @@ Description
namespace Foam namespace Foam
{ {
template<class Zone, class MeshType> class ZoneMesh;
class faceZone; class faceZone;
class polyMesh; class polyMesh;
template<class Zone, class MeshType> class ZoneMesh;
typedef ZoneMesh<faceZone, polyMesh> faceZoneMesh; typedef ZoneMesh<faceZone, polyMesh> faceZoneMesh;
} }

View File

@ -33,8 +33,6 @@ Description
#include "pointZone.H" #include "pointZone.H"
#include "pointZoneMeshFwd.H" #include "pointZoneMeshFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -36,10 +36,10 @@ Description
namespace Foam namespace Foam
{ {
template<class Zone, class MeshType> class ZoneMesh;
class pointZone; class pointZone;
class polyMesh; class polyMesh;
template<class Zone, class MeshType> class ZoneMesh;
typedef ZoneMesh<pointZone, polyMesh> pointZoneMesh; typedef ZoneMesh<pointZone, polyMesh> pointZoneMesh;
} }

View File

@ -42,6 +42,7 @@ namespace Foam
const char * const Foam::cellZone::labelsName = "cellLabels"; const char * const Foam::cellZone::labelsName = "cellLabels";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cellZone::cellZone Foam::cellZone::cellZone

View File

@ -52,7 +52,7 @@ namespace Foam
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class cellZone; class cellZone;
Ostream& operator<<(Ostream&, const cellZone&); Ostream& operator<<(Ostream& os, const cellZone& zn);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -64,6 +64,12 @@ class cellZone
public zone public zone
{ {
// Private Member Functions
//- Disallow default bitwise copy construct
cellZone(const cellZone&) = delete;
protected: protected:
// Protected data // Protected data
@ -72,14 +78,6 @@ protected:
const cellZoneMesh& zoneMesh_; const cellZoneMesh& zoneMesh_;
private:
// Private Member Functions
//- Disallow default bitwise copy construct
cellZone(const cellZone&);
public: public:
// Static data members // Static data members
@ -117,7 +115,7 @@ public:
const word& name, const word& name,
const labelUList& addr, const labelUList& addr,
const label index, const label index,
const cellZoneMesh& const cellZoneMesh& zm
); );
//- Construct from components, transferring contents //- Construct from components, transferring contents
@ -126,36 +124,36 @@ public:
const word& name, const word& name,
const Xfer<labelList>& addr, const Xfer<labelList>& addr,
const label index, const label index,
const cellZoneMesh& const cellZoneMesh& zm
); );
//- Construct from dictionary //- Construct from dictionary
cellZone cellZone
( (
const word& name, const word& name,
const dictionary&, const dictionary& dict,
const label index, const label index,
const cellZoneMesh& const cellZoneMesh& zm
); );
//- Construct given the original zone and resetting the //- Construct given the original zone,
// cell list and zone mesh information // resetting the cell list and zone mesh information
cellZone cellZone
( (
const cellZone&, const cellZone& cz,
const labelUList& addr, const labelUList& addr,
const label index, const label index,
const cellZoneMesh& const cellZoneMesh& zm
); );
//- Construct given the original zone, resetting the //- Construct given the original zone,
// cell list and zone mesh information // resetting the cell list and zone mesh information
cellZone cellZone
( (
const cellZone&, const cellZone& cz,
const Xfer<labelList>& addr, const Xfer<labelList>& addr,
const label index, const label index,
const cellZoneMesh& const cellZoneMesh& zm
); );
//- Construct and return a clone, resetting the zone mesh //- Construct and return a clone, resetting the zone mesh
@ -190,9 +188,9 @@ public:
static autoPtr<cellZone> New static autoPtr<cellZone> New
( (
const word& name, const word& name,
const dictionary&, const dictionary& dict,
const label index, const label index,
const cellZoneMesh& const cellZoneMesh& zm
); );
@ -211,33 +209,33 @@ public:
//- 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;
//- Check whether zone is synchronised across coupled boundaries. Return //- Check whether zone is synchronised across coupled boundaries.
// true if in error. // \return True if any errors.
virtual bool checkParallelSync(const bool report = false) const virtual bool checkParallelSync(const bool report = false) const
{ {
return false; return false;
} }
//- Write dictionary //- Write dictionary
virtual void writeDict(Ostream&) const; virtual void writeDict(Ostream& os) const;
// 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& zn);
//- Assign addressing, clearing demand-driven data //- Assign addressing, clearing demand-driven data
void operator=(const labelUList&); void operator=(const labelUList& addr);
//- Assign addressing, clearing demand-driven data //- Assign addressing, clearing demand-driven data
void operator=(const Xfer<labelList>&); void operator=(const Xfer<labelList>& addr);
// I-O // I-O
//- Ostream Operator //- Ostream Operator
friend Ostream& operator<<(Ostream&, const cellZone&); friend Ostream& operator<<(Ostream& os, const cellZone& zn);
}; };

View File

@ -43,6 +43,23 @@ namespace Foam
const char* const Foam::faceZone::labelsName = "faceLabels"; const char* const Foam::faceZone::labelsName = "faceLabels";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::faceZone::setFlipMap(const bool flipValue)
{
// Match size for flipMap
if (flipMap_.size() == this->size())
{
flipMap_ = flipValue;
}
else
{
// Avoid copying old values on resize
flipMap_.clear();
flipMap_.setSize(this->size(), flipValue);
}
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -128,8 +145,8 @@ void Foam::faceZone::calcCellLayers() const
forAll(mf, facei) forAll(mf, facei)
{ {
label ownCelli = own[mf[facei]]; const label ownCelli = own[mf[facei]];
label neiCelli = const label neiCelli =
( (
zoneMesh().mesh().isInternalFace(mf[facei]) zoneMesh().mesh().isInternalFace(mf[facei])
? nei[mf[facei]] ? nei[mf[facei]]
@ -386,6 +403,30 @@ void Foam::faceZone::resetAddressing
} }
void Foam::faceZone::resetAddressing
(
const labelUList& addr,
const bool flipValue
)
{
clearAddressing();
labelList::operator=(addr);
setFlipMap(flipValue);
}
void Foam::faceZone::resetAddressing
(
const Xfer<labelList>& addr,
const bool flipValue
)
{
clearAddressing();
labelList::operator=(addr);
setFlipMap(flipValue);
}
void Foam::faceZone::updateMesh(const mapPolyMesh& mpm) void Foam::faceZone::updateMesh(const mapPolyMesh& mpm)
{ {
clearAddressing(); clearAddressing();
@ -511,11 +552,11 @@ bool Foam::faceZone::checkParallelSync(const bool report) const
} }
void Foam::faceZone::movePoints(const pointField& p) void Foam::faceZone::movePoints(const pointField& pts)
{ {
if (patchPtr_) if (patchPtr_)
{ {
patchPtr_->movePoints(p); patchPtr_->movePoints(pts);
} }
} }

View File

@ -55,7 +55,7 @@ class mapPolyMesh;
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class faceZone; class faceZone;
Ostream& operator<<(Ostream&, const faceZone&); Ostream& operator<<(Ostream& os, const faceZone& zn);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -66,46 +66,43 @@ class faceZone
: :
public zone public zone
{ {
// Private data
//- The name associated with the zone-labels dictionary entry
static const word labelsName_;
// Private Member Functions // Private Member Functions
//- Set flip-map to constant value
void setFlipMap(const bool flipValue);
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
faceZone(const faceZone&); faceZone(const faceZone&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const faceZone&); void operator=(const faceZone&) = delete;
protected: protected:
// Protected data // Protected data
//- Flip map for all faces in the zone. Set to true if the //- Flip map for all faces in the zone.
// face needs to be flipped to achieve the correct orientation. // Use true if the face needs flipping for the correct orientation.
boolList flipMap_; boolList flipMap_;
//- Reference to zone list //- Reference to zone list
const faceZoneMesh& zoneMesh_; const faceZoneMesh& zoneMesh_;
// Demand-driven private data // Demand-driven data
//- Primitive patch made out of correctly flipped faces //- Primitive patch made out of correctly flipped faces
mutable primitiveFacePatch* patchPtr_; mutable primitiveFacePatch* patchPtr_;
//- Master cell layer //- Master cell layer
mutable labelList* masterCellsPtr_; mutable labelList* masterCellsPtr_;
//- Slave cell layer //- Slave cell layer
mutable labelList* slaveCellsPtr_; mutable labelList* slaveCellsPtr_;
//- Global edge addressing //- Global edge addressing
mutable labelList* mePtr_; mutable labelList* mePtr_;
// Protected Member Functions // Protected Member Functions
@ -168,38 +165,38 @@ public:
const Xfer<labelList>& addr, const Xfer<labelList>& addr,
const Xfer<boolList>& fm, const Xfer<boolList>& fm,
const label index, const label index,
const faceZoneMesh& const faceZoneMesh& zm
); );
//- Construct from dictionary //- Construct from dictionary
faceZone faceZone
( (
const word& name, const word& name,
const dictionary&, const dictionary& dict,
const label index, const label index,
const faceZoneMesh& const faceZoneMesh& zm
); );
//- Construct given the original zone and resetting the //- Construct given the original zone and resetting the
// face list and zone mesh information // face list and zone mesh information
faceZone faceZone
( (
const faceZone&, const faceZone& fz,
const labelUList& addr, const labelUList& addr,
const boolList& fm, const boolList& fm,
const label index, const label index,
const faceZoneMesh& const faceZoneMesh& zm
); );
//- Construct given the original zone, resetting the //- Construct given the original zone,
// face list and zone mesh information // resetting the face list and zone mesh information
faceZone faceZone
( (
const faceZone&, const faceZone& fz,
const Xfer<labelList>& addr, const Xfer<labelList>& addr,
const Xfer<boolList>& fm, const Xfer<boolList>& fm,
const label index, const label index,
const faceZoneMesh& const faceZoneMesh& zm
); );
//- Construct and return a clone, resetting the zone mesh //- Construct and return a clone, resetting the zone mesh
@ -235,9 +232,9 @@ public:
static autoPtr<faceZone> New static autoPtr<faceZone> New
( (
const word& name, const word& name,
const dictionary&, const dictionary& dict,
const label index, const label index,
const faceZoneMesh& const faceZoneMesh& zm
); );
@ -247,6 +244,9 @@ public:
// Member Functions // Member Functions
//- Return zoneMesh reference
const faceZoneMesh& zoneMesh() const;
//- Return face flip map //- Return face flip map
const boolList& flipMap() const const boolList& flipMap() const
{ {
@ -259,52 +259,71 @@ public:
//- Return reference to primitive patch //- Return reference to primitive patch
const primitiveFacePatch& operator()() const; const primitiveFacePatch& operator()() const;
//- Return zoneMesh reference
const faceZoneMesh& zoneMesh() const;
// Addressing into mesh
// Addressing into mesh //- Return labels of master cells (cells next to the master face
// zone in the prescribed direction)
const labelList& masterCells() const;
//- Return labels of master cells (cells next to the master face //- Return labels of slave cells
// zone in the prescribed direction) const labelList& slaveCells() const;
const labelList& masterCells() const;
//- Return labels of slave cells //- Return global edge index for local edges
const labelList& slaveCells() const; const labelList& meshEdges() const;
//- Return global edge index for local edges
const labelList& meshEdges() const;
//- Clear addressing //- Clear addressing
virtual void clearAddressing(); virtual void clearAddressing();
//- Reset addressing and flip map (clearing demand-driven data) //- Reset addressing and flip map.
virtual void resetAddressing(const labelUList&, const boolList&); // Clears demand-driven data.
virtual void resetAddressing
(
const labelUList& addr,
const boolList& flipMap
);
//- Reset addressing - use constant flip map
// Clears demand-driven data.
virtual void resetAddressing
(
const labelUList& addr,
const bool flipValue
);
//- Reset addressing - use constant flip map
// Clears demand-driven data.
virtual void resetAddressing
(
const Xfer<labelList>& addr,
const bool flipValue
);
//- 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;
//- Check whether all procs have faces synchronised. Return //- Check whether all procs have faces synchronised.
// true if in error. // \return True if any errors.
virtual bool checkParallelSync(const bool report = false) const; virtual bool checkParallelSync(const bool report = false) const;
//- Correct patch after moving points //- Correct patch after moving points
virtual void movePoints(const pointField&); virtual void movePoints(const pointField& pts);
//- Update for changes in topology //- Update for changes in topology
virtual void updateMesh(const mapPolyMesh&); virtual void updateMesh(const mapPolyMesh& mpm);
//- Write //- Write
virtual void write(Ostream&) const; virtual void write(Ostream& os) const;
//- Write dictionary //- Write dictionary
virtual void writeDict(Ostream&) const; virtual void writeDict(Ostream& os) const;
// I-O // I-O
//- Ostream Operator //- Ostream Operator
friend Ostream& operator<<(Ostream&, const faceZone&); friend Ostream& operator<<(Ostream& os, const faceZone& zn);
}; };

View File

@ -42,6 +42,7 @@ namespace Foam
const char* const Foam::pointZone::labelsName = "pointLabels"; const char* const Foam::pointZone::labelsName = "pointLabels";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pointZone::pointZone Foam::pointZone::pointZone

View File

@ -53,7 +53,7 @@ namespace Foam
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class pointZone; class pointZone;
Ostream& operator<<(Ostream&, const pointZone&); Ostream& operator<<(Ostream& os, const pointZone& zn);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -64,6 +64,11 @@ class pointZone
: :
public zone public zone
{ {
// Private Member Functions
//- Disallow default bitwise copy construct
pointZone(const pointZone&) = delete;
protected: protected:
@ -72,10 +77,6 @@ protected:
//- Reference to zone list //- Reference to zone list
const pointZoneMesh& zoneMesh_; const pointZoneMesh& zoneMesh_;
// Private Member Functions
//- Disallow default bitwise copy construct
pointZone(const pointZone&);
public: public:
@ -114,7 +115,7 @@ public:
const word& name, const word& name,
const labelUList& addr, const labelUList& addr,
const label index, const label index,
const pointZoneMesh& const pointZoneMesh& zm
); );
//- Construct from components, transferring contents //- Construct from components, transferring contents
@ -123,36 +124,36 @@ public:
const word& name, const word& name,
const Xfer<labelList>& addr, const Xfer<labelList>& addr,
const label index, const label index,
const pointZoneMesh& const pointZoneMesh& zm
); );
//- Construct from dictionary //- Construct from dictionary
pointZone pointZone
( (
const word& name, const word& name,
const dictionary&, const dictionary& dict,
const label index, const label index,
const pointZoneMesh& const pointZoneMesh& zm
); );
//- Construct given the original zone and resetting the //- Construct given the original zone and resetting the
// point list and zone mesh information // point list and zone mesh information
pointZone pointZone
( (
const pointZone&, const pointZone& pz,
const labelUList& addr, const labelUList& addr,
const label index, const label index,
const pointZoneMesh& const pointZoneMesh& zm
); );
//- Construct given the original zone, resetting the //- Construct given the original zone,
// face list and zone mesh information // resetting the point list and zone mesh information
pointZone pointZone
( (
const pointZone&, const pointZone& pz,
const Xfer<labelList>& addr, const Xfer<labelList>& addr,
const label index, const label index,
const pointZoneMesh& const pointZoneMesh& zm
); );
//- Construct and return a clone, resetting the zone mesh //- Construct and return a clone, resetting the zone mesh
@ -187,9 +188,9 @@ public:
static autoPtr<pointZone> New static autoPtr<pointZone> New
( (
const word& name, const word& name,
const dictionary&, const dictionary& dict,
const label index, const label index,
const pointZoneMesh& const pointZoneMesh& zm
); );
@ -208,8 +209,8 @@ public:
//- 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;
//- Check whether zone is synchronised across coupled boundaries. Return //- Check whether zone is synchronised across coupled boundaries.
// true if in error. // \return True if any errors.
virtual bool checkParallelSync(const bool report = false) const; virtual bool checkParallelSync(const bool report = false) const;
//- Correct patch after moving points //- Correct patch after moving points
@ -217,25 +218,25 @@ public:
{} {}
//- Write dictionary //- Write dictionary
virtual void writeDict(Ostream&) const; virtual void writeDict(Ostream& os) const;
// 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& zn);
//- Assign addressing, clearing demand-driven data //- Assign addressing, clearing demand-driven data
void operator=(const labelUList&); void operator=(const labelUList& addr);
//- Assign addressing, clearing demand-driven data //- Assign addressing, clearing demand-driven data
void operator=(const Xfer<labelList>&); void operator=(const Xfer<labelList>& addr);
// I-O // I-O
//- Ostream Operator //- Ostream Operator
friend Ostream& operator<<(Ostream&, const pointZone&); friend Ostream& operator<<(Ostream& os, const pointZone& zn);
}; };

View File

@ -127,13 +127,13 @@ Foam::zone::zone
Foam::zone::zone Foam::zone::zone
( (
const zone& z, const zone& zn,
const labelUList& addr, const labelUList& addr,
const label index const label index
) )
: :
labelList(addr), labelList(addr),
name_(z.name()), name_(zn.name()),
index_(index), index_(index),
lookupMapPtr_(nullptr) lookupMapPtr_(nullptr)
{} {}
@ -141,13 +141,13 @@ Foam::zone::zone
Foam::zone::zone Foam::zone::zone
( (
const zone& z, const zone& zn,
const Xfer<labelList>& addr, const Xfer<labelList>& addr,
const label index const label index
) )
: :
labelList(addr), labelList(addr),
name_(z.name()), name_(zn.name()),
index_(index), index_(index),
lookupMapPtr_(nullptr) lookupMapPtr_(nullptr)
{} {}
@ -165,18 +165,7 @@ Foam::zone::~zone()
Foam::label Foam::zone::localID(const label globalCellID) const Foam::label Foam::zone::localID(const label globalCellID) const
{ {
const Map<label>& lm = lookupMap(); return lookupMap().lookup(globalCellID, -1);
Map<label>::const_iterator lmIter = lm.find(globalCellID);
if (lmIter == lm.end())
{
return -1;
}
else
{
return lmIter();
}
} }
@ -197,7 +186,8 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
forAll(addr, i) forAll(addr, i)
{ {
if (addr[i] < 0 || addr[i] >= maxSize) const label idx = addr[i];
if (idx < 0 || idx >= maxSize)
{ {
hasError = true; hasError = true;
@ -205,7 +195,7 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
{ {
SeriousErrorInFunction SeriousErrorInFunction
<< "Zone " << name_ << "Zone " << name_
<< " contains invalid index label " << addr[i] << nl << " contains invalid index label " << idx << nl
<< "Valid index labels are 0.." << "Valid index labels are 0.."
<< maxSize-1 << endl; << maxSize-1 << endl;
} }
@ -215,13 +205,13 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
break; break;
} }
} }
else if (!elems.insert(addr[i])) else if (!elems.insert(idx))
{ {
if (report) if (report)
{ {
WarningInFunction WarningInFunction
<< "Zone " << name_ << "Zone " << name_
<< " contains duplicate index label " << addr[i] << endl; << " contains duplicate index label " << idx << endl;
} }
} }
} }
@ -239,9 +229,9 @@ void Foam::zone::write(Ostream& os) const
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const zone& z) Foam::Ostream& Foam::operator<<(Ostream& os, const zone& zn)
{ {
z.write(os); zn.write(os);
os.check(FUNCTION_NAME); os.check(FUNCTION_NAME);
return os; return os;
} }

View File

@ -49,7 +49,7 @@ namespace Foam
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class zone; class zone;
Ostream& operator<<(Ostream&, const zone&); Ostream& operator<<(Ostream& os, const zone& zn);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class zone Declaration Class zone Declaration
@ -59,6 +59,11 @@ class zone
: :
public labelList public labelList
{ {
// Private Member Functions
//- Disallow default bitwise copy construct
zone(const zone&) = delete;
protected: protected:
@ -71,10 +76,10 @@ protected:
label index_; label index_;
// Demand-driven private data // Demand-driven private data
//- Map of labels in zone for fast location lookup //- Map of labels in zone for fast location lookup
mutable Map<label>* lookupMapPtr_; mutable Map<label>* lookupMapPtr_;
// Protected Member Functions // Protected Member Functions
@ -82,9 +87,6 @@ protected:
//- Construct the look-up map //- Construct the look-up map
void calcLookupMap() const; void calcLookupMap() const;
//- Disallow default bitwise copy construct
zone(const zone&);
public: public:
@ -114,7 +116,7 @@ public:
zone zone
( (
const word& name, const word& name,
const dictionary&, const dictionary& dict,
const word& labelsName, const word& labelsName,
const label index const label index
); );
@ -123,7 +125,7 @@ public:
// cell list and zone mesh information // cell list and zone mesh information
zone zone
( (
const zone&, const zone& zn,
const labelUList& addr, const labelUList& addr,
const label index const label index
); );
@ -132,7 +134,7 @@ public:
// cell list and zone mesh information // cell list and zone mesh information
zone zone
( (
const zone&, const zone& zn,
const Xfer<labelList>& addr, const Xfer<labelList>& addr,
const label index const label index
); );
@ -178,20 +180,20 @@ public:
) const; ) const;
//- Correct patch after moving points //- Correct patch after moving points
virtual void movePoints(const pointField&) virtual void movePoints(const pointField& pts)
{} {}
//- Write //- Write
virtual void write(Ostream&) const; virtual void write(Ostream& os) const;
//- Write dictionary //- Write dictionary
virtual void writeDict(Ostream&) const = 0; virtual void writeDict(Ostream& os) const = 0;
// I-O // I-O
//- Ostream Operator //- Ostream Operator
friend Ostream& operator<<(Ostream&, const zone&); friend Ostream& operator<<(Ostream& os, const zone& zn);
}; };