Commit 2d1398b3 authored by henry's avatar henry
Browse files
parents a1bf420f 3e0ec9d8
......@@ -345,6 +345,9 @@ $(globalMeshData)/globalIndex.C
$(polyMesh)/syncTools/syncTools.C
zone = $(polyMesh)/zones/zone
$(zone)/zone.C
cellZone = $(polyMesh)/zones/cellZone
$(cellZone)/cellZone.C
$(cellZone)/newCellZone.C
......
......@@ -114,6 +114,7 @@ public:
return index_ > -1;
}
// Edit
//- Update
......
......@@ -22,9 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
A subset of mesh cells.
\*---------------------------------------------------------------------------*/
#include "cellZone.H"
......@@ -45,59 +42,9 @@ namespace Foam
addToRunTimeSelectionTable(cellZone, cellZone, dictionary);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const Foam::Map<Foam::label>& Foam::cellZone::cellLookupMap() const
{
if (!cellLookupMapPtr_)
{
calcCellLookupMap();
}
return *cellLookupMapPtr_;
}
void Foam::cellZone::calcCellLookupMap() const
{
if (debug)
{
Info<< "void cellZone::calcCellLookupMap() const : "
<< "Calculating cell lookup map"
<< endl;
}
if (cellLookupMapPtr_)
{
FatalErrorIn
(
"void cellZone::calcCellLookupMap() const"
) << "cell lookup map already calculated"
<< abort(FatalError);
}
const labelList& addr = *this;
cellLookupMapPtr_ = new Map<label>(2*addr.size());
Map<label>& clm = *cellLookupMapPtr_;
forAll (addr, cellI)
{
clm.insert(addr[cellI], cellI);
}
if (debug)
{
Info<< "void cellZone::calcCellLookupMap() const : "
<< "Finished calculating cell lookup map"
<< endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::cellZone::cellZone
(
const word& name,
......@@ -106,11 +53,8 @@ Foam::cellZone::cellZone
const cellZoneMesh& zm
)
:
labelList(addr),
name_(name),
index_(index),
zoneMesh_(zm),
cellLookupMapPtr_(NULL)
zone(name, addr, index),
zoneMesh_(zm)
{}
......@@ -122,15 +66,11 @@ Foam::cellZone::cellZone
const cellZoneMesh& zm
)
:
labelList(addr),
name_(name),
index_(index),
zoneMesh_(zm),
cellLookupMapPtr_(NULL)
zone(name, addr, index),
zoneMesh_(zm)
{}
// Construct from dictionary
Foam::cellZone::cellZone
(
const word& name,
......@@ -139,16 +79,11 @@ Foam::cellZone::cellZone
const cellZoneMesh& zm
)
:
labelList(dict.lookup("cellLabels")),
name_(name),
index_(index),
zoneMesh_(zm),
cellLookupMapPtr_(NULL)
zone("cell", name, dict, index),
zoneMesh_(zm)
{}
// Construct given the original zone and resetting the
// cell list and zone mesh information
Foam::cellZone::cellZone
(
const cellZone& cz,
......@@ -157,11 +92,8 @@ Foam::cellZone::cellZone
const cellZoneMesh& zm
)
:
labelList(addr),
name_(cz.name()),
index_(index),
zoneMesh_(zm),
cellLookupMapPtr_(NULL)
zone(cz, addr, index),
zoneMesh_(zm)
{}
Foam::cellZone::cellZone
......@@ -172,38 +104,22 @@ Foam::cellZone::cellZone
const cellZoneMesh& zm
)
:
labelList(addr),
name_(cz.name()),
index_(index),
zoneMesh_(zm),
cellLookupMapPtr_(NULL)
zone(cz, addr, index),
zoneMesh_(zm)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cellZone::~cellZone()
{
clearAddressing();
}
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::cellZone::whichCell(const label globalCellID) const
{
const Map<label>& clm = cellLookupMap();
Map<label>::const_iterator clmIter = clm.find(globalCellID);
if (clmIter == clm.end())
{
return -1;
}
else
{
return clmIter();
}
return zone::localID(globalCellID);
}
......@@ -213,45 +129,9 @@ const Foam::cellZoneMesh& Foam::cellZone::zoneMesh() const
}
void Foam::cellZone::clearAddressing()
{
deleteDemandDrivenData(cellLookupMapPtr_);
}
bool Foam::cellZone::checkDefinition(const bool report) const
{
const labelList& addr = *this;
bool boundaryError = false;
forAll(addr, i)
{
if (addr[i] < 0 || addr[i] >= zoneMesh_.mesh().nCells())
{
boundaryError = true;
if (report)
{
SeriousErrorIn
(
"bool cellZone::checkDefinition("
"const bool report) const"
) << "Zone " << name()
<< " contains invalid cell label " << addr[i] << nl
<< "Valid cell labels are 0.."
<< zoneMesh_.mesh().nCells()-1 << endl;
}
}
}
return boundaryError;
}
void Foam::cellZone::write(Ostream& os) const
{
os << nl << name()
<< nl << static_cast<const labelList&>(*this);
return zone::checkDefinition(zoneMesh_.mesh().nCells(), report);
}
......@@ -284,10 +164,10 @@ void Foam::cellZone::operator=(const labelList& addr)
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const cellZone& p)
Foam::Ostream& Foam::operator<<(Ostream& os, const cellZone& cz)
{
p.write(os);
os.check("Ostream& operator<<(Ostream& f, const cellZone& p");
cz.write(os);
os.check("Ostream& operator<<(Ostream& os, const cellZone& cz");
return os;
}
......
......@@ -42,12 +42,8 @@ SourceFiles
#ifndef cellZone_H
#define cellZone_H
#include "labelList.H"
#include "typeInfo.H"
#include "dictionary.H"
#include "zone.H"
#include "cellZoneMeshFwd.H"
#include "pointFieldFwd.H"
#include "Map.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -66,36 +62,22 @@ Ostream& operator<<(Ostream&, const cellZone&);
class cellZone
:
public labelList
public zone
{
// Private data
//- Name of zone
word name_;
protected:
//- Index of zone
label index_;
// Protected data
//- Reference to zone list
const cellZoneMesh& zoneMesh_;
// Demand-driven private data
//- Map of cell labels in zone for fast location lookup
mutable Map<label>* cellLookupMapPtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
cellZone(const cellZone&);
//- Return map of local cell indices
const Map<label>& cellLookupMap() const;
//- Build map of local cell indices
void calcCellLookupMap() const;
public:
......@@ -208,45 +190,19 @@ public:
//- Destructor
virtual ~cellZone();
virtual ~cellZone();
// Member Functions
//- Return name
const word& name() const
{
return name_;
}
//- Map storing the local cell index for every global cell
// index. Used to find out the index of cell in the zone from
// the known global cell index. If the cell is not in the
// zone, returns -1
//- Helper function to re-direct to zone::localID(...)
label whichCell(const label globalCellID) const;
//- Return the index of this zone in zone list
label index() const
{
return index_;
}
//- Return zoneMesh reference
const cellZoneMesh& zoneMesh() const;
//- Clear addressing
void clearAddressing();
//- Check zone definition. Return true if in error.
bool checkDefinition(const bool report = false) const;
//- Correct patch after moving points
virtual void movePoints(const pointField&)
{}
//- Write
virtual void write(Ostream&) const;
virtual bool checkDefinition(const bool report = false) const;
//- Write dictionary
virtual void writeDict(Ostream&) const;
......@@ -261,8 +217,9 @@ public:
void operator=(const labelList&);
// Ostream Operator
// I-O
//- Ostream Operator
friend Ostream& operator<<(Ostream&, const cellZone&);
};
......
......@@ -22,15 +22,11 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "cellZone.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::cellZone> Foam::cellZone::New
......@@ -61,7 +57,7 @@ Foam::autoPtr<Foam::cellZone> Foam::cellZone::New
"const label, const cellZoneMesh&)",
dict
) << "Unknown cellZone type " << zoneType << endl << endl
<< "Valid cellZone types are :" << endl
<< "Valid cellZone types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalIOError);
}
......@@ -70,6 +66,4 @@ Foam::autoPtr<Foam::cellZone> Foam::cellZone::New
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //
......@@ -22,9 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
A subset of mesh faces.
\*---------------------------------------------------------------------------*/
#include "faceZone.H"
......@@ -100,54 +97,6 @@ void Foam::faceZone::calcFaceZonePatch() const
}
const Foam::Map<Foam::label>& Foam::faceZone::faceLookupMap() const
{
if (!faceLookupMapPtr_)
{
calcFaceLookupMap();
}
return *faceLookupMapPtr_;
}
void Foam::faceZone::calcFaceLookupMap() const
{
if (debug)
{
Info<< "void faceZone::calcFaceLookupMap() const : "
<< "Calculating face lookup map"
<< endl;
}
if (faceLookupMapPtr_)
{
FatalErrorIn
(
"void faceZone::calcFaceLookupMap() const"
) << "face lookup map already calculated"
<< abort(FatalError);
}
const labelList& addr = *this;
faceLookupMapPtr_ = new Map<label>(2*addr.size());
Map<label>& flm = *faceLookupMapPtr_;
forAll (addr, faceI)
{
flm.insert(addr[faceI], faceI);
}
if (debug)
{
Info<< "void faceZone::calcFaceLookupMap() const : "
<< "Finished calculating face lookup map"
<< endl;
}
}
void Foam::faceZone::calcCellLayers() const
{
if (debug)
......@@ -228,16 +177,13 @@ Foam::faceZone::faceZone
const faceZoneMesh& zm
)
:
labelList(addr),
name_(name),
zone(name, addr, index),
flipMap_(fm),
index_(index),
zoneMesh_(zm),
patchPtr_(NULL),
masterCellsPtr_(NULL),
slaveCellsPtr_(NULL),
mePtr_(NULL),
faceLookupMapPtr_(NULL)
mePtr_(NULL)
{
checkAddressing();
}
......@@ -252,22 +198,18 @@ Foam::faceZone::faceZone
const faceZoneMesh& zm
)
:
labelList(addr),
name_(name),
zone(name, addr, index),
flipMap_(fm),
index_(index),
zoneMesh_(zm),
patchPtr_(NULL),
masterCellsPtr_(NULL),
slaveCellsPtr_(NULL),
mePtr_(NULL),
faceLookupMapPtr_(NULL)
mePtr_(NULL)
{
checkAddressing();
}
// Construct from dictionary
Foam::faceZone::faceZone
(
const word& name,
......@@ -276,23 +218,18 @@ Foam::faceZone::faceZone
const faceZoneMesh& zm
)
:
labelList(dict.lookup("faceLabels")),
name_(name),
zone("face", name, dict, index),
flipMap_(dict.lookup("flipMap")),
index_(index),
zoneMesh_(zm),
patchPtr_(NULL),
masterCellsPtr_(NULL),
slaveCellsPtr_(NULL),
mePtr_(NULL),
faceLookupMapPtr_(NULL)
mePtr_(NULL)
{
checkAddressing();
}
// Construct given the original zone and resetting the
// face list and zone mesh information
Foam::faceZone::faceZone
(
const faceZone& fz,
......@@ -302,16 +239,13 @@ Foam::faceZone::faceZone
const faceZoneMesh& zm
)
:
labelList(addr),
name_(fz.name()),
zone(fz, addr, index),
flipMap_(fm),
index_(index),
zoneMesh_(zm),
patchPtr_(NULL),
masterCellsPtr_(NULL),
slaveCellsPtr_(NULL),
mePtr_(NULL),
faceLookupMapPtr_(NULL)
mePtr_(NULL)
{
checkAddressing();
}
......@@ -326,16 +260,13 @@ Foam::faceZone::faceZone
const faceZoneMesh& zm
)
:
labelList(addr),
name_(fz.name()),
zone(fz, addr, index),
flipMap_(fm),
index_(index),
zoneMesh_(zm),
patchPtr_(NULL),
masterCellsPtr_(NULL),
slaveCellsPtr_(NULL),
mePtr_(NULL),
faceLookupMapPtr_(NULL)
mePtr_(NULL)
{
checkAddressing();
}
......@@ -351,26 +282,15 @@ Foam::faceZone::~faceZone()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::faceZone::whichFace(const label globalFaceID) const
const Foam::faceZoneMesh& Foam::faceZone::zoneMesh() const
{
const Map<label>& flm = faceLookupMap();
Map<label>::const_iterator flmIter = flm.find(globalFaceID);
if (flmIter == flm.end())
{
return -1;
}
else
{
return flmIter();
}
return zoneMesh_;
}
const Foam::faceZoneMesh& Foam::faceZone::zoneMesh() const
Foam::label Foam::faceZone::whichFace(const label globalFaceID) const
{
return zoneMesh_;
return zone::localID(globalFaceID);
}
......@@ -450,13 +370,14 @@ const Foam::labelList& Foam::faceZone::meshEdges() const
void Foam::faceZone::clearAddressing()
{
zone::clearAddressing();
deleteDemandDrivenData(patchPtr_);
deleteDemandDrivenData(masterCellsPtr_);
deleteDemandDrivenData(slaveCellsPtr_);
deleteDemandDrivenData(mePtr_);
deleteDemandDrivenData(faceLookupMapPtr_);
}
......@@ -504,30 +425,7 @@ void Foam::faceZone::updateMesh(const mapPolyMesh& mpm)
bool Foam::faceZone::checkDefinition(const bool report) const
{