ENH: improved zone constructors

- constructor for empty cell/face/point Zones, with contents to be
  transferred in later.

- ZoneMesh::operator(const word&) to return existing zone or a new empty one.
This commit is contained in:
Mark Olesen
2017-11-10 02:09:37 +01:00
parent ccc07d3234
commit a59c87d5ac
29 changed files with 591 additions and 441 deletions

View File

@ -642,7 +642,7 @@ int main(int argc, char *argv[])
(
patchNames[patchi],
bFaceLabels,
boolList(bFaceLabels.size(), false),
false, // none are flipped
fz.size(),
pShapeMesh.faceZones()
)

View File

@ -1156,7 +1156,6 @@ int main(int argc, char *argv[])
new cellZone
(
name,
labelList(0),
cellZonei,
mesh.cellZones()
)
@ -1186,8 +1185,6 @@ int main(int argc, char *argv[])
new faceZone
(
name,
labelList(0),
boolList(0),
faceZonei,
mesh.faceZones()
)

View File

@ -1077,7 +1077,6 @@ int main(int argc, char *argv[])
// Create new faces
forAll(faces, facei)
{
if (faces[facei].size() != 2)
{
FatalErrorInFunction
@ -1660,7 +1659,7 @@ int main(int argc, char *argv[])
(
name,
zoneFaces,
boolList(zoneFaces.size(), false),
false, // none are flipped
cnt,
pShapeMesh.faceZones()
);

View File

@ -1102,7 +1102,7 @@ int main(int argc, char *argv[])
(
zoneName,
zoneFaces[zoneI],
boolList(zoneFaces[zoneI].size(), true),
true, // all are flipped
nValidFaceZones,
mesh.faceZones()
);

View File

@ -1282,7 +1282,7 @@ int main(int argc, char *argv[])
(
faceZones.toc()[cnt],
indizes,
boolList(indizes.size(),false),
false, // none are flipped
cnt,
mesh.faceZones()
);

View File

@ -16,10 +16,10 @@
+ name(pairI)
);
// An empty zone for cut points
pz[pairI] = new pointZone
(
mergeName + "CutPointZone",
labelList(0),
0,
mesh.pointZones()
);
@ -40,7 +40,7 @@
(
mergeName + "MasterZone",
isf,
boolList(masterPatch.size(), false),
false, // none are flipped
0,
mesh.faceZones()
);
@ -61,17 +61,15 @@
(
mergeName + "SlaveZone",
osf,
boolList(slavePatch.size(), false),
false, // none are flipped
1,
mesh.faceZones()
);
// Add empty zone for cut faces
// An empty zone for cut faces
fz[3*pairI + 2] = new faceZone
(
mergeName + "CutFaceZone",
labelList(0),
boolList(0, false),
2,
mesh.faceZones()
);

View File

@ -1026,7 +1026,7 @@ int main(int argc, char *argv[])
(
cutZoneName,
frontPatchFaces,
boolList(frontPatchFaces.size(), false),
false, // none are flipped
0,
mesh.faceZones()
)

View File

@ -503,22 +503,19 @@ void Foam::mergePolyMesh::merge()
if (pointZoneNames_.size() > pointZones().size())
{
Info<< "Adding new pointZones." << endl;
label nZones = pointZones().size();
pointZones().setSize(pointZoneNames_.size());
label zonei = pointZones().size(); // continue from here
for (label zoneI = nZones; zoneI < pointZoneNames_.size(); zoneI++)
const label nZones = pointZoneNames_.size();
pointZones().setSize(nZones);
for (/*nil*/; zonei < nZones; ++zonei)
{
pointZones().set
(
zoneI,
new pointZone
(
pointZoneNames_[zoneI],
labelList(),
zoneI,
pointZones()
)
zonei,
new pointZone(pointZoneNames_[zonei], zonei, pointZones())
);
}
}
@ -526,22 +523,18 @@ void Foam::mergePolyMesh::merge()
{
Info<< "Adding new cellZones." << endl;
label nZones = cellZones().size();
label zonei = cellZones().size(); // continue from here
const label nZones = cellZoneNames_.size();
cellZones().setSize(cellZoneNames_.size());
for (label zoneI = nZones; zoneI < cellZoneNames_.size(); zoneI++)
for (/*nil*/; zonei < nZones; ++zonei)
{
cellZones().set
(
zoneI,
new cellZone
(
cellZoneNames_[zoneI],
labelList(),
zoneI,
cellZones()
)
zonei,
new cellZone(cellZoneNames_[zonei], zonei, cellZones())
);
}
}
@ -549,23 +542,18 @@ void Foam::mergePolyMesh::merge()
{
Info<< "Adding new faceZones." << endl;
label nZones = faceZones().size();
label zonei = faceZones().size(); // continue from here
faceZones().setSize(faceZoneNames_.size());
const label nZones = faceZoneNames_.size();
for (label zoneI = nZones; zoneI < faceZoneNames_.size(); zoneI++)
faceZones().setSize(nZones);
for (/*nil*/; zonei < nZones; ++zonei)
{
faceZones().set
(
zoneI,
new faceZone
(
faceZoneNames_[zoneI],
labelList(),
boolList(),
zoneI,
faceZones()
)
zonei,
new faceZone(faceZoneNames_[zonei], zonei, faceZones())
);
}
}

View File

@ -113,36 +113,28 @@ int main(int argc, char *argv[])
pointSet set(*iter());
SortableList<label> pointLabels(set.toc());
label zoneID = mesh.pointZones().findZoneID(set.name());
if (zoneID == -1)
// The original number of zones
const label nOrigZones = mesh.pointZones().size();
// Get existing or create new empty zone
pointZone& zn = mesh.pointZones()(set.name());
if (nOrigZones == mesh.pointZones().size())
{
Info<< "Adding set " << set.name() << " as a pointZone." << endl;
label sz = mesh.pointZones().size();
mesh.pointZones().setSize(sz+1);
mesh.pointZones().set
(
sz,
new pointZone
(
set.name(), //name
pointLabels, //addressing
sz, //index
mesh.pointZones() //pointZoneMesh
)
);
mesh.pointZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.pointZones().instance() = mesh.facesInstance();
Info<< "Overwriting contents of existing pointZone "
<< zn.index()
<< " with that of set " << set.name() << "." << endl;
}
else
{
Info<< "Overwriting contents of existing pointZone " << zoneID
<< " with that of set " << set.name() << "." << endl;
mesh.pointZones()[zoneID] = pointLabels;
Info<< "Adding set " << set.name() << " as a pointZone." << endl;
}
zn = pointLabels;
mesh.pointZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.pointZones().instance() = mesh.facesInstance();
}
}
IOobjectList faceObjects(objects.lookupClass(faceSet::typeName));
@ -244,40 +236,32 @@ int main(int argc, char *argv[])
}
}
label zoneID = mesh.faceZones().findZoneID(set.name());
if (zoneID == -1)
// The original number of zones
const label nOrigZones = mesh.faceZones().size();
// Get existing or create new empty zone
faceZone& zn = mesh.faceZones()(set.name());
if (nOrigZones == mesh.faceZones().size())
{
Info<< "Adding set " << set.name() << " as a faceZone." << endl;
label sz = mesh.faceZones().size();
mesh.faceZones().setSize(sz+1);
mesh.faceZones().set
(
sz,
new faceZone
(
set.name(), //name
addressing.shrink(), //addressing
flipMap.shrink(), //flipmap
sz, //index
mesh.faceZones() //pointZoneMesh
)
);
mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.faceZones().instance() = mesh.facesInstance();
Info<< "Overwriting contents of existing faceZone "
<< zn.index()
<< " with that of set " << set.name() << "." << endl;
}
else
{
Info<< "Overwriting contents of existing faceZone " << zoneID
<< " with that of set " << set.name() << "." << endl;
mesh.faceZones()[zoneID].resetAddressing
Info<< "Adding set " << set.name() << " as a faceZone." << endl;
}
zn.resetAddressing
(
addressing.shrink(),
flipMap.shrink()
);
mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.faceZones().instance() = mesh.facesInstance();
}
}
@ -293,37 +277,28 @@ int main(int argc, char *argv[])
cellSet set(*iter());
SortableList<label> cellLabels(set.toc());
label zoneID = mesh.cellZones().findZoneID(set.name());
if (zoneID == -1)
// The original number of zones
const label nOrigZones = mesh.cellZones().size();
cellZone& zn = mesh.cellZones()(set.name());
if (nOrigZones == mesh.cellZones().size())
{
Info<< "Adding set " << set.name() << " as a cellZone." << endl;
label sz = mesh.cellZones().size();
mesh.cellZones().setSize(sz+1);
mesh.cellZones().set
(
sz,
new cellZone
(
set.name(), //name
cellLabels, //addressing
sz, //index
mesh.cellZones() //pointZoneMesh
)
);
mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.cellZones().instance() = mesh.facesInstance();
Info<< "Overwriting contents of existing cellZone "
<< zn.index()
<< " with that of set " << set.name() << "." << endl;
}
else
{
Info<< "Overwriting contents of existing cellZone " << zoneID
<< " with that of set " << set.name() << "." << endl;
mesh.cellZones()[zoneID] = cellLabels;
Info<< "Adding set " << set.name() << " as a cellZone." << endl;
}
zn = cellLabels;
mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.cellZones().instance() = mesh.facesInstance();
}
}
}
Info<< "Writing mesh." << endl;

View File

@ -72,109 +72,8 @@ Description
#include "IOobjectList.H"
#include "ReadFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
label addPointZone(polyMesh& mesh, const word& name)
{
pointZoneMesh& zones = mesh.pointZones();
label zoneID = zones.findZoneID(name);
if (zoneID != -1)
{
Info<< "Reusing existing pointZone " << zones[zoneID].name()
<< " at index " << zoneID << endl;
return zoneID;
}
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;
}
label addFaceZone(polyMesh& mesh, const word& name)
{
faceZoneMesh& zones = mesh.faceZones();
label zoneID = zones.findZoneID(name);
if (zoneID != -1)
{
Info<< "Reusing existing faceZone " << zones[zoneID].name()
<< " at index " << zoneID << endl;
return zoneID;
}
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;
}
label addCellZone(polyMesh& mesh, const word& name)
{
cellZoneMesh& zones = mesh.cellZones();
label zoneID = zones.findZoneID(name);
if (zoneID != -1)
{
Info<< "Reusing existing cellZone " << zones[zoneID].name()
<< " at index " << zoneID << endl;
return zoneID;
}
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;
}
// Checks whether patch present
void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
{
@ -198,7 +97,6 @@ void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
}
int main(int argc, char *argv[])
{
argList::addNote
@ -341,10 +239,12 @@ int main(int argc, char *argv[])
if (perfectCover)
{
// Add empty zone for resulting internal faces
const label cutZoneID = addFaceZone(mesh, cutZoneName);
mesh.faceZones()[cutZoneID].resetAddressing(isf.xfer(), false);
// Starts as master zone, but receives the resulting internal faces
mesh.faceZones()
(
cutZoneName,
true // verbose
).resetAddressing(isf.xfer(), false);
// Add the perfect interface mesh modifier
stitcher.set
@ -363,12 +263,19 @@ int main(int argc, char *argv[])
}
else
{
label pointZoneID = addPointZone(mesh, mergePatchName + "CutPointZone");
mesh.pointZones()[pointZoneID] = labelList(0);
// An empty point zone
mesh.pointZones()
(
mergePatchName + "CutPointZone",
true // verbose
) = labelList();
label masterZoneID = addFaceZone(mesh, mergePatchName + "MasterZone");
mesh.faceZones()[masterZoneID].resetAddressing(isf.xfer(), false);
// The master zone
mesh.faceZones()
(
mergePatchName + "MasterZone",
true // verbose
).resetAddressing(isf.xfer(), false);
// Slave patch
const polyPatch& slavePatch = mesh.boundaryMesh()[slavePatchName];
@ -380,12 +287,18 @@ int main(int argc, char *argv[])
osf[i] = slavePatch.start() + i;
}
label slaveZoneID = addFaceZone(mesh, mergePatchName + "SlaveZone");
mesh.faceZones()[slaveZoneID].resetAddressing(osf.xfer(), false);
mesh.faceZones()
(
mergePatchName + "SlaveZone",
true // verbose
).resetAddressing(osf.xfer(), false);
// Add empty zone for cut faces
const label cutZoneID = addFaceZone(mesh, cutZoneName);
mesh.faceZones()[cutZoneID].resetAddressing(labelList(0), false);
// An empty zone for cut faces
mesh.faceZones()
(
cutZoneName,
true // verbose
).resetAddressing(labelList(), false);
// Add the sliding interface mesh modifier

View File

@ -218,7 +218,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
new pointZone
(
"dummyPointZone",
labelList(0),
0,
dummyMesh.pointZones()
)
@ -229,8 +228,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
new faceZone
(
"dummyFaceZone",
labelList(0),
boolList(0),
0,
dummyMesh.faceZones()
)
@ -241,7 +238,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
new cellZone
(
"dummyCellZone",
labelList(0),
0,
dummyMesh.cellZones()
)
@ -347,7 +343,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
pz[i] = new pointZone
(
pointZoneNames[i],
labelList(0),
i,
mesh.pointZones()
);
@ -358,8 +353,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
fz[i] = new faceZone
(
faceZoneNames[i],
labelList(0),
boolList(0),
i,
mesh.faceZones()
);
@ -370,7 +363,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
cz[i] = new cellZone
(
cellZoneNames[i],
labelList(0),
i,
mesh.cellZones()
);

View File

@ -61,9 +61,9 @@ void Foam::ZoneMesh<ZoneType, MeshType>::calcZoneMap() const
{
const labelList& zoneObjects = this->operator[](zonei);
forAll(zoneObjects, objI)
for (const label idx : zoneObjects)
{
zm.insert(zoneObjects[objI], zonei);
zm.insert(idx, zonei);
}
}
}
@ -113,12 +113,10 @@ bool Foam::ZoneMesh<ZoneType, MeshType>::read()
return true;
}
else
{
// Nothing read
return false;
}
}
// Templated implementation for names()
@ -209,6 +207,7 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
// Nothing read. Use supplied zones
PtrList<ZoneType>& zones = *this;
zones.setSize(pzm.size());
forAll(zones, zonei)
{
zones.set(zonei, pzm[zonei].clone(*this).ptr());
@ -630,6 +629,45 @@ ZoneType& Foam::ZoneMesh<ZoneType, MeshType>::operator[]
}
template<class ZoneType, class MeshType>
ZoneType& Foam::ZoneMesh<ZoneType, MeshType>::operator()
(
const word& zoneName,
const bool verbose
)
{
PtrList<ZoneType>& zones = *this;
label zoneId = findZoneID(zoneName);
if (zoneId < 0)
{
zoneId = zones.size();
zones.setSize(zoneId+1);
zones.set(zoneId, new ZoneType(zoneName, zoneId, *this));
if (verbose)
{
Info<< ZoneType::typeName << " " << zoneName
<< " (new at index " << zoneId << ")"
<< endl;
}
}
else
{
if (verbose)
{
Info<< ZoneType::typeName << " " << zoneName
<< " (existing at index " << zoneId << ")"
<< endl;
}
}
return zones[zoneId];
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class ZoneType, class MeshType>
@ -639,14 +677,23 @@ Foam::Ostream& Foam::operator<<
const ZoneMesh<ZoneType, MeshType>& zones
)
{
os << zones.size() << nl << token::BEGIN_LIST;
const label sz = zones.size();
forAll(zones, zonei)
if (sz)
{
zones[zonei].writeDict(os);
os << sz << nl << token::BEGIN_LIST;
for (label i=0; i<sz; ++i)
{
zones[i].writeDict(os);
}
os << token::END_LIST;
}
else
{
os << sz << token::BEGIN_LIST << token::END_LIST;
}
return os;
}

View File

@ -179,7 +179,7 @@ public:
//- Find zone index given a name, return -1 if not found
label findZoneID(const word& zoneName) const;
//- Mark cells that match the zone specification
//- Mark items (cells, faces, points) that match the zone specification
PackedBoolList findMatching(const keyType& key) const;
//- Clear addressing
@ -203,15 +203,35 @@ public:
// Member Operators
//- Return const and non-const reference to ZoneType by index.
//- Return const and non-const reference to zone by index.
using PtrList<ZoneType>::operator[];
//- Return const reference to ZoneType by name.
//- Return const reference to zone by name.
// Fatal if the zone does not exist.
const ZoneType& operator[](const word& zoneName) const;
//- Return reference to ZoneType by name.
//- Return reference to an existing zone by name
// Fatal if the zone does not exist.
ZoneType& operator[](const word& zoneName);
//- Find an existing zone by name or create a new empty one
//- if required.
//
// To determine if the zone already existed or was newly created,
// it will be necessary to add additional logic in the caller.
// For example,
// \code
// const label nOrig = zones.size();
//
// ZoneType& zn = zones("zoneName");
//
// if (nOrig == zones.size()) { existing... } else { new... }
// \endcode
// \param verbose report if an existing zone was selected or
// a new zone was created.
// \return non-const reference to the existing or new zone
ZoneType& operator()(const word& zoneName, const bool verbose=false);
// Ostream operator

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -45,6 +45,18 @@ const char * const Foam::cellZone::labelsName = "cellLabels";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cellZone::cellZone
(
const word& name,
const label index,
const cellZoneMesh& zm
)
:
zone(name, index),
zoneMesh_(zm)
{}
Foam::cellZone::cellZone
(
const word& name,
@ -58,6 +70,19 @@ Foam::cellZone::cellZone
{}
Foam::cellZone::cellZone
(
const word& name,
labelList&& addr,
const label index,
const cellZoneMesh& zm
)
:
zone(name, std::move(addr), index),
zoneMesh_(zm)
{}
Foam::cellZone::cellZone
(
const word& name,
@ -86,25 +111,39 @@ Foam::cellZone::cellZone
Foam::cellZone::cellZone
(
const cellZone& cz,
const cellZone& origZone,
const labelUList& addr,
const label index,
const cellZoneMesh& zm
)
:
zone(cz, addr, index),
zone(origZone, addr, index),
zoneMesh_(zm)
{}
Foam::cellZone::cellZone
(
const cellZone& cz,
const cellZone& origZone,
labelList&& addr,
const label index,
const cellZoneMesh& zm
)
:
zone(origZone, std::move(addr), index),
zoneMesh_(zm)
{}
Foam::cellZone::cellZone
(
const cellZone& origZone,
const Xfer<labelList>& addr,
const label index,
const cellZoneMesh& zm
)
:
zone(cz, addr, index),
zone(origZone, addr, index),
zoneMesh_(zm)
{}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -109,6 +109,9 @@ public:
// Constructors
//- Construct an empty zone
cellZone(const word& name, const label index, const cellZoneMesh& zm);
//- Construct from components
cellZone
(
@ -118,7 +121,16 @@ public:
const cellZoneMesh& zm
);
//- Construct from components, transferring contents
//- Construct from components, transferring addressing
cellZone
(
const word& name,
labelList&& addr,
const label index,
const cellZoneMesh& zm
);
//- Construct from components, transferring addressing
cellZone
(
const word& name,
@ -136,26 +148,37 @@ public:
const cellZoneMesh& zm
);
//- Construct given the original zone,
// resetting the cell list and zone mesh information
//- Construct given the original zone (name is used),
//- and resetting the cell list and zone mesh information
cellZone
(
const cellZone& cz,
const cellZone& origZone,
const labelUList& addr,
const label index,
const cellZoneMesh& zm
);
//- Construct given the original zone,
// resetting the cell list and zone mesh information
//- Construct with a new index and zone mesh information, the name
//- of the original zone, resetting the cell addressing.
cellZone
(
const cellZone& cz,
const cellZone& origZone,
labelList&& addr,
const label index,
const cellZoneMesh& zm
);
//- Construct with a new index and zone mesh information, the name
//- of the original zone, (move) resetting the cell addressing.
cellZone
(
const cellZone& origZone,
const Xfer<labelList>& addr,
const label index,
const cellZoneMesh& zm
);
//- Construct and return a clone, resetting the zone mesh
virtual autoPtr<cellZone> clone(const cellZoneMesh& zm) const
{
@ -165,8 +188,8 @@ public:
);
}
//- Construct and return a clone, resetting the cell list
// and zone mesh
//- Construct and return a clone,
//- resetting the cell list and zone mesh
virtual autoPtr<cellZone> clone
(
const labelUList& addr,
@ -184,7 +207,7 @@ public:
// Selectors
//- Return a pointer to a new cell zone
// created on freestore from dictionary
//- created on freestore from dictionary
static autoPtr<cellZone> New
(
const word& name,
@ -228,7 +251,7 @@ public:
//- Assign addressing, clearing demand-driven data
void operator=(const labelUList& addr);
//- Assign addressing, clearing demand-driven data
//- Move assign addressing, clearing demand-driven data
void operator=(const Xfer<labelList>& addr);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,20 +43,21 @@ namespace Foam
const char* const Foam::faceZone::labelsName = "faceLabels";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::faceZone::setFlipMap(const bool flipValue)
void Foam::faceZone::setFlipMap(const bool val)
{
// Match size for flipMap
if (flipMap_.size() == this->size())
{
flipMap_ = flipValue;
flipMap_ = val;
}
else
{
// Avoid copying old values on resize
flipMap_.clear();
flipMap_.setSize(this->size(), flipValue);
flipMap_.setSize(this->size(), val);
}
}
@ -200,6 +201,67 @@ void Foam::faceZone::checkAddressing() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faceZone::faceZone
(
const word& name,
const label index,
const faceZoneMesh& zm
)
:
zone(name, index),
flipMap_(),
zoneMesh_(zm),
patchPtr_(nullptr),
masterCellsPtr_(nullptr),
slaveCellsPtr_(nullptr),
mePtr_(nullptr)
{}
Foam::faceZone::faceZone
(
const word& name,
const labelUList& addr,
const bool flipMapValue,
const label index,
const faceZoneMesh& zm
)
:
zone(name, addr, index),
flipMap_(),
zoneMesh_(zm),
patchPtr_(nullptr),
masterCellsPtr_(nullptr),
slaveCellsPtr_(nullptr),
mePtr_(nullptr)
{
flipMap_.setSize(size(), flipMapValue);
checkAddressing();
}
Foam::faceZone::faceZone
(
const word& name,
labelList&& addr,
const bool flipMapValue,
const label index,
const faceZoneMesh& zm
)
:
zone(name, std::move(addr), index),
flipMap_(),
zoneMesh_(zm),
patchPtr_(nullptr),
masterCellsPtr_(nullptr),
slaveCellsPtr_(nullptr),
mePtr_(nullptr)
{
flipMap_.setSize(size(), flipMapValue);
checkAddressing();
}
Foam::faceZone::faceZone
(
const word& name,
@ -264,14 +326,14 @@ Foam::faceZone::faceZone
Foam::faceZone::faceZone
(
const faceZone& fz,
const faceZone& origZone,
const labelUList& addr,
const boolList& fm,
const label index,
const faceZoneMesh& zm
)
:
zone(fz, addr, index),
zone(origZone, addr, index),
flipMap_(fm),
zoneMesh_(zm),
patchPtr_(nullptr),
@ -285,14 +347,14 @@ Foam::faceZone::faceZone
Foam::faceZone::faceZone
(
const faceZone& fz,
const faceZone& origZone,
const Xfer<labelList>& addr,
const Xfer<boolList>& fm,
const label index,
const faceZoneMesh& zm
)
:
zone(fz, addr, index),
zone(origZone, addr, index),
flipMap_(fm),
zoneMesh_(zm),
patchPtr_(nullptr),
@ -391,6 +453,18 @@ void Foam::faceZone::clearAddressing()
}
void Foam::faceZone::resetAddressing
(
const labelUList& addr,
const bool flipMapValue
)
{
clearAddressing();
labelList::operator=(addr);
setFlipMap(flipMapValue);
}
void Foam::faceZone::resetAddressing
(
const labelUList& addr,
@ -403,27 +477,15 @@ 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
const bool flipMapValue
)
{
clearAddressing();
labelList::operator=(addr);
setFlipMap(flipValue);
setFlipMap(flipMapValue);
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -68,8 +68,8 @@ class faceZone
{
// Private Member Functions
//- Set flip-map to constant value
void setFlipMap(const bool flipValue);
//- Set flip-map to uniform value
void setFlipMap(const bool val);
//- Disallow default bitwise copy construct
faceZone(const faceZone&) = delete;
@ -148,6 +148,30 @@ public:
// Constructors
//- Construct an empty zone
faceZone(const word& name, const label index, const faceZoneMesh& zm);
//- Construct from components with uniform flip map value
faceZone
(
const word& name,
const labelUList& addr,
const bool flipMapValue,
const label index,
const faceZoneMesh& zm
);
//- Construct from components with uniform flip map value,
//- transferring addressing.
faceZone
(
const word& name,
labelList&& addr,
const bool flipMapValue,
const label index,
const faceZoneMesh& zm
);
//- Construct from components
faceZone
(
@ -158,7 +182,7 @@ public:
const faceZoneMesh& zm
);
//- Construct from components, transferring contents
//- Construct from components, transferring addressing
faceZone
(
const word& name,
@ -177,22 +201,24 @@ public:
const faceZoneMesh& zm
);
//- Construct given the original zone and resetting the
// face list and zone mesh information
//- Construct with a new index and zone mesh information, the name
//- of the original zone, resetting the face addressing
//- and flip-map.
faceZone
(
const faceZone& fz,
const faceZone& origZone,
const labelUList& addr,
const boolList& fm,
const label index,
const faceZoneMesh& zm
);
//- Construct given the original zone,
// resetting the face list and zone mesh information
//- Construct with a new index and zone mesh information, the name
//- of the original zone, (move) resetting the face addressing
//- and flip-map.
faceZone
(
const faceZone& fz,
const faceZone& origZone,
const Xfer<labelList>& addr,
const Xfer<boolList>& fm,
const label index,
@ -208,8 +234,8 @@ public:
);
}
//- Construct and return a clone, resetting the face list
// and zone mesh
//- Construct and return a clone,
//- resetting the face list and zone mesh
virtual autoPtr<faceZone> clone
(
const labelUList& addr,
@ -228,7 +254,7 @@ public:
// Selectors
//- Return a pointer to a new face zone
// created on freestore from dictionary
//- created on freestore from dictionary
static autoPtr<faceZone> New
(
const word& name,
@ -263,7 +289,7 @@ public:
// Addressing into mesh
//- Return labels of master cells (cells next to the master face
// zone in the prescribed direction)
//- zone in the prescribed direction)
const labelList& masterCells() const;
//- Return labels of slave cells
@ -276,6 +302,14 @@ public:
//- Clear addressing
virtual void clearAddressing();
//- Reset addressing - use uniform flip map value
// Clears demand-driven data.
virtual void resetAddressing
(
const labelUList& addr,
const bool flipMapValue
);
//- Reset addressing and flip map.
// Clears demand-driven data.
virtual void resetAddressing
@ -284,20 +318,12 @@ public:
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
//- Move reset addressing - use uniform flip map value
// Clears demand-driven data.
virtual void resetAddressing
(
const Xfer<labelList>& addr,
const bool flipValue
const bool flipMapValue
);
//- Check zone definition. Return true if in error.

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -45,6 +45,18 @@ const char* const Foam::pointZone::labelsName = "pointLabels";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pointZone::pointZone
(
const word& name,
const label index,
const pointZoneMesh& zm
)
:
zone(name, index),
zoneMesh_(zm)
{}
Foam::pointZone::pointZone
(
const word& name,
@ -58,6 +70,19 @@ Foam::pointZone::pointZone
{}
Foam::pointZone::pointZone
(
const word& name,
labelList&& addr,
const label index,
const pointZoneMesh& zm
)
:
zone(name, std::move(addr), index),
zoneMesh_(zm)
{}
Foam::pointZone::pointZone
(
const word& name,
@ -86,26 +111,39 @@ Foam::pointZone::pointZone
Foam::pointZone::pointZone
(
const pointZone& pz,
const pointZone& origZone,
const labelUList& addr,
const label index,
const pointZoneMesh& zm
)
:
zone(pz, addr, index),
zone(origZone, addr, index),
zoneMesh_(zm)
{}
Foam::pointZone::pointZone
(
const pointZone& pz,
const pointZone& origZone,
labelList&& addr,
const label index,
const pointZoneMesh& zm
)
:
zone(origZone, std::move(addr), index),
zoneMesh_(zm)
{}
Foam::pointZone::pointZone
(
const pointZone& origZone,
const Xfer<labelList>& addr,
const label index,
const pointZoneMesh& zm
)
:
zone(pz, addr, index),
zone(origZone, addr, index),
zoneMesh_(zm)
{}
@ -142,9 +180,11 @@ bool Foam::pointZone::checkParallelSync(const bool report) const
labelList maxZone(mesh.nPoints(), -1);
labelList minZone(mesh.nPoints(), labelMax);
forAll(*this, i)
const labelList& addr = *this;
for (const label pointi : addr)
{
label pointi = operator[](i);
maxZone[pointi] = index();
minZone[pointi] = index();
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,6 +26,7 @@ Class
Description
A subset of mesh points.
The labels of points in the zone can be obtained from the addressing()
list.
@ -109,6 +110,9 @@ public:
// Constructors
//- Construct an empty zone
pointZone(const word& name, const label index, const pointZoneMesh& zm);
//- Construct from components
pointZone
(
@ -118,6 +122,15 @@ public:
const pointZoneMesh& zm
);
//- Construct from components, transferring addressing
pointZone
(
const word& name,
labelList&& addr,
const label index,
const pointZoneMesh& zm
);
//- Construct from components, transferring contents
pointZone
(
@ -136,26 +149,37 @@ public:
const pointZoneMesh& zm
);
//- Construct given the original zone and resetting the
// point list and zone mesh information
//- Construct with a new index and zone mesh information, the name
//- of the original zone, resetting the point addressing.
pointZone
(
const pointZone& pz,
const pointZone& origZone,
const labelUList& addr,
const label index,
const pointZoneMesh& zm
);
//- Construct given the original zone,
// resetting the point list and zone mesh information
//- Construct with a new index and zone mesh information, the name
//- of the original zone, (move) resetting the point addressing.
pointZone
(
const pointZone& pz,
const pointZone& origZone,
labelList&& addr,
const label index,
const pointZoneMesh& zm
);
//- Construct with a new index and zone mesh information from
//- an original zone, (move) resetting the point list.
pointZone
(
const pointZone& origZone,
const Xfer<labelList>& addr,
const label index,
const pointZoneMesh& zm
);
//- Construct and return a clone, resetting the zone mesh
virtual autoPtr<pointZone> clone(const pointZoneMesh& zm) const
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -82,6 +82,15 @@ void Foam::zone::calcLookupMap() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::zone::zone(const word& name, const label index)
:
labelList(),
name_(name),
index_(index),
lookupMapPtr_(nullptr)
{}
Foam::zone::zone
(
const word& name,
@ -96,6 +105,20 @@ Foam::zone::zone
{}
Foam::zone::zone
(
const word& name,
labelList&& addr,
const label index
)
:
labelList(std::move(addr)),
name_(name),
index_(index),
lookupMapPtr_(nullptr)
{}
Foam::zone::zone
(
const word& name,
@ -127,13 +150,13 @@ Foam::zone::zone
Foam::zone::zone
(
const zone& zn,
const zone& origZone,
const labelUList& addr,
const label index
)
:
labelList(addr),
name_(zn.name()),
name_(origZone.name()),
index_(index),
lookupMapPtr_(nullptr)
{}
@ -141,13 +164,27 @@ Foam::zone::zone
Foam::zone::zone
(
const zone& zn,
const zone& origZone,
labelList&& addr,
const label index
)
:
labelList(std::move(addr)),
name_(origZone.name()),
index_(index),
lookupMapPtr_(nullptr)
{}
Foam::zone::zone
(
const zone& origZone,
const Xfer<labelList>& addr,
const label index
)
:
labelList(addr),
name_(zn.name()),
name_(origZone.name()),
index_(index),
lookupMapPtr_(nullptr)
{}
@ -184,9 +221,8 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
// To check for duplicate entries
labelHashSet elems(size());
forAll(addr, i)
for (const label idx : addr)
{
const label idx = addr[i];
if (idx < 0 || idx >= maxSize)
{
hasError = true;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,7 +25,10 @@ Class
Foam::zone
Description
Base class for zones
Base class for mesh zones.
A zone is a list of labels (eg, cells, faces, points) with
a name and associated with an index within another list.
SourceFiles
zone.C
@ -96,7 +99,10 @@ public:
// Constructors
//- Construct from components
//- Construct an empty zone
zone(const word& name, const label index);
//- Copy construct from components
zone
(
const word& name,
@ -104,7 +110,15 @@ public:
const label index
);
//- Construct from components, transferring contents
//- Move construct from components
zone
(
const word& name,
labelList&& addr,
const label index
);
//- Move construct from components
zone
(
const word& name,
@ -121,17 +135,26 @@ public:
const label index
);
//- Construct given the original zone and resetting the
// cell list and zone mesh information
//- Construct given the name of the original zone (name is used)
//- and resetting addressing and index.
zone
(
const zone& zn,
const zone& origZone,
const labelUList& addr,
const label index
);
//- Construct given the original zone, resetting the
// cell list and zone mesh information
//- Construct given the name of the original zone (name is used)
//- and (move) resetting addressing and index.
zone
(
const zone& origZone,
labelList&& addr,
const label index
);
//- Construct given the name of the original zone (name is used)
//- and (move) resetting addressing and index.
zone
(
const zone& zn,

View File

@ -2546,7 +2546,7 @@ void Foam::ccm::reader::addFaceZones
(
iter.key(),
iter(),
boolList(iter().size(), false),
false, // none are flipped
nZone,
mesh.faceZones()
)

View File

@ -63,7 +63,7 @@ void Foam::meshReader::addFaceZones(polyMesh& mesh) const
(
iter.key(),
iter(),
boolList(iter().size(), false),
false, // none are flipped
nZone,
mesh.faceZones()
)

View File

@ -56,11 +56,9 @@ bool Foam::fvMeshSubset::checkCellSubset() const
return false;
}
else
{
return true;
}
}
void Foam::fvMeshSubset::markPoints
@ -69,10 +67,10 @@ void Foam::fvMeshSubset::markPoints
Map<label>& pointMap
)
{
forAll(curPoints, pointi)
for (const label pointi : curPoints)
{
// Note: insert will only insert if not yet there.
pointMap.insert(curPoints[pointi], 0);
pointMap.insert(pointi, 0);
}
}
@ -83,9 +81,9 @@ void Foam::fvMeshSubset::markPoints
labelList& pointMap
)
{
forAll(curPoints, pointi)
for (const label pointi : curPoints)
{
pointMap[curPoints[pointi]] = 0;
pointMap[pointi] = 0;
}
}

View File

@ -642,7 +642,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
pz[i] = new pointZone
(
pointZoneNames[i],
labelList(0),
i,
mesh.pointZones()
);
@ -653,8 +652,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
fz[i] = new faceZone
(
faceZoneNames[i],
labelList(0),
boolList(0),
i,
mesh.faceZones()
);
@ -665,7 +662,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
cz[i] = new cellZone
(
cellZoneNames[i],
labelList(0),
i,
mesh.cellZones()
);

View File

@ -3422,7 +3422,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh
pZonePtrs[i] = new pointZone
(
oldPointZones[i].name(),
labelList(0),
i,
newMesh.pointZones()
);
@ -3437,8 +3436,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh
fZonePtrs[i] = new faceZone
(
oldFaceZones[i].name(),
labelList(0),
boolList(0),
i,
newMesh.faceZones()
);
@ -3453,7 +3450,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh
cZonePtrs[i] = new cellZone
(
oldCellZones[i].name(),
labelList(0),
i,
newMesh.cellZones()
);

View File

@ -67,15 +67,8 @@ void Foam::linearValveFvMesh::addZonesAndModifiers()
// Add zones
List<pointZone*> pz(1);
// Add an empty zone for cut points
pz[0] = new pointZone
(
"cutPointZone",
labelList(0),
0,
pointZones()
);
// An empty zone for cut points
pz[0] = new pointZone("cutPointZone", 0, pointZones());
// Do face zones for slider
@ -97,7 +90,7 @@ void Foam::linearValveFvMesh::addZonesAndModifiers()
(
"insideSliderZone",
isf,
boolList(innerSlider.size(), false),
false, // none are flipped
0,
faceZones()
);
@ -117,20 +110,13 @@ void Foam::linearValveFvMesh::addZonesAndModifiers()
(
"outsideSliderZone",
osf,
boolList(outerSlider.size(), false),
false, // none are flipped
1,
faceZones()
);
// Add empty zone for cut faces
fz[2] = new faceZone
(
"cutFaceZone",
labelList(0),
boolList(0, false),
2,
faceZones()
);
// An empty zone for cut faces
fz[2] = new faceZone("cutFaceZone", 2, faceZones());
List<cellZone*> cz(0);

View File

@ -76,15 +76,8 @@ void Foam::linearValveLayersFvMesh::addZonesAndModifiers()
List<cellZone*> cz(0);
// Add an empty zone for cut points
pz[0] = new pointZone
(
"cutPointZone",
labelList(0),
0,
pointZones()
);
// An empty zone for cut points
pz[0] = new pointZone("cutPointZone", 0, pointZones());
// Do face zones for slider
@ -104,7 +97,7 @@ void Foam::linearValveLayersFvMesh::addZonesAndModifiers()
(
"insideSliderZone",
isf,
boolList(innerSlider.size(), false),
false, // none are flipped
0,
faceZones()
);
@ -124,20 +117,13 @@ void Foam::linearValveLayersFvMesh::addZonesAndModifiers()
(
"outsideSliderZone",
osf,
boolList(outerSlider.size(), false),
false, // none are flipped
1,
faceZones()
);
// Add empty zone for cut faces
fz[2] = new faceZone
(
"cutFaceZone",
labelList(0),
boolList(0, false),
2,
faceZones()
);
// An empty zone for cut faces
fz[2] = new faceZone("cutFaceZone", 2, faceZones());
// Add face zone for layer addition
const word layerPatchName
@ -158,7 +144,7 @@ void Foam::linearValveLayersFvMesh::addZonesAndModifiers()
(
"valveLayerZone",
lpf,
boolList(layerPatch.size(), true),
true, // all are flipped
0,
faceZones()
);

View File

@ -67,15 +67,8 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
// Add zones
List<pointZone*> pz(1);
// Add an empty zone for cut points
pz[0] = new pointZone
(
"cutPointZone",
labelList(0),
0,
pointZones()
);
// An empty zone for cut points
pz[0] = new pointZone("cutPointZone", 0, pointZones());
// Do face zones for slider
@ -97,7 +90,7 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
(
"insideSliderZone",
isf,
boolList(innerSlider.size(), false),
false, // none are flipped
0,
faceZones()
);
@ -117,20 +110,13 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
(
"outsideSliderZone",
osf,
boolList(outerSlider.size(), false),
false, // none are flipped
1,
faceZones()
);
// Add empty zone for cut faces
fz[2] = new faceZone
(
"cutFaceZone",
labelList(0),
boolList(0, false),
2,
faceZones()
);
// An empty zone for cut faces
fz[2] = new faceZone("cutFaceZone", 2, faceZones());
List<cellZone*> cz(1);