diff --git a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L index ae658b0af1..68f4c82589 100644 --- a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L +++ b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L @@ -1243,7 +1243,7 @@ int main(int argc, char *argv[]) // Add all points forAll(points, pointi) { - meshMod.addPoint(points[pointi], pointi, -1, true); + meshMod.addPoint(points[pointi], pointi, true); } points.setSize(0); diff --git a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh.C b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh.C index 174db26e75..7ef48e1d1b 100644 --- a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh.C +++ b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh.C @@ -42,7 +42,6 @@ Description #include "polyTopoChange.H" #include "MeshedSurface.H" #include "edgeCollapser.H" -#include "addPatchCellLayer.H" #include "patchToPoly2DMesh.H" #include "globalIndex.H" #include "IOdictionary.H" diff --git a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/extrude2DMesh/extrude2DMesh.C b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/extrude2DMesh/extrude2DMesh.C index 0e7096c2d0..c98b35747a 100644 --- a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/extrude2DMesh/extrude2DMesh.C +++ b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/extrude2DMesh/extrude2DMesh.C @@ -238,7 +238,6 @@ void Foam::extrude2DMesh::setRefinement ( newPoint, pointi + offset, - -1, // zoneID true // inCell ); } diff --git a/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C index 24ffb2aa05..f4e9207a6d 100644 --- a/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrudeMesh/extrudeMesh.C @@ -628,6 +628,8 @@ int main(int argc, char *argv[]) mesh ); + layerExtrude.updateZones(meshFromMesh()); + layerExtrude.topoChange ( map(), diff --git a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C index cf789edae8..825d0320d9 100644 --- a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C +++ b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C @@ -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]); + } } diff --git a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H index 1d055b577d..461d63bce9 100644 --- a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H +++ b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H @@ -66,6 +66,9 @@ class mergePolyMesh //- Point zone names DynamicList pointZoneNames_; + //- Zones of the added points + List pointZonesAddedPoints_; + //- Face zone names DynamicList faceZoneNames_; diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C index 77064e27e7..9e8164f244 100644 --- a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C +++ b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C @@ -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 ); diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/polyDualMesh.C b/applications/utilities/mesh/manipulation/polyDualMesh/polyDualMesh.C index 28d0a91b4e..c5158a1318 100644 --- a/applications/utilities/mesh/manipulation/polyDualMesh/polyDualMesh.C +++ b/applications/utilities/mesh/manipulation/polyDualMesh/polyDualMesh.C @@ -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 diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C index 8c7267cb08..61edceec72 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C @@ -24,12 +24,10 @@ License \*---------------------------------------------------------------------------*/ #include "cellZone.H" -#include "addToRunTimeSelectionTable.H" #include "meshCellZones.H" #include "polyMesh.H" -#include "primitiveMesh.H" -#include "IOstream.H" -#include "demandDrivenData.H" +#include "polyTopoChangeMap.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -130,6 +128,33 @@ bool Foam::cellZone::checkDefinition(const bool report) const } +void Foam::cellZone::topoChange(const polyTopoChangeMap& map) +{ + clearAddressing(); + + /* + labelList newAddressing(size()); + label nCells = 0; + + const labelList& cellMap = map.reverseCellMap(); + + forAll(*this, i) + { + const label celli = operator[](i); + + if (cellMap[celli] >= 0) + { + newAddressing[nCells] = cellMap[celli]; + nCells++; + } + } + + newAddressing.setSize(nCells); + transfer(newAddressing); + */ +} + + void Foam::cellZone::writeDict(Ostream& os) const { os << nl << name() << nl << token::BEGIN_BLOCK << nl diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H index a728f7d548..f7b3b490ec 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H @@ -200,6 +200,9 @@ public: return false; } + //- Update zone using the given map + virtual void topoChange(const polyTopoChangeMap& map); + //- Write dictionary virtual void writeDict(Ostream&) const; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C index 7e92f41284..4d38379168 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C @@ -24,14 +24,11 @@ License \*---------------------------------------------------------------------------*/ #include "faceZone.H" -#include "addToRunTimeSelectionTable.H" #include "meshFaceZones.H" #include "polyMesh.H" -#include "primitiveMesh.H" -#include "demandDrivenData.H" #include "polyTopoChangeMap.H" -#include "polyMeshMap.H" #include "syncTools.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -382,38 +379,6 @@ void Foam::faceZone::resetAddressing } -void Foam::faceZone::topoChange(const polyTopoChangeMap& map) -{ - clearAddressing(); - - /* - labelList newAddressing(size()); - boolList newFlipMap(flipMap_.size()); - label nFaces = 0; - - const labelList& faceMap = map.reverseFaceMap(); - - forAll(*this, i) - { - const label facei = operator[](i); - - if (faceMap[facei] >= 0) - { - newAddressing[nFaces] = faceMap[facei]; - newFlipMap[nFaces] = flipMap_[i]; // Keep flip map. - nFaces++; - } - } - - newAddressing.setSize(nFaces); - newFlipMap.setSize(nFaces); - - transfer(newAddressing); - flipMap_.transfer(newFlipMap); - */ -} - - bool Foam::faceZone::checkDefinition(const bool report) const { return zone::checkDefinition(meshZones().mesh().faces().size(), report); @@ -514,6 +479,38 @@ void Foam::faceZone::swap(faceZone& fz) } +void Foam::faceZone::topoChange(const polyTopoChangeMap& map) +{ + clearAddressing(); + + /* + labelList newAddressing(size()); + boolList newFlipMap(flipMap_.size()); + label nFaces = 0; + + const labelList& faceMap = map.reverseFaceMap(); + + forAll(*this, i) + { + const label facei = operator[](i); + + if (faceMap[facei] >= 0) + { + newAddressing[nFaces] = faceMap[facei]; + newFlipMap[nFaces] = flipMap_[i]; // Keep flip map. + nFaces++; + } + } + + newAddressing.setSize(nFaces); + newFlipMap.setSize(nFaces); + + transfer(newAddressing); + flipMap_.transfer(newFlipMap); + */ +} + + void Foam::faceZone::movePoints(const pointField& p) { if (patchPtr_) diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H index 9dab0e5b07..6058003782 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H @@ -283,7 +283,7 @@ public: //- Correct patch after moving points virtual void movePoints(const pointField&); - //- Update topology using the given map + //- Update zone using the given map virtual void topoChange(const polyTopoChangeMap&); //- Write diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C index e02e8c42f2..32c87364e2 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C @@ -24,12 +24,11 @@ License \*---------------------------------------------------------------------------*/ #include "pointZone.H" -#include "addToRunTimeSelectionTable.H" #include "meshPointZones.H" #include "polyMesh.H" -#include "primitiveMesh.H" -#include "demandDrivenData.H" +#include "polyTopoChangeMap.H" #include "syncTools.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -182,6 +181,31 @@ bool Foam::pointZone::checkParallelSync(const bool report) const } +void Foam::pointZone::topoChange(const polyTopoChangeMap& map) +{ + clearAddressing(); + + labelList newAddressing(size()); + label nPoints = 0; + + const labelList& pointMap = map.reversePointMap(); + + forAll(*this, i) + { + const label pointi = operator[](i); + + if (pointMap[pointi] >= 0) + { + newAddressing[nPoints] = pointMap[pointi]; + nPoints++; + } + } + + newAddressing.setSize(nPoints); + transfer(newAddressing); +} + + void Foam::pointZone::writeDict(Ostream& os) const { os << nl << name_ << nl << token::BEGIN_BLOCK << nl diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H index 29bc4d5ffe..65ed58e0cd 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H @@ -198,6 +198,9 @@ public: // true if in error. virtual bool checkParallelSync(const bool report = false) const; + //- Update zone using the given map + virtual void topoChange(const polyTopoChangeMap& map); + //- Write dictionary virtual void writeDict(Ostream&) const; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C index 325574d1a4..2dd6348d2f 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C @@ -220,20 +220,14 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const } -void Foam::zone::insert(const HashSet