diff --git a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.H b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.H index 93a452a2e5..08d2abfee4 100644 --- a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.H +++ b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -89,13 +89,13 @@ public: } //- Mirrored to original cell - const labelList& cellMap() const + labelList& cellMap() { return cellMapPtr_(); } //- Mirrored to original point - const labelList& pointMap() const + labelList& pointMap() { return pointMapPtr_(); } diff --git a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorMesh.C b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorMesh.C index 3e4987fadf..9ad8293c91 100644 --- a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorMesh.C +++ b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorMesh.C @@ -100,23 +100,24 @@ int main(int argc, char *argv[]) polyTopoChangeMap map ( mesh, - mesh.nPoints(), // nOldPoints, - mesh.nFaces(), // nOldFaces, - mesh.nCells(), // nOldCells, - mesh.pointMap(), // pointMap, - List(0), // pointsFromPoints, - labelList(0), // faceMap, - List(0), // facesFromFaces, - mesh.cellMap(), // cellMap, - List(0), // cellsFromCells, - labelList(0), // reversePointMap, - labelList(0), // reverseFaceMap, - labelList(0), // reverseCellMap, - labelHashSet(0), // flipFaceFlux, - labelListList(0), // patchPointMap, - labelList(0), // oldPatchStarts, - labelList(0), // oldPatchNMeshPoints, - autoPtr() // oldCellVolumesPtr + mesh.nPoints(), // nOldPoints, + mesh.nFaces(), // nOldFaces, + mesh.nCells(), // nOldCells, + move(mesh.pointMap()), // pointMap, + move(List(0)), // pointsFromPoints, + move(labelList(0)), // faceMap, + move(List(0)), // facesFromFaces, + move(mesh.cellMap()), // cellMap, + move(List(0)), // cellsFromCells, + move(labelList(0)), // reversePointMap, + move(labelList(0)), // reverseFaceMap, + move(labelList(0)), // reverseCellMap, + move(labelHashSet(0)), // flipFaceFlux, + move(labelListList(0)), // patchPointMap, + move(labelList(0)), // oldPatchSizes, + move(labelList(0)), // oldPatchStarts, + move(labelList(0)), // oldPatchNMeshPoints, + move(autoPtr()) // oldCellVolumesPtr ); refData.topoChange(map); refData.write(); diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index 398bd7f381..a820efb868 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -391,8 +391,8 @@ labelList getRegionFaceOrder autoPtr reorderMesh ( polyMesh& mesh, - const labelList& cellOrder, - const labelList& faceOrder + labelList& cellOrder, + labelList& faceOrder ) { labelList reverseCellOrder(invert(cellOrder.size(), cellOrder)); @@ -506,24 +506,25 @@ autoPtr reorderMesh ( new polyTopoChangeMap ( - mesh, // const polyMesh& mesh, - mesh.nPoints(), // nOldPoints, - mesh.nFaces(), // nOldFaces, - mesh.nCells(), // nOldCells, - identityMap(mesh.nPoints()), // pointMap, - List(0), // pointsFromPoints, - faceOrder, // faceMap, - List(0), // facesFromFaces, - cellOrder, // cellMap, - List(0), // cellsFromCells, - identityMap(mesh.nPoints()), // reversePointMap, - reverseFaceOrder, // reverseFaceMap, - reverseCellOrder, // reverseCellMap, - flipFaceFlux, // flipFaceFlux, - patchPointMap, // patchPointMap, - patchStarts, // oldPatchStarts, - oldPatchNMeshPoints, // oldPatchNMeshPoints - autoPtr() // oldCellVolumes + mesh, // const polyMesh& mesh, + mesh.nPoints(), // nOldPoints, + mesh.nFaces(), // nOldFaces, + mesh.nCells(), // nOldCells, + identityMap(mesh.nPoints()), // pointMap, + List(0), // pointsFromPoints, + move(faceOrder), // faceMap, + List(0), // facesFromFaces, + move(cellOrder), // cellMap, + List(0), // cellsFromCells, + identityMap(mesh.nPoints()), // reversePointMap, + move(reverseFaceOrder), // reverseFaceMap, + move(reverseCellOrder), // reverseCellMap, + move(flipFaceFlux), // flipFaceFlux, + move(patchPointMap), // patchPointMap, + move(patchSizes), // oldPatchSizes + move(patchStarts), // oldPatchStarts, + move(oldPatchNMeshPoints), // oldPatchNMeshPoints + move(autoPtr()) // oldCellVolumes ) ); } diff --git a/src/OpenFOAM/meshes/polyMesh/polyTopoChangeMap/polyTopoChangeMap.C b/src/OpenFOAM/meshes/polyMesh/polyTopoChangeMap/polyTopoChangeMap.C index b3a4e3af67..8b10c5077e 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyTopoChangeMap/polyTopoChangeMap.C +++ b/src/OpenFOAM/meshes/polyMesh/polyTopoChangeMap/polyTopoChangeMap.C @@ -43,137 +43,43 @@ Foam::polyTopoChangeMap::polyTopoChangeMap const label nOldPoints, const label nOldFaces, const label nOldCells, - const labelList& pointMap, - const List& pointsFromPoints, - const labelList& faceMap, - const List& facesFromFaces, - const labelList& cellMap, - const List& cellsFromCells, - const labelList& reversePointMap, - const labelList& reverseFaceMap, - const labelList& reverseCellMap, - const labelHashSet& flipFaceFlux, - const labelListList& patchPointMap, - const labelList& oldPatchStarts, - const labelList& oldPatchNMeshPoints, - const autoPtr& oldCellVolumesPtr + labelList&& pointMap, + List&& pointsFromPoints, + labelList&& faceMap, + List&& facesFromFaces, + labelList&& cellMap, + List&& cellsFromCells, + labelList&& reversePointMap, + labelList&& reverseFaceMap, + labelList&& reverseCellMap, + labelHashSet&& flipFaceFlux, + labelListList&& patchPointMap, + labelList&& oldPatchSizes, + labelList&& oldPatchStarts, + labelList&& oldPatchNMeshPoints, + autoPtr&& oldCellVolumesPtr ) : mesh_(mesh), nOldPoints_(nOldPoints), nOldFaces_(nOldFaces), nOldCells_(nOldCells), - pointMap_(pointMap), - pointsFromPointsMap_(pointsFromPoints), - faceMap_(faceMap), - facesFromFacesMap_(facesFromFaces), - cellMap_(cellMap), - cellsFromCellsMap_(cellsFromCells), - reversePointMap_(reversePointMap), - reverseFaceMap_(reverseFaceMap), - reverseCellMap_(reverseCellMap), - flipFaceFlux_(flipFaceFlux), - patchPointMap_(patchPointMap), - oldPatchSizes_(oldPatchStarts.size()), - oldPatchStarts_(oldPatchStarts), - oldPatchNMeshPoints_(oldPatchNMeshPoints), - oldCellVolumesPtr_(oldCellVolumesPtr) -{ - if (oldPatchStarts_.size()) - { - // Calculate old patch sizes - for (label patchi = 0; patchi < oldPatchStarts_.size() - 1; patchi++) - { - oldPatchSizes_[patchi] = - oldPatchStarts_[patchi + 1] - oldPatchStarts_[patchi]; - } - - // Set the last one by hand - const label lastPatchID = oldPatchStarts_.size() - 1; - - oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID]; - - if (polyMesh::debug) - { - if (min(oldPatchSizes_) < 0) - { - FatalErrorInFunction - << abort(FatalError); - } - } - } -} - - -Foam::polyTopoChangeMap::polyTopoChangeMap -( - const polyMesh& mesh, - const label nOldPoints, - const label nOldFaces, - const label nOldCells, - labelList& pointMap, - List& pointsFromPoints, - labelList& faceMap, - List& facesFromFaces, - labelList& cellMap, - List& cellsFromCells, - labelList& reversePointMap, - labelList& reverseFaceMap, - labelList& reverseCellMap, - labelHashSet& flipFaceFlux, - labelListList& patchPointMap, - labelList& oldPatchStarts, - labelList& oldPatchNMeshPoints, - autoPtr& oldCellVolumesPtr, - const bool reuse -) -: - mesh_(mesh), - nOldPoints_(nOldPoints), - nOldFaces_(nOldFaces), - nOldCells_(nOldCells), - pointMap_(pointMap, reuse), - pointsFromPointsMap_(pointsFromPoints, reuse), - faceMap_(faceMap, reuse), - facesFromFacesMap_(facesFromFaces, reuse), - cellMap_(cellMap, reuse), - cellsFromCellsMap_(cellsFromCells, reuse), - reversePointMap_(reversePointMap, reuse), - reverseFaceMap_(reverseFaceMap, reuse), - reverseCellMap_(reverseCellMap, reuse), - flipFaceFlux_(flipFaceFlux), - patchPointMap_(patchPointMap, reuse), - oldPatchSizes_(oldPatchStarts.size()), - oldPatchStarts_(oldPatchStarts, reuse), - oldPatchNMeshPoints_(oldPatchNMeshPoints, reuse), - oldCellVolumesPtr_(oldCellVolumesPtr, reuse) -{ - if (oldPatchStarts_.size() > 0) - { - // Calculate old patch sizes - for (label patchi = 0; patchi < oldPatchStarts_.size() - 1; patchi++) - { - oldPatchSizes_[patchi] = - oldPatchStarts_[patchi + 1] - oldPatchStarts_[patchi]; - } - - // Set the last one by hand - const label lastPatchID = oldPatchStarts_.size() - 1; - - oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID]; - - if (polyMesh::debug) - { - if (min(oldPatchSizes_) < 0) - { - FatalErrorInFunction - << "Calculated negative old patch size." - << " Error in mapping data" - << abort(FatalError); - } - } - } -} + pointMap_(move(pointMap)), + pointsFromPointsMap_(move(pointsFromPoints)), + faceMap_(move(faceMap)), + facesFromFacesMap_(move(facesFromFaces)), + cellMap_(move(cellMap)), + cellsFromCellsMap_(move(cellsFromCells)), + reversePointMap_(move(reversePointMap)), + reverseFaceMap_(move(reverseFaceMap)), + reverseCellMap_(move(reverseCellMap)), + flipFaceFlux_(move(flipFaceFlux)), + patchPointMap_(move(patchPointMap)), + oldPatchSizes_(move(oldPatchSizes)), + oldPatchStarts_(move(oldPatchStarts)), + oldPatchNMeshPoints_(move(oldPatchNMeshPoints)), + oldCellVolumesPtr_(move(oldCellVolumesPtr)) +{} // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/polyTopoChangeMap/polyTopoChangeMap.H b/src/OpenFOAM/meshes/polyMesh/polyTopoChangeMap/polyTopoChangeMap.H index 867820bca7..f500196c50 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyTopoChangeMap/polyTopoChangeMap.H +++ b/src/OpenFOAM/meshes/polyMesh/polyTopoChangeMap/polyTopoChangeMap.H @@ -98,7 +98,6 @@ Description - appended: - cellMap[celli] contains -1 - SourceFiles polyTopoChangeMap.C @@ -187,7 +186,7 @@ class polyTopoChangeMap const labelListList patchPointMap_; //- List of the old patch sizes - labelList oldPatchSizes_; + const labelList oldPatchSizes_; //- List of the old patch start labels const labelList oldPatchStarts_; @@ -206,51 +205,28 @@ public: //- Construct from mesh only, no topology change polyTopoChangeMap(const polyMesh& mesh); - //- Construct from components. Copy (except for oldCellVolumes). + //- Construct from components reusing storage polyTopoChangeMap ( const polyMesh& mesh, const label nOldPoints, const label nOldFaces, const label nOldCells, - const labelList& pointMap, - const List& pointsFromPoints, - const labelList& faceMap, - const List& facesFromFaces, - const labelList& cellMap, - const List& cellsFromCells, - const labelList& reversePointMap, - const labelList& reverseFaceMap, - const labelList& reverseCellMap, - const labelHashSet& flipFaceFlux, - const labelListList& patchPointMap, - const labelList& oldPatchStarts, - const labelList& oldPatchNMeshPoints, - const autoPtr& oldCellVolumesPtr - ); - - //- Construct from components and optionally reuse storage - polyTopoChangeMap - ( - const polyMesh& mesh, - const label nOldPoints, - const label nOldFaces, - const label nOldCells, - labelList& pointMap, - List& pointsFromPoints, - labelList& faceMap, - List& facesFromFaces, - labelList& cellMap, - List& cellsFromCells, - labelList& reversePointMap, - labelList& reverseFaceMap, - labelList& reverseCellMap, - labelHashSet& flipFaceFlux, - labelListList& patchPointMap, - labelList& oldPatchStarts, - labelList& oldPatchNMeshPoints, - autoPtr& oldCellVolumesPtr, - const bool reuse + labelList&& pointMap, + List&& pointsFromPoints, + labelList&& faceMap, + List&& facesFromFaces, + labelList&& cellMap, + List&& cellsFromCells, + labelList&& reversePointMap, + labelList&& reverseFaceMap, + labelList&& reverseCellMap, + labelHashSet&& flipFaceFlux, + labelListList&& patchPointMap, + labelList&& oldPatchSizes, + labelList&& oldPatchStarts, + labelList&& oldPatchNMeshPoints, + autoPtr&& oldCellVolumesPtr ); //- Disallow default bitwise copy construction diff --git a/src/polyTopoChange/polyTopoChange/hexRef8/hexRef8Data.H b/src/polyTopoChange/polyTopoChange/hexRef8/hexRef8Data.H index ed613c123e..e8e13edacd 100644 --- a/src/polyTopoChange/polyTopoChange/hexRef8/hexRef8Data.H +++ b/src/polyTopoChange/polyTopoChange/hexRef8/hexRef8Data.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2015-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,9 +57,6 @@ class fvMesh; class hexRef8Data { - -private: - // Private Data autoPtr cellLevelPtr_; diff --git a/src/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/polyTopoChange/polyTopoChange/polyTopoChange.C index d58b2f267a..ea4970cb67 100644 --- a/src/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -1590,6 +1590,7 @@ void Foam::polyTopoChange::compactAndReorder List& cellsFromCells, List>& oldPatchMeshPointMaps, labelList& oldPatchNMeshPoints, + labelList& oldPatchSizes, labelList& oldPatchStarts, List>& oldMeshFaceZonesPointMaps ) @@ -1661,6 +1662,7 @@ void Foam::polyTopoChange::compactAndReorder // Grab patch mesh point maps oldPatchMeshPointMaps.setSize(boundary.size()); oldPatchNMeshPoints.setSize(boundary.size()); + oldPatchSizes.setSize(boundary.size()); oldPatchStarts.setSize(boundary.size()); forAll(boundary, patchi) @@ -1668,6 +1670,7 @@ void Foam::polyTopoChange::compactAndReorder // Copy old face zone point maps oldPatchMeshPointMaps[patchi] = boundary[patchi].meshPointMap(); oldPatchNMeshPoints[patchi] = boundary[patchi].meshPoints().size(); + oldPatchSizes[patchi] = boundary[patchi].size(); oldPatchStarts[patchi] = boundary[patchi].start(); } @@ -2223,18 +2226,23 @@ Foam::autoPtr Foam::polyTopoChange::changeMesh // new mesh points pointField newPoints; + // number of internal points label nInternalPoints; + // patch slicing labelList patchSizes; labelList patchStarts; + // maps List pointsFromPoints; List facesFromFaces; List cellsFromCells; + // old mesh info List> oldPatchMeshPointMaps; labelList oldPatchNMeshPoints; + labelList oldPatchSizes; labelList oldPatchStarts; List> oldMeshFaceZonesPointMaps; @@ -2255,6 +2263,7 @@ Foam::autoPtr Foam::polyTopoChange::changeMesh cellsFromCells, oldPatchMeshPointMaps, oldPatchNMeshPoints, + oldPatchSizes, oldPatchStarts, oldMeshFaceZonesPointMaps ); @@ -2372,29 +2381,28 @@ Foam::autoPtr Foam::polyTopoChange::changeMesh nOldFaces, nOldCells, - pointMap_, - pointsFromPoints, + move(pointMap_), + move(pointsFromPoints), - faceMap_, - facesFromFaces, + move(faceMap_), + move(facesFromFaces), - cellMap_, - cellsFromCells, + move(cellMap_), + move(cellsFromCells), - reversePointMap_, - reverseFaceMap_, - reverseCellMap_, + move(reversePointMap_), + move(reverseFaceMap_), + move(reverseCellMap_), - flipFaceFluxSet, + move(flipFaceFluxSet), - patchPointMap, + move(patchPointMap), - oldPatchStarts, - oldPatchNMeshPoints, + move(oldPatchSizes), + move(oldPatchStarts), + move(oldPatchNMeshPoints), - oldCellVolumes, - - true // steal storage. + move(oldCellVolumes) ) ); @@ -2442,6 +2450,7 @@ Foam::autoPtr Foam::polyTopoChange::makeMesh // old mesh info List> oldPatchMeshPointMaps; labelList oldPatchNMeshPoints; + labelList oldPatchSizes; labelList oldPatchStarts; List> oldMeshFaceZonesPointMaps; @@ -2462,6 +2471,7 @@ Foam::autoPtr Foam::polyTopoChange::makeMesh cellsFromCells, oldPatchMeshPointMaps, oldPatchNMeshPoints, + oldPatchSizes, oldPatchStarts, oldMeshFaceZonesPointMaps ); @@ -2560,7 +2570,7 @@ Foam::autoPtr Foam::polyTopoChange::makeMesh // Zones // ~~~~~ - // Start off from empty zones. + // Copy pointZone from old mesh const meshPointZones& oldPointZones = mesh.pointZones(); List pZonePtrs(oldPointZones.size()); { @@ -2570,6 +2580,7 @@ Foam::autoPtr Foam::polyTopoChange::makeMesh } } + // Start with empty faceZone const meshFaceZones& oldFaceZones = mesh.faceZones(); List fZonePtrs(oldFaceZones.size()); { @@ -2585,6 +2596,7 @@ Foam::autoPtr Foam::polyTopoChange::makeMesh } } + // Copy cellZone from old mesh const meshCellZones& oldCellZones = mesh.cellZones(); List cZonePtrs(oldCellZones.size()); { @@ -2635,27 +2647,28 @@ Foam::autoPtr Foam::polyTopoChange::makeMesh nOldFaces, nOldCells, - pointMap_, - pointsFromPoints, + move(pointMap_), + move(pointsFromPoints), - faceMap_, - facesFromFaces, + move(faceMap_), + move(facesFromFaces), - cellMap_, - cellsFromCells, + move(cellMap_), + move(cellsFromCells), - reversePointMap_, - reverseFaceMap_, - reverseCellMap_, + move(reversePointMap_), + move(reverseFaceMap_), + move(reverseCellMap_), - flipFaceFluxSet, + move(flipFaceFluxSet), - patchPointMap, + move(patchPointMap), - oldPatchStarts, - oldPatchNMeshPoints, - oldCellVolumes, - true // steal storage. + move(oldPatchSizes), + move(oldPatchStarts), + move(oldPatchNMeshPoints), + + move(oldCellVolumes) ) ); diff --git a/src/polyTopoChange/polyTopoChange/polyTopoChange.H b/src/polyTopoChange/polyTopoChange/polyTopoChange.H index 4e8244e8d4..efc4077781 100644 --- a/src/polyTopoChange/polyTopoChange/polyTopoChange.H +++ b/src/polyTopoChange/polyTopoChange/polyTopoChange.H @@ -364,6 +364,7 @@ class polyTopoChange List& cellsFromCells, List>& oldPatchMeshPointMaps, labelList& oldPatchNMeshPoints, + labelList& oldPatchSizes, labelList& oldPatchStarts, List>& oldMeshFaceZonesPointMaps );