polyTopoChange: Removed restrictive cellZone functionality

Now cellZones are handled directly by the applications and the new
cellZone::topoChange function so that any cell can now be in any number of
zones, significantly increasing the flexibility and usefulness of cellZones.

The same rationalisation and generalisation will be applied to faceZones in the
future.
This commit is contained in:
Henry Weller
2024-03-15 10:24:46 +00:00
parent 81c2c42ca4
commit b41e0857ef
22 changed files with 188 additions and 359 deletions

View File

@ -1252,8 +1252,7 @@ int main(int argc, char *argv[])
{
meshMod.addCell
(
celli, // masterCellID
-1 // zoneID
celli // masterCellID
);
}

View File

@ -252,6 +252,8 @@ int main(int argc, char *argv[])
// Create a mesh from topo changes.
autoPtr<polyTopoChangeMap> map = meshMod().changeMesh(mesh());
extruder.updateZones();
mesh().topoChange(map);
{

View File

@ -52,31 +52,6 @@ void Foam::extrude2DMesh::check2D() const
}
//void Foam::extrude2DMesh::findExtrudeDirection()
//{
// scalar minRange = great;
// for (direction dir = 0; dir < 3; dir++)
// {
// scalarField cmpts(mesh_.points().component(dir));
// scalar range = max(cmpts)-min(cmpts);
// Info<< "Direction:" << dir << " range:" << range << endl;
// if (range < minRange)
// {
// minRange = range;
// extrudeDir_ = dir;
// }
// }
// Info<< "Extruding in direction " << extrudeDir_
// << " with thickness " << thickness_ << nl
// << endl;
//}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::extrude2DMesh::extrude2DMesh
@ -88,12 +63,12 @@ Foam::extrude2DMesh::extrude2DMesh
:
mesh_(mesh),
dict_(dict),
// patchDict_(dict.subDict("patchInfo")),
model_(model),
modelType_(dict.lookup("extrudeModel")),
patchType_(dict.lookup("patchType")),
frontPatchi_(-1),
backPatchi_(-1)
backPatchi_(-1),
cellZonesAddedCells_(mesh.cellZones().size())
{
check2D();
}
@ -146,14 +121,6 @@ void Foam::extrude2DMesh::addFrontBackPatches()
patches
).ptr();
// newPatches[frontPatchi_] = polyPatch::New
// (
// "front",
// patchDict_,
// frontPatchi_,
// patches
// ).ptr();
Info<< "Adding patch " << newPatches[frontPatchi_]->name()
<< " at index " << frontPatchi_
<< " for front faces." << nl << endl;
@ -174,14 +141,6 @@ void Foam::extrude2DMesh::addFrontBackPatches()
patches
).ptr();
// newPatches[frontPatchi_] = polyPatch::New
// (
// "back",
// patchDict_,
// backPatchi_,
// patches
// ).ptr();
Info<< "Adding patch " << newPatches[backPatchi_]->name()
<< " at index " << backPatchi_
<< " for back faces." << nl << endl;
@ -203,15 +162,20 @@ void Foam::extrude2DMesh::setRefinement
for (label layer = 0; layer < nLayers; ++layer)
{
label offset = layer * mesh_.nCells();
const label offset = layer*mesh_.nCells();
forAll(mesh_.cells(), celli)
{
meshMod.addCell
const label newCelli = meshMod.addCell
(
celli + offset, // masterCellID,
mesh_.cellZones().whichZone(celli) // zoneID
celli + offset // masterCellID
);
const labelList zones(mesh_.cellZones().whichZones(celli));
forAll(zones, zonei)
{
cellZonesAddedCells_[zonei].insert(newCelli);
}
}
}
@ -275,23 +239,6 @@ void Foam::extrude2DMesh::setRefinement
newFace[2] = f[1] + nextLayerOffset;
newFace[3] = f[0] + nextLayerOffset;
//{
// vector n = newFace.normal(pointField(meshMod.points()));
// label own = mesh_.faceOwner()[facei];
// const labelList& ownPoints = mesh_.cellPoints()[own];
// point ownCc = sum(pointField(mesh_.points(), ownPoints))/ownPoints.size();
// label nei = mesh_.faceNeighbour()[facei];
// const labelList& neiPoints = mesh_.cellPoints()[nei];
// point neiCc = sum(pointField(mesh_.points(), neiPoints))/neiPoints.size();
// vector d = neiCc - ownCc;
// Pout<< "face:" << facei << " at:" << f.centre(mesh_.points()) << endl
// << " own:" << own << " at:" << ownCc << endl
// << " nei:" << nei << " at:" << neiCc << endl
// << " sign:" << (n & d) << endl
// << endl;
//}
label offset = layer * mesh_.nCells();
meshMod.addFace
@ -569,4 +516,14 @@ void Foam::extrude2DMesh::setRefinement
}
void Foam::extrude2DMesh::updateZones()
{
// Add the cellZones to the merged mesh
forAll(cellZonesAddedCells_, zonei)
{
mesh_.cellZones()[zonei].insert(cellZonesAddedCells_[zonei]);
}
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -68,8 +68,6 @@ class extrude2DMesh
const dictionary dict_;
// const dictionary patchDict_;
const extrudeModel& model_;
const word modelType_;
@ -77,16 +75,18 @@ class extrude2DMesh
const word patchType_;
label frontPatchi_;
label backPatchi_;
//- Zones of the added cells
List<labelHashSet> cellZonesAddedCells_;
// Private Member Functions
//- Check the mesh is 2D
void check2D() const;
//- Find extrusion direction
// void findExtrudeDirection();
public:
@ -115,17 +115,6 @@ public:
//- Add front and back patches
void addFrontBackPatches();
//- Play commands into polyTopoChange to extrude mesh.
void setRefinement(polyTopoChange&);
//- Force recalculation of locally stored data on topological change
void topoChange(const polyTopoChangeMap&)
{}
//- Force recalculation of locally stored data for mesh distribution
void distribute(const polyDistributionMap&)
{}
label frontPatchi() const
{
return frontPatchi_;
@ -136,6 +125,13 @@ public:
return backPatchi_;
}
//- Play commands into polyTopoChange to extrude mesh.
void setRefinement(polyTopoChange&);
//- Update the mesh zones
// adding the point and cell zones for the added layer
void updateZones();
// Member Operators

View File

@ -630,6 +630,8 @@ int main(int argc, char *argv[])
layerExtrude.updateZones(meshFromMesh());
meshFromMesh().topoChange(map);
layerExtrude.topoChange
(
map(),

View File

@ -100,11 +100,11 @@ Foam::label Foam::mergePolyMesh::zoneIndex
const word& curName
)
{
forAll(names, zoneI)
forAll(names, zonei)
{
if (names[zoneI] == curName)
if (names[zonei] == curName)
{
return zoneI;
return zonei;
}
}
@ -148,9 +148,9 @@ Foam::mergePolyMesh::mergePolyMesh(polyMesh& mesh)
pointZoneNames_.setCapacity(2*curPointZoneNames.size());
}
forAll(curPointZoneNames, zoneI)
forAll(curPointZoneNames, zonei)
{
pointZoneNames_.append(curPointZoneNames[zoneI]);
pointZoneNames_.append(curPointZoneNames[zonei]);
}
pointZonesAddedPoints_.setSize(pointZoneNames_.size());
@ -162,9 +162,9 @@ Foam::mergePolyMesh::mergePolyMesh(polyMesh& mesh)
{
faceZoneNames_.setCapacity(2*curFaceZoneNames.size());
}
forAll(curFaceZoneNames, zoneI)
forAll(curFaceZoneNames, zonei)
{
faceZoneNames_.append(curFaceZoneNames[zoneI]);
faceZoneNames_.append(curFaceZoneNames[zonei]);
}
// Cell zones
@ -174,16 +174,16 @@ Foam::mergePolyMesh::mergePolyMesh(polyMesh& mesh)
{
cellZoneNames_.setCapacity(2*curCellZoneNames.size());
}
forAll(curCellZoneNames, zoneI)
forAll(curCellZoneNames, zonei)
{
cellZoneNames_.append(curCellZoneNames[zoneI]);
cellZoneNames_.append(curCellZoneNames[zonei]);
}
cellZonesAddedCells_.setSize(cellZoneNames_.size());
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::mergePolyMesh::addMesh(const polyMesh& m)
@ -192,17 +192,15 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
// Add points
label zoneID = -1;
const pointField& p = m.points();
labelList renumberPoints(p.size());
const meshPointZones& pz = m.pointZones();
labelList pointZoneIndices(pz.size());
forAll(pz, zoneI)
forAll(pz, zonei)
{
pointZoneIndices[zoneI] = zoneIndex(pointZoneNames_, pz[zoneI].name());
pointZoneIndices[zonei] = zoneIndex(pointZoneNames_, pz[zonei].name());
pointZonesAddedPoints_.setSize(pointZoneNames_.size());
}
@ -215,12 +213,10 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
pointi < m.nPoints() // Is in cell?
);
// Grab zone ID. If a point is not in a zone, it will return -1
zoneID = pz.whichZone(pointi);
if (zoneID >= 0)
const labelList zones(pz.whichZones(pointi));
forAll(zones, zonei)
{
pointZonesAddedPoints_[pointZoneIndices[zoneID]]
pointZonesAddedPoints_[pointZoneIndices[zonei]]
.insert(renumberPoints[pointi]);
}
}
@ -233,27 +229,22 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
const meshCellZones& cz = m.cellZones();
labelList cellZoneIndices(cz.size());
forAll(cz, zoneI)
forAll(cz, zonei)
{
cellZoneIndices[zoneI] = zoneIndex(cellZoneNames_, cz[zoneI].name());
cellZoneIndices[zonei] = zoneIndex(cellZoneNames_, cz[zonei].name());
cellZonesAddedCells_.setSize(cellZoneNames_.size());
}
forAll(c, celli)
{
// Grab zone ID. If a cell is not in a zone, it will return -1
zoneID = cz.whichZone(celli);
renumberCells[celli] = meshMod_.addCell(-1);
if (zoneID >= 0)
const labelList zones(cz.whichZones(celli));
forAll(zones, zonei)
{
// Translate zone ID into the new index
zoneID = cellZoneIndices[zoneID];
cellZonesAddedCells_[cellZoneIndices[zonei]]
.insert(renumberCells[celli]);
}
renumberCells[celli] = meshMod_.addCell
(
-1, // Master cell
zoneID // Zone for cell
);
}
// Add faces
@ -276,9 +267,9 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
const meshFaceZones& fz = m.faceZones();
labelList faceZoneIndices(fz.size());
forAll(fz, zoneI)
forAll(fz, zonei)
{
faceZoneIndices[zoneI] = zoneIndex(faceZoneNames_, fz[zoneI].name());
faceZoneIndices[zonei] = zoneIndex(faceZoneNames_, fz[zonei].name());
}
const faceList& f = m.faces();
@ -438,14 +429,14 @@ void Foam::mergePolyMesh::merge()
mesh_.pointZones().setSize(pointZoneNames_.size());
for (label zoneI = nZones; zoneI < pointZoneNames_.size(); zoneI++)
for (label zonei = nZones; zonei < pointZoneNames_.size(); zonei++)
{
mesh_.pointZones().set
(
zoneI,
zonei,
new pointZone
(
pointZoneNames_[zoneI],
pointZoneNames_[zonei],
labelList(),
mesh_.pointZones()
)
@ -464,14 +455,14 @@ void Foam::mergePolyMesh::merge()
mesh_.cellZones().setSize(cellZoneNames_.size());
for (label zoneI = nZones; zoneI < cellZoneNames_.size(); zoneI++)
for (label zonei = nZones; zonei < cellZoneNames_.size(); zonei++)
{
mesh_.cellZones().set
(
zoneI,
zonei,
new cellZone
(
cellZoneNames_[zoneI],
cellZoneNames_[zonei],
labelList(),
mesh_.cellZones()
)
@ -490,14 +481,14 @@ void Foam::mergePolyMesh::merge()
mesh_.faceZones().setSize(faceZoneNames_.size());
for (label zoneI = nZones; zoneI < faceZoneNames_.size(); zoneI++)
for (label zonei = nZones; zonei < faceZoneNames_.size(); zonei++)
{
mesh_.faceZones().set
(
zoneI,
zonei,
new faceZone
(
faceZoneNames_[zoneI],
faceZoneNames_[zonei],
labelList(),
boolList(),
mesh_.faceZones()
@ -507,16 +498,24 @@ void Foam::mergePolyMesh::merge()
}
// Change mesh
meshMod_.changeMesh(mesh_);
// Clear topo change for the next operation
meshMod_.clear();
autoPtr<polyTopoChangeMap> map(meshMod_.changeMesh(mesh_));
// Add the new points to the pointZones in the merged mesh
forAll(pointZonesAddedPoints_, zonei)
{
mesh_.pointZones()[zonei].insert(pointZonesAddedPoints_[zonei]);
}
// Add the new cells to the cellZones in the merged mesh
forAll(cellZonesAddedCells_, zonei)
{
mesh_.cellZones()[zonei].insert(cellZonesAddedCells_[zonei]);
}
mesh_.topoChange(map);
// Clear topo change for the next operation
meshMod_.clear();
}

View File

@ -75,6 +75,9 @@ class mergePolyMesh
//- Cell zone names
DynamicList<word> cellZoneNames_;
//- Zones of the added cells
List<labelHashSet> cellZonesAddedCells_;
// Private Member Functions

View File

@ -933,8 +933,7 @@ void Foam::meshDualiser::setRefinement
pointToDualCells_[pointi].setSize(1);
pointToDualCells_[pointi][0] = meshMod.addCell
(
-1, // masterCellID,
-1 // zoneID
-1 // masterCellID,
);
if (dualCcStr.valid())
{
@ -973,8 +972,7 @@ void Foam::meshDualiser::setRefinement
{
pointToDualCells_[pointi][pCelli] = meshMod.addCell
(
-1, // masterCellID
-1
-1 // masterCellID
);
if (dualCcStr.valid())
{
@ -994,8 +992,7 @@ void Foam::meshDualiser::setRefinement
pointToDualCells_[pointi].setSize(1);
pointToDualCells_[pointi][0] = meshMod.addCell
(
-1, // masterCellID,
-1 // zoneID
-1 // masterCellID,
);
if (dualCcStr.valid())

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -561,6 +561,9 @@ public:
// time directories
readUpdateState readUpdate();
//- Update zones using the given map
void topoChangeZones(const polyTopoChangeMap&);
//- Update topology using the given map
virtual void topoChange(const polyTopoChangeMap&);

View File

@ -36,6 +36,14 @@ Description
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::polyMesh::topoChangeZones(const polyTopoChangeMap& map)
{
pointZones_.topoChange(map);
faceZones_.topoChange(map);
cellZones_.topoChange(map);
}
void Foam::polyMesh::topoChange(const polyTopoChangeMap& map)
{
if (debug)
@ -49,9 +57,7 @@ void Foam::polyMesh::topoChange(const polyTopoChangeMap& map)
boundary_.topoChange();
// Update zones
pointZones_.topoChange(map);
faceZones_.topoChange(map);
cellZones_.topoChange(map);
topoChangeZones(map);
// Remove the stored tet base points
tetBasePtIsPtr_.clear();

View File

@ -132,26 +132,18 @@ void Foam::cellZone::topoChange(const polyTopoChangeMap& map)
{
clearAddressing();
/*
labelList newAddressing(size());
label nCells = 0;
labelHashSet newIndices;
const labelList& cellMap = map.cellMap();
const labelList& cellMap = map.reverseCellMap();
forAll(*this, i)
forAll(cellMap, celli)
{
const label celli = operator[](i);
if (cellMap[celli] >= 0)
if (cellMap[celli] >= 0 && localIndex(cellMap[celli]) != -1)
{
newAddressing[nCells] = cellMap[celli];
nCells++;
newIndices.insert(celli);
}
}
newAddressing.setSize(nCells);
transfer(newAddressing);
*/
labelList::operator=(newIndices.sortedToc());
}

View File

@ -3014,12 +3014,10 @@ Foam::autoPtr<Foam::polyTopoChangeMap> Foam::meshRefinement::zonify
mesh_.cellZones()[zonei].insert(cellZoneNewCells[zonei]);
}
// Topochange container
polyTopoChange meshMod(mesh_);
// Get coupled neighbour cellZone. Set to -1 on non-coupled patches.
labelList neiCellZone;
syncTools::swapBoundaryCellList(mesh_, cellToZone, neiCellZone);
@ -3038,12 +3036,10 @@ Foam::autoPtr<Foam::polyTopoChangeMap> Foam::meshRefinement::zonify
}
// Get per face whether is it master (of a coupled set of faces)
const PackedBoolList isMasterFace(syncTools::getMasterFaces(mesh_));
// faceZones
// ~~~~~~~~~
// Faces on faceZones come in two variants:

View File

@ -503,8 +503,7 @@ void Foam::createShellMesh::setRefinement
{
addedCells[nLayers*facei+layerI] = meshMod.addCell
(
cellToFaceMap.size(), // masterCellID
-1 // zoneID
cellToFaceMap.size() // masterCellID
);
cellToFaceMap.append(facei);
}

View File

@ -590,6 +590,9 @@ Foam::autoPtr<Foam::polyTopoChangeMap> Foam::fvMeshDistribute::repatch
autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_, true);
// Update zones
mesh_.topoChangeZones(map);
// Update fields
mesh_.mapFields(map);
@ -772,6 +775,9 @@ Foam::autoPtr<Foam::polyTopoChangeMap> Foam::fvMeshDistribute::mergeSharedPoints
// Note: parallel comms allowed.
autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_, true);
// Update zones
mesh_.topoChangeZones(map);
// Update fields
mesh_.mapFields(map);
@ -1278,6 +1284,9 @@ Foam::autoPtr<Foam::polyTopoChangeMap> Foam::fvMeshDistribute::doRemoveCells
// Note: no parallel comms allowed.
autoPtr<polyTopoChangeMap> map = meshMod.changeMesh(mesh_, false);
// Update zones
mesh_.topoChangeZones(map);
// Update fields
mesh_.mapFields(map);

View File

@ -606,11 +606,7 @@ void Foam::meshCutter::setRefinement
if (cellLoops[celli].size())
{
// Add a cell to the existing cell
label addedCelli = meshMod.addCell
(
celli, // master cell
mesh().cellZones().whichZone(celli) // zone for cell
);
label addedCelli = meshMod.addCell(celli);
addedCells_.insert(celli, addedCelli);

View File

@ -421,6 +421,7 @@ Foam::addPatchCellLayer::addPatchCellLayer
addToMesh_(addToMesh),
addedPoints_(0),
pointZonesAddedPoints_(mesh.pointZones().size()),
cellZonesAddedCells_(mesh.cellZones().size()),
layerFaces_(0)
{}
@ -1009,9 +1010,9 @@ void Foam::addPatchCellLayer::setRefinement
true // supports a cell
);
const label zonei = mesh_.pointZones().whichZone(meshPointi);
if (zonei != -1)
forAll(mesh_.pointZones(), zonei)
{
if (mesh_.pointZones()[zonei].localIndex(meshPointi) != -1)
{
pointZonesAddedPoints_[zonei].insert
(
@ -1021,6 +1022,7 @@ void Foam::addPatchCellLayer::setRefinement
}
}
}
}
// Create points for additional layers
@ -1033,7 +1035,7 @@ void Foam::addPatchCellLayer::setRefinement
point pt = mesh_.points()[meshPointi];
vector disp = firstLayerDisp[patchPointi];
const label zonei = mesh_.pointZones().whichZone(meshPointi);
const labelList zones(mesh_.pointZones().whichZones(meshPointi));
forAll(addedPoints_[patchPointi], i)
{
@ -1048,7 +1050,7 @@ void Foam::addPatchCellLayer::setRefinement
addedPoints_[patchPointi][i] = addedVertI;
if (zonei != -1)
forAll(zones, zonei)
{
pointZonesAddedPoints_[zonei].insert(addedVertI);
}
@ -1071,11 +1073,11 @@ void Foam::addPatchCellLayer::setRefinement
{
addedCells[patchFacei].setSize(nFaceLayers[patchFacei]);
label meshFacei = pp.addressing()[patchFacei];
const label meshFacei = pp.addressing()[patchFacei];
label ownZoneI = mesh_.cellZones().whichZone
const labelList ownZones
(
mesh_.faceOwner()[meshFacei]
mesh_.cellZones().whichZones( mesh_.faceOwner()[meshFacei])
);
for (label i = 0; i < nFaceLayers[patchFacei]; i++)
@ -1084,13 +1086,19 @@ void Foam::addPatchCellLayer::setRefinement
// for now add from cell so we can map easily.
addedCells[patchFacei][i] = meshMod.addCell
(
(addToMesh_ ? mesh_.faceOwner()[meshFacei] : -1), // master
ownZoneI // zone for cell
(addToMesh_ ? mesh_.faceOwner()[meshFacei] : -1)
);
forAll(ownZones, zonei)
{
cellZonesAddedCells_[zonei].insert
(
addedCells[patchFacei][i]
);
}
}
}
}
// Create faces on top of the original patch faces.
@ -1684,6 +1692,12 @@ void Foam::addPatchCellLayer::updateZones(polyMesh& mesh)
{
mesh.pointZones()[zonei].insert(pointZonesAddedPoints_[zonei]);
}
// Add the cellZones to the merged mesh
forAll(cellZonesAddedCells_, zonei)
{
mesh.cellZones()[zonei].insert(cellZonesAddedCells_[zonei]);
}
}

View File

@ -175,6 +175,9 @@ class addPatchCellLayer
//- Zones of the added points
List<labelHashSet> pointZonesAddedPoints_;
//- Zones of the added cells
List<labelHashSet> cellZonesAddedCells_;
//- For all patchfaces: list of layer faces.
// - empty if no face extruded
// - first face is original boundary face

View File

@ -3632,16 +3632,10 @@ Foam::labelListList Foam::hexRef8::setRefinement
// Update cell level
newCellLevel[celli] = cellLevel_[celli]+1;
for (label i = 1; i < 8; i++)
{
cAdded[i] = meshMod.addCell
(
celli, // master cell
mesh_.cellZones().whichZone(celli) // zone for cell
);
newCellLevel(cAdded[i]) = cellLevel_[celli]+1;
cAdded[i] = meshMod.addCell(celli);
newCellLevel(cAdded[i]) = cellLevel_[celli] + 1;
}
}
}

View File

@ -796,12 +796,6 @@ void Foam::polyTopoChange::getFaceOrder
}
}
// if (debug)
//{
// Pout<< "patchSizes:" << patchSizes << nl
// << "patchStarts:" << patchStarts << endl;
//}
labelList workPatchStarts(patchStarts);
for (label facei = 0; facei < nActiveFaces; facei++)
@ -899,7 +893,6 @@ void Foam::polyTopoChange::compact
cellMap_.shrink();
reverseCellMap_.shrink();
cellZone_.shrink();
// Compact points
@ -1149,9 +1142,6 @@ void Foam::polyTopoChange::compact
cellMap_.setCapacity(newCelli);
renumberReverseMap(localCellMap, reverseCellMap_);
reorder(localCellMap, cellZone_);
cellZone_.setCapacity(newCelli);
// Renumber owner/neighbour. Take into account if neighbour suddenly
// gets lower cell than owner.
forAll(faceOwner_, facei)
@ -1412,69 +1402,6 @@ void Foam::polyTopoChange::resetZones
);
}
}
// cellZones
// ~~~~~~~~~
{
const meshCellZones& cellZones = mesh.cellZones();
labelList nCells(cellZones.size(), 0);
forAll(cellZone_, celli)
{
label zoneI = cellZone_[celli];
if (zoneI >= cellZones.size())
{
FatalErrorInFunction
<< "Illegal zoneID " << zoneI << " for cell "
<< celli << abort(FatalError);
}
if (zoneI >= 0)
{
nCells[zoneI]++;
}
}
labelListList addressing(cellZones.size());
forAll(addressing, zoneI)
{
addressing[zoneI].setSize(nCells[zoneI]);
}
nCells = 0;
forAll(cellZone_, celli)
{
label zoneI = cellZone_[celli];
if (zoneI >= 0)
{
addressing[zoneI][nCells[zoneI]++] = celli;
}
}
// Sort the addressing
forAll(addressing, zoneI)
{
stableSort(addressing[zoneI]);
}
// Reset the addressing on the zone
forAll(newMesh.cellZones(), zoneI)
{
if (debug)
{
Pout<< "cellZone:" << zoneI
<< " name:" << newMesh.cellZones()[zoneI].name()
<< " size:" << addressing[zoneI].size()
<< endl;
}
newMesh.cellZones()[zoneI] = addressing[zoneI];
}
}
}
@ -1780,8 +1707,7 @@ Foam::polyTopoChange::polyTopoChange(const label nPatches, const bool strict)
faceZoneFlip_(0),
nActiveFaces_(0),
cellMap_(0),
reverseCellMap_(0),
cellZone_(0)
reverseCellMap_(0)
{}
@ -1809,8 +1735,7 @@ Foam::polyTopoChange::polyTopoChange
faceZoneFlip_(0),
nActiveFaces_(0),
cellMap_(0),
reverseCellMap_(0),
cellZone_(0)
reverseCellMap_(0)
{
// Add points
{
@ -1825,19 +1750,12 @@ Foam::polyTopoChange::polyTopoChange
// Add points in mesh order
for (label pointi = 0; pointi < mesh.nPoints(); pointi++)
{
addPoint
(
points[pointi],
pointi,
true
);
addPoint(points[pointi], pointi, true);
}
}
// Add cells
{
const meshCellZones& cellZones = mesh.cellZones();
// Resize
// Note: polyMesh does not allow retired cells anymore. So allCells
@ -1846,43 +1764,11 @@ Foam::polyTopoChange::polyTopoChange
cellMap_.setCapacity(cellMap_.size() + nAllCells);
reverseCellMap_.setCapacity(reverseCellMap_.size() + nAllCells);
cellZone_.setCapacity(cellZone_.size() + nAllCells);
// Precalc offset zones
labelList newZoneID(nAllCells, -1);
forAll(cellZones, zoneI)
{
const labelList& cellLabels = cellZones[zoneI];
forAll(cellLabels, j)
{
label celli = cellLabels[j];
if (newZoneID[celli] != -1)
{
WarningInFunction
<< "Cell:" << celli
<< " centre:" << mesh.cellCentres()[celli]
<< " is in two zones:"
<< cellZones[newZoneID[celli]].name()
<< " and " << cellZones[zoneI].name() << endl
<< " This is not supported."
<< " Continuing with first zone only." << endl;
}
else
{
newZoneID[celli] = zoneI;
}
}
}
// Add cells in mesh order
for (label celli = 0; celli < nAllCells; celli++)
{
// Add cell from cell
addCell(celli, newZoneID[celli]);
addCell(celli);
}
}
@ -2001,7 +1887,6 @@ void Foam::polyTopoChange::clear()
cellMap_.clearStorage();
reverseCellMap_.clearStorage();
cellZone_.clearStorage();
}
@ -2028,7 +1913,6 @@ void Foam::polyTopoChange::setCapacity
cellMap_.setCapacity(nCells);
reverseCellMap_.setCapacity(nCells);
cellZone_.setCapacity(nCells);
}
@ -2276,16 +2160,11 @@ void Foam::polyTopoChange::removeFace(const label facei, const label mergeFacei)
}
Foam::label Foam::polyTopoChange::addCell
(
const label masterCellID,
const label zoneID
)
Foam::label Foam::polyTopoChange::addCell(const label masterCellID)
{
const label celli = cellMap_.size();
cellMap_.append(masterCellID);
reverseCellMap_.append(celli);
cellZone_.append(zoneID);
return celli;
}
@ -2318,7 +2197,6 @@ void Foam::polyTopoChange::removeCell(const label celli, const label mergeCelli)
{
reverseCellMap_[celli] = -1;
}
cellZone_[celli] = -1;
}
@ -2465,7 +2343,6 @@ Foam::autoPtr<Foam::polyTopoChangeMap> Foam::polyTopoChange::changeMesh
{
faceZone_.clearStorage();
faceZoneFlip_.clearStorage();
cellZone_.clearStorage();
}
@ -2689,12 +2566,6 @@ Foam::autoPtr<Foam::polyTopoChangeMap> Foam::polyTopoChange::makeMesh
{
forAll(oldPointZones, i)
{
// pZonePtrs[i] = new pointZone
// (
// oldPointZones[i].name(),
// labelList(0),
// newMesh.pointZones()
// );
pZonePtrs[i] = oldPointZones[i].clone(newMesh.pointZones()).ptr();
}
}
@ -2719,12 +2590,7 @@ Foam::autoPtr<Foam::polyTopoChangeMap> Foam::polyTopoChange::makeMesh
{
forAll(oldCellZones, i)
{
cZonePtrs[i] = new cellZone
(
oldCellZones[i].name(),
labelList(0),
newMesh.cellZones()
);
cZonePtrs[i] = oldCellZones[i].clone(newMesh.cellZones()).ptr();
}
}
@ -2735,7 +2601,6 @@ Foam::autoPtr<Foam::polyTopoChangeMap> Foam::polyTopoChange::makeMesh
{
faceZone_.clearStorage();
faceZoneFlip_.clearStorage();
cellZone_.clearStorage();
}
// Patch point renumbering

View File

@ -100,7 +100,7 @@ class polyTopoChange
// Private Data
//- Whether to allow referencing illegal points/cells/faces
// when adding/removing data.
// when adding/removing data
bool strict_;
@ -118,7 +118,7 @@ class polyTopoChange
//- Original point label (or masterpoint for added points)
DynamicList<label> pointMap_;
//- For all original and added points contains new point label.
//- For all original and added points contains new point label
// (used to map return value of addPoint to new mesh point)
DynamicList<label> reversePointMap_;
@ -152,7 +152,7 @@ class polyTopoChange
// (used to map return value of addFace to new mesh face)
DynamicList<label> reverseFaceMap_;
//- In mapping whether to reverse the flux.
//- In mapping whether to reverse the flux
PackedBoolList flipFaceFlux_;
//- Zone of face
@ -168,29 +168,29 @@ class polyTopoChange
// Cells
//- Original cell label or master cell for added-from-cell;
// -1 for cells added from face or edge.
// -1 for cells added from face or edge
DynamicList<label> cellMap_;
//- For all original and added cells contains new cell label
// (used to map return value of addCell to new mesh cell)
DynamicList<label> reverseCellMap_;
//- Zone of cell
DynamicList<label> cellZone_;
// Private Member Functions
//- Reorder contents of container according to map
template<class T>
static void reorder(const labelList& map, DynamicList<T>&);
template<class T>
static void reorder(const labelList& map, List<DynamicList<T>>&);
template<class T>
static void renumberKey(const labelList& map, Map<T>&);
//- Renumber elements of container according to map
static void renumber(const labelList&, labelHashSet&);
//- Special handling of reverse maps which have <-1 in them
static void renumberReverseMap(const labelList&, DynamicList<label>&);
@ -200,7 +200,7 @@ class polyTopoChange
//- Get all set elements as a labelHashSet
static labelHashSet getSetIndices(const PackedBoolList&);
//- Count number of added and removed quantities from maps.
//- Count number of added and removed quantities from maps
static void countMap
(
const labelList& map,
@ -215,7 +215,7 @@ class polyTopoChange
static void writeMeshStats(const polyMesh& mesh, Ostream&);
//- Calculate object maps. Requires reverseMap to have destination
// to be marked with <-1.
// to be marked with < -1
static void getMergeSets
(
const labelList& reverseCellMap,
@ -255,14 +255,14 @@ class polyTopoChange
CompactListList<label>& cellCells
) const;
//- Cell ordering (bandCompression). Returns number of remaining cells.
//- Cell ordering (bandCompression). Returns number of remaining cells
label getCellOrder
(
const CompactListList<label>&,
labelList&
) const;
//- Do upper-triangular ordering and patch ordering.
//- Do upper-triangular ordering and patch ordering
void getFaceOrder
(
const label nActiveFaces,
@ -381,7 +381,7 @@ public:
// setNumPatches before trying to make a mesh (makeMesh, changeMesh)
polyTopoChange(const label nPatches, const bool strict = true);
//- Construct from mesh. Adds all points/face/cells from mesh.
//- Construct from mesh. Adds all points/face/cells from mesh
polyTopoChange(const polyMesh& mesh, const bool strict = true);
@ -439,7 +439,7 @@ public:
const label nCells
);
//- Add point. Return new point label.
//- Add point and return new point index
// Notes:
// - masterPointID can be < 0 (appended points)
// - inCell = false: add retired point (to end of point list)
@ -450,7 +450,7 @@ public:
const bool inCell
);
//- Modify coordinate.
//- Modify coordinate
// Notes:
// - inCell = false: add retired point (to end of point list)
void modifyPoint
@ -460,10 +460,10 @@ public:
const bool inCell
);
//- Remove/merge point.
//- Remove point / merge points
void removePoint(const label, const label);
//- Add face to cells. Return new face label.
//- Add face to cells and return new face index
// own,nei<0, zoneID>=0 : add inactive face (to end of face list)
label addFace
(
@ -477,7 +477,7 @@ public:
const bool zoneFlip
);
//- Modify vertices or cell of face.
//- Modify vertices or cell of face
void modifyFace
(
const face& f,
@ -490,23 +490,20 @@ public:
const bool zoneFlip
);
//- Remove/merge face.
//- Remove face / merge faces
void removeFace(const label, const label);
//- Add cell. Return new cell label.
label addCell
(
const label masterCellID,
const label zoneID
);
//- Add cell and return new cell index
label addCell(const label masterCellID);
//- Remove/merge cell.
//- Remove cell / merge cells
void removeCell(const label, const label);
//- Explicitly set the number of patches if construct-without-mesh
// used.
// used
inline void setNumPatches(const label nPatches);
// Other
//- Inplace changes mesh without change of patches.

View File

@ -8,7 +8,7 @@ rm -rf constant/polyMesh/sets
runApplication blockMesh
runApplication snappyHexMesh -overwrite
runApplication splitMeshRegions -cellZones -overwrite
runApplication splitMeshRegions -cellZones -defaultRegionName fluid -overwrite
runApplication decomposePar -allRegions
runParallel $(getApplication)
runApplication reconstructPar -allRegions

View File

@ -30,7 +30,7 @@ vertices
blocks
(
hex (0 1 2 3 4 5 6 7) fluid (20 24 60) simpleGrading (1 1 1)
hex (0 1 2 3 4 5 6 7) (20 24 60) simpleGrading (1 1 1)
);
defaultPatch