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], patchNames[patchi],
bFaceLabels, bFaceLabels,
boolList(bFaceLabels.size(), false), false, // none are flipped
fz.size(), fz.size(),
pShapeMesh.faceZones() pShapeMesh.faceZones()
) )

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -502,70 +502,58 @@ void Foam::mergePolyMesh::merge()
// Add the zones if necessary // Add the zones if necessary
if (pointZoneNames_.size() > pointZones().size()) if (pointZoneNames_.size() > pointZones().size())
{ {
Info<< "Adding new pointZones. " << endl; 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 pointZones().set
( (
zoneI, zonei,
new pointZone new pointZone(pointZoneNames_[zonei], zonei, pointZones())
(
pointZoneNames_[zoneI],
labelList(),
zoneI,
pointZones()
)
); );
} }
} }
if (cellZoneNames_.size() > cellZones().size()) if (cellZoneNames_.size() > cellZones().size())
{ {
Info<< "Adding new cellZones. " << endl; 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()); cellZones().setSize(cellZoneNames_.size());
for (label zoneI = nZones; zoneI < cellZoneNames_.size(); zoneI++) for (/*nil*/; zonei < nZones; ++zonei)
{ {
cellZones().set cellZones().set
( (
zoneI, zonei,
new cellZone new cellZone(cellZoneNames_[zonei], zonei, cellZones())
(
cellZoneNames_[zoneI],
labelList(),
zoneI,
cellZones()
)
); );
} }
} }
if (faceZoneNames_.size() > faceZones().size()) if (faceZoneNames_.size() > faceZones().size())
{ {
Info<< "Adding new faceZones. " << endl; 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 faceZones().set
( (
zoneI, zonei,
new faceZone new faceZone(faceZoneNames_[zonei], zonei, faceZones())
(
faceZoneNames_[zoneI],
labelList(),
boolList(),
zoneI,
faceZones()
)
); );
} }
} }

View File

@ -113,36 +113,28 @@ int main(int argc, char *argv[])
pointSet set(*iter()); pointSet set(*iter());
SortableList<label> pointLabels(set.toc()); SortableList<label> pointLabels(set.toc());
label zoneID = mesh.pointZones().findZoneID(set.name()); // The original number of zones
if (zoneID == -1) 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; Info<< "Overwriting contents of existing pointZone "
label sz = mesh.pointZones().size(); << zn.index()
mesh.pointZones().setSize(sz+1); << " with that of set " << set.name() << "." << endl;
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();
} }
else else
{ {
Info<< "Overwriting contents of existing pointZone " << zoneID Info<< "Adding set " << set.name() << " as a pointZone." << endl;
<< " with that of set " << set.name() << "." << endl;
mesh.pointZones()[zoneID] = pointLabels;
mesh.pointZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.pointZones().instance() = mesh.facesInstance();
} }
}
zn = pointLabels;
mesh.pointZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.pointZones().instance() = mesh.facesInstance();
}
IOobjectList faceObjects(objects.lookupClass(faceSet::typeName)); IOobjectList faceObjects(objects.lookupClass(faceSet::typeName));
@ -244,39 +236,31 @@ int main(int argc, char *argv[])
} }
} }
label zoneID = mesh.faceZones().findZoneID(set.name()); // The original number of zones
if (zoneID == -1) 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; Info<< "Overwriting contents of existing faceZone "
label sz = mesh.faceZones().size(); << zn.index()
mesh.faceZones().setSize(sz+1); << " with that of set " << set.name() << "." << endl;
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();
} }
else else
{ {
Info<< "Overwriting contents of existing faceZone " << zoneID Info<< "Adding set " << set.name() << " as a faceZone." << endl;
<< " with that of set " << set.name() << "." << endl;
mesh.faceZones()[zoneID].resetAddressing
(
addressing.shrink(),
flipMap.shrink()
);
mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.faceZones().instance() = mesh.facesInstance();
} }
zn.resetAddressing
(
addressing.shrink(),
flipMap.shrink()
);
mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.faceZones().instance() = mesh.facesInstance();
} }
@ -293,39 +277,30 @@ int main(int argc, char *argv[])
cellSet set(*iter()); cellSet set(*iter());
SortableList<label> cellLabels(set.toc()); SortableList<label> cellLabels(set.toc());
label zoneID = mesh.cellZones().findZoneID(set.name()); // The original number of zones
if (zoneID == -1) 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; Info<< "Overwriting contents of existing cellZone "
label sz = mesh.cellZones().size(); << zn.index()
mesh.cellZones().setSize(sz+1); << " with that of set " << set.name() << "." << endl;
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();
} }
else else
{ {
Info<< "Overwriting contents of existing cellZone " << zoneID Info<< "Adding set " << set.name() << " as a cellZone." << endl;
<< " with that of set " << set.name() << "." << endl;
mesh.cellZones()[zoneID] = cellLabels;
mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.cellZones().instance() = mesh.facesInstance();
} }
zn = cellLabels;
mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE;
mesh.cellZones().instance() = mesh.facesInstance();
} }
} }
Info<< "Writing mesh." << endl; Info<< "Writing mesh." << endl;
if (!mesh.write()) if (!mesh.write())

View File

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

View File

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

View File

@ -61,9 +61,9 @@ void Foam::ZoneMesh<ZoneType, MeshType>::calcZoneMap() const
{ {
const labelList& zoneObjects = this->operator[](zonei); const labelList& zoneObjects = this->operator[](zonei);
forAll(zoneObjects, objI) for (const label idx : zoneObjects)
{ {
zm.insert(zoneObjects[objI], zonei); zm.insert(idx, zonei);
} }
} }
} }
@ -113,11 +113,9 @@ bool Foam::ZoneMesh<ZoneType, MeshType>::read()
return true; return true;
} }
else
{ // Nothing read
// Nothing read return false;
return false;
}
} }
@ -209,6 +207,7 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh
// Nothing read. Use supplied zones // Nothing read. Use supplied zones
PtrList<ZoneType>& zones = *this; PtrList<ZoneType>& zones = *this;
zones.setSize(pzm.size()); zones.setSize(pzm.size());
forAll(zones, zonei) forAll(zones, zonei)
{ {
zones.set(zonei, pzm[zonei].clone(*this).ptr()); 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 * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class ZoneType, class MeshType> template<class ZoneType, class MeshType>
@ -639,14 +677,23 @@ Foam::Ostream& Foam::operator<<
const ZoneMesh<ZoneType, MeshType>& zones 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;
}
os << token::END_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; return os;
} }

View File

@ -145,7 +145,7 @@ public:
const Map<label>& zoneMap() const; const Map<label>& zoneMap() const;
//- Given a global object index, return the zone it is in. //- Given a global object index, return the zone it is in.
// If object does not belong to any zones, return -1 // If object does not belong to any zones, return -1
label whichZone(const label objectIndex) const; label whichZone(const label objectIndex) const;
//- Return a list of zone types //- Return a list of zone types
@ -179,7 +179,7 @@ public:
//- Find zone index given a name, return -1 if not found //- 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 items (cells, faces, points) that match the zone specification
PackedBoolList findMatching(const keyType& key) const; PackedBoolList findMatching(const keyType& key) const;
//- Clear addressing //- Clear addressing
@ -203,15 +203,35 @@ public:
// Member Operators // 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[]; 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; 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); 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 // Ostream operator

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -25,7 +25,10 @@ Class
Foam::zone Foam::zone
Description 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 SourceFiles
zone.C zone.C
@ -96,7 +99,10 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct an empty zone
zone(const word& name, const label index);
//- Copy construct from components
zone zone
( (
const word& name, const word& name,
@ -104,7 +110,15 @@ public:
const label index 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 zone
( (
const word& name, const word& name,
@ -121,17 +135,26 @@ public:
const label index const label index
); );
//- Construct given the original zone and resetting the //- Construct given the name of the original zone (name is used)
// cell list and zone mesh information //- and resetting addressing and index.
zone zone
( (
const zone& zn, const zone& origZone,
const labelUList& addr, const labelUList& addr,
const label index const label index
); );
//- Construct given the original zone, resetting the //- Construct given the name of the original zone (name is used)
// cell list and zone mesh information //- 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 zone
( (
const zone& zn, const zone& zn,

View File

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

View File

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

View File

@ -56,10 +56,8 @@ bool Foam::fvMeshSubset::checkCellSubset() const
return false; return false;
} }
else
{ return true;
return true;
}
} }
@ -69,10 +67,10 @@ void Foam::fvMeshSubset::markPoints
Map<label>& pointMap Map<label>& pointMap
) )
{ {
forAll(curPoints, pointi) for (const label pointi : curPoints)
{ {
// Note: insert will only insert if not yet there. // 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 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 pz[i] = new pointZone
( (
pointZoneNames[i], pointZoneNames[i],
labelList(0),
i, i,
mesh.pointZones() mesh.pointZones()
); );
@ -653,8 +652,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
fz[i] = new faceZone fz[i] = new faceZone
( (
faceZoneNames[i], faceZoneNames[i],
labelList(0),
boolList(0),
i, i,
mesh.faceZones() mesh.faceZones()
); );
@ -665,7 +662,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
cz[i] = new cellZone cz[i] = new cellZone
( (
cellZoneNames[i], cellZoneNames[i],
labelList(0),
i, i,
mesh.cellZones() mesh.cellZones()
); );

View File

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

View File

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

View File

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

View File

@ -67,15 +67,8 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
// Add zones // Add zones
List<pointZone*> pz(1); List<pointZone*> pz(1);
// Add an empty zone for cut points // An empty zone for cut points
pz[0] = new pointZone("cutPointZone", 0, pointZones());
pz[0] = new pointZone
(
"cutPointZone",
labelList(0),
0,
pointZones()
);
// Do face zones for slider // Do face zones for slider
@ -97,7 +90,7 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
( (
"insideSliderZone", "insideSliderZone",
isf, isf,
boolList(innerSlider.size(), false), false, // none are flipped
0, 0,
faceZones() faceZones()
); );
@ -117,20 +110,13 @@ void Foam::mixerFvMesh::addZonesAndModifiers()
( (
"outsideSliderZone", "outsideSliderZone",
osf, osf,
boolList(outerSlider.size(), false), false, // none are flipped
1, 1,
faceZones() faceZones()
); );
// Add empty zone for cut faces // An empty zone for cut faces
fz[2] = new faceZone fz[2] = new faceZone("cutFaceZone", 2, faceZones());
(
"cutFaceZone",
labelList(0),
boolList(0, false),
2,
faceZones()
);
List<cellZone*> cz(1); List<cellZone*> cz(1);
@ -338,7 +324,7 @@ const Foam::scalarField& Foam::mixerFvMesh::movingPointsMask() const
bool Foam::mixerFvMesh::update() bool Foam::mixerFvMesh::update()
{ {
// Rotational speed needs to be converted from rpm // Rotational speed needs to be converted from rpm
movePoints movePoints
( (
csPtr_->globalPosition csPtr_->globalPosition