polyTopoChange: Removed restrictive pointZone functionality

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

The same rationalisation and generalisation will be applied to cellZones and
faceZones in the future.
This commit is contained in:
Henry Weller
2024-03-13 20:36:00 +00:00
parent 9e3d5fd521
commit 9239b3bfa9
30 changed files with 218 additions and 408 deletions

View File

@ -153,6 +153,8 @@ Foam::mergePolyMesh::mergePolyMesh(polyMesh& mesh)
pointZoneNames_.append(curPointZoneNames[zoneI]);
}
pointZonesAddedPoints_.setSize(pointZoneNames_.size());
// Face zones
wordList curFaceZoneNames = mesh_.faceZones().names();
@ -201,26 +203,26 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
forAll(pz, zoneI)
{
pointZoneIndices[zoneI] = zoneIndex(pointZoneNames_, pz[zoneI].name());
pointZonesAddedPoints_.setSize(pointZoneNames_.size());
}
forAll(p, pointi)
{
renumberPoints[pointi] = meshMod_.addPoint
(
p[pointi], // Point to add
-1, // Master point (straight addition)
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)
{
// Translate zone ID into the new index
zoneID = pointZoneIndices[zoneID];
pointZonesAddedPoints_[pointZoneIndices[zoneID]]
.insert(renumberPoints[pointi]);
}
renumberPoints[pointi] = meshMod_.addPoint
(
p[pointi], // Point to add
-1, // Master point (straight addition)
zoneID, // Zone for point
pointi < m.nPoints() // Is in cell?
);
}
// Add cells
@ -509,6 +511,12 @@ void Foam::mergePolyMesh::merge()
// Clear topo change for the next operation
meshMod_.clear();
// Add the new points to the pointZones in the merged mesh
forAll(pointZonesAddedPoints_, zonei)
{
mesh_.pointZones()[zonei].insert(pointZonesAddedPoints_[zonei]);
}
}

View File

@ -66,6 +66,9 @@ class mergePolyMesh
//- Point zone names
DynamicList<word> pointZoneNames_;
//- Zones of the added points
List<labelHashSet> pointZonesAddedPoints_;
//- Face zone names
DynamicList<word> faceZoneNames_;

View File

@ -127,7 +127,6 @@ void Foam::meshDualiser::generateDualBoundaryEdges
(
e.centre(mesh_.points()),
pointi, // masterPoint
-1, // zoneID
true // inCell
);
}
@ -177,20 +176,6 @@ Foam::label Foam::meshDualiser::addInternalFace
reverse(newFace);
}
label zoneID = -1;
bool zoneFlip = false;
if (masterFacei != -1)
{
zoneID = mesh_.faceZones().whichZone(masterFacei);
if (zoneID != -1)
{
const faceZone& fZone = mesh_.faceZones()[zoneID];
zoneFlip = fZone.flipMap()[fZone.whichFace(masterFacei)];
}
}
label dualFacei;
if (dualCell0 < dualCell1)
@ -203,8 +188,8 @@ Foam::label Foam::meshDualiser::addInternalFace
masterFacei, // masterFaceID
false, // flipFaceFlux
-1, // patchID
zoneID, // zoneID
zoneFlip // zoneFlip
-1, // zoneID
false // zoneFlip
);
// pointField dualPoints(meshMod.points());
@ -228,8 +213,8 @@ Foam::label Foam::meshDualiser::addInternalFace
masterFacei, // masterFaceID
false, // flipFaceFlux
-1, // patchID
zoneID, // zoneID
zoneFlip // zoneFlip
-1, // zoneID
false // zoneFlip
);
// pointField dualPoints(meshMod.points());
@ -261,20 +246,6 @@ Foam::label Foam::meshDualiser::addBoundaryFace
{
face newFace(verts);
label zoneID = -1;
bool zoneFlip = false;
if (masterFacei != -1)
{
zoneID = mesh_.faceZones().whichZone(masterFacei);
if (zoneID != -1)
{
const faceZone& fZone = mesh_.faceZones()[zoneID];
zoneFlip = fZone.flipMap()[fZone.whichFace(masterFacei)];
}
}
label dualFacei = meshMod.addFace
(
newFace,
@ -283,8 +254,8 @@ Foam::label Foam::meshDualiser::addBoundaryFace
masterFacei, // masterFaceID
false, // flipFaceFlux
patchi, // patchID
zoneID, // zoneID
zoneFlip // zoneFlip
-1, // zoneID
false // zoneFlip
);
// pointField dualPoints(meshMod.points());
@ -955,7 +926,6 @@ void Foam::meshDualiser::setRefinement
(
mesh_.points()[pointi],
pointi, // masterPoint
mesh_.pointZones().whichZone(pointi), // zoneID
true // inCell
);
@ -990,7 +960,6 @@ void Foam::meshDualiser::setRefinement
(
mesh_.points()[pointi],
pointi, // masterPoint
mesh_.pointZones().whichZone(pointi), // zoneID
true // inCell
);
@ -1005,7 +974,7 @@ void Foam::meshDualiser::setRefinement
pointToDualCells_[pointi][pCelli] = meshMod.addCell
(
-1, // masterCellID
mesh_.cellZones().whichZone(pCells[pCelli]) // zoneID
-1
);
if (dualCcStr.valid())
{
@ -1046,7 +1015,6 @@ void Foam::meshDualiser::setRefinement
(
cellCentres[celli],
mesh_.faces()[mesh_.cells()[celli][0]][0], // masterPoint
-1, // zoneID
true // inCell
);
}
@ -1061,7 +1029,6 @@ void Foam::meshDualiser::setRefinement
(
mesh_.faceCentres()[facei],
mesh_.faces()[facei][0], // masterPoint
-1, // zoneID
true // inCell
);
}
@ -1085,7 +1052,6 @@ void Foam::meshDualiser::setRefinement
(
mesh_.faceCentres()[facei],
f[fp], // masterPoint
-1, // zoneID
true // inCell
);
@ -1107,7 +1073,6 @@ void Foam::meshDualiser::setRefinement
(
e.centre(mesh_.points()),
e[0], // masterPoint
-1, // zoneID
true // inCell
);
}
@ -1142,7 +1107,6 @@ void Foam::meshDualiser::setRefinement
(
e.centre(mesh_.points()),
e[0], // masterPoint
mesh_.pointZones().whichZone(e[0]), // zoneID
true // inCell
);
@ -1157,7 +1121,6 @@ void Foam::meshDualiser::setRefinement
(
e.centre(mesh_.points()),
e[1], // masterPoint
mesh_.pointZones().whichZone(e[1]), // zoneID
true // inCell
);

View File

@ -422,6 +422,14 @@ int main(int argc, char *argv[])
}
mesh.cellZones().clear();
mesh.pointZones().clear();
if (doNotPreserveFaceZones)
{
mesh.faceZones().clear();
}
// Face(centre)s that need inclusion in the dual mesh
labelList featureFaces;
// Edge(centre)s ,,
@ -446,6 +454,8 @@ int main(int argc, char *argv[])
multiCellFeaturePoints
);
mesh.faceZones().clear();
// If we want to split all polyMesh faces into one dualface per cell
// we are passing through we also need a point
// at the polyMesh facecentre and edgemid of the faces we want to