From 24577907a1c5f6fd5d485b8d83efd663b64fb3c6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 4 Oct 2017 08:55:00 +0200 Subject: [PATCH] ENH: add faceZone::resetAddressing with constant flipMap - remove unused static variable, use updated hashtable methods --- .../mesh/manipulation/stitchMesh/stitchMesh.C | 160 ++++++++---------- .../meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C | 16 +- .../meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H | 8 +- .../polyMesh/zones/ZoneMesh/cellZoneMesh.H | 2 - .../polyMesh/zones/ZoneMesh/cellZoneMeshFwd.H | 2 +- .../polyMesh/zones/ZoneMesh/faceZoneMesh.H | 2 - .../polyMesh/zones/ZoneMesh/faceZoneMeshFwd.H | 2 +- .../polyMesh/zones/ZoneMesh/pointZoneMesh.H | 2 - .../zones/ZoneMesh/pointZoneMeshFwd.H | 2 +- .../meshes/polyMesh/zones/cellZone/cellZone.C | 1 + .../meshes/polyMesh/zones/cellZone/cellZone.H | 58 +++---- .../meshes/polyMesh/zones/faceZone/faceZone.C | 49 +++++- .../meshes/polyMesh/zones/faceZone/faceZone.H | 121 +++++++------ .../polyMesh/zones/pointZone/pointZone.C | 1 + .../polyMesh/zones/pointZone/pointZone.H | 49 +++--- .../meshes/polyMesh/zones/zone/zone.C | 34 ++-- .../meshes/polyMesh/zones/zone/zone.H | 30 ++-- 17 files changed, 281 insertions(+), 258 deletions(-) diff --git a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C index 1fa978d125..9723c1cdb7 100644 --- a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C +++ b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C @@ -76,100 +76,102 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -label addPointZone(const polyMesh& mesh, const word& name) +label addPointZone(polyMesh& mesh, const word& name) { - label zoneID = mesh.pointZones().findZoneID(name); + pointZoneMesh& zones = mesh.pointZones(); + label zoneID = zones.findZoneID(name); if (zoneID != -1) { - Info<< "Reusing existing pointZone " - << mesh.pointZones()[zoneID].name() + Info<< "Reusing existing pointZone " << zones[zoneID].name() << " at index " << zoneID << endl; - } - else - { - pointZoneMesh& pointZones = const_cast(mesh).pointZones(); - zoneID = pointZones.size(); - Info<< "Adding pointZone " << name << " at index " << zoneID << endl; - pointZones.setSize(zoneID+1); - pointZones.set - ( - zoneID, - new pointZone - ( - name, - labelList(0), - zoneID, - pointZones - ) - ); + 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(const polyMesh& mesh, const word& name) +label addFaceZone(polyMesh& mesh, const word& name) { - label zoneID = mesh.faceZones().findZoneID(name); + faceZoneMesh& zones = mesh.faceZones(); + label zoneID = zones.findZoneID(name); if (zoneID != -1) { - Info<< "Reusing existing faceZone " << mesh.faceZones()[zoneID].name() + Info<< "Reusing existing faceZone " << zones[zoneID].name() << " at index " << zoneID << endl; - } - else - { - faceZoneMesh& faceZones = const_cast(mesh).faceZones(); - zoneID = faceZones.size(); - Info<< "Adding faceZone " << name << " at index " << zoneID << endl; - faceZones.setSize(zoneID+1); - faceZones.set - ( - zoneID, - new faceZone - ( - name, - labelList(0), - boolList(), - zoneID, - faceZones - ) - ); + 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(const polyMesh& mesh, const word& name) +label addCellZone(polyMesh& mesh, const word& name) { - label zoneID = mesh.cellZones().findZoneID(name); + cellZoneMesh& zones = mesh.cellZones(); + label zoneID = zones.findZoneID(name); if (zoneID != -1) { - Info<< "Reusing existing cellZone " << mesh.cellZones()[zoneID].name() + Info<< "Reusing existing cellZone " << zones[zoneID].name() << " at index " << zoneID << endl; - } - else - { - cellZoneMesh& cellZones = const_cast(mesh).cellZones(); - zoneID = cellZones.size(); - Info<< "Adding cellZone " << name << " at index " << zoneID << endl; - cellZones.setSize(zoneID+1); - cellZones.set - ( - zoneID, - new cellZone - ( - name, - labelList(0), - zoneID, - cellZones - ) - ); + 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; } @@ -340,13 +342,9 @@ int main(int argc, char *argv[]) if (perfectCover) { // Add empty zone for resulting internal faces - label cutZoneID = addFaceZone(mesh, cutZoneName); + const label cutZoneID = addFaceZone(mesh, cutZoneName); - mesh.faceZones()[cutZoneID].resetAddressing - ( - isf, - boolList(masterPatch.size(), false) - ); + mesh.faceZones()[cutZoneID].resetAddressing(isf.xfer(), false); // Add the perfect interface mesh modifier stitcher.set @@ -370,11 +368,7 @@ int main(int argc, char *argv[]) label masterZoneID = addFaceZone(mesh, mergePatchName + "MasterZone"); - mesh.faceZones()[masterZoneID].resetAddressing - ( - isf, - boolList(masterPatch.size(), false) - ); + mesh.faceZones()[masterZoneID].resetAddressing(isf.xfer(), false); // Slave patch const polyPatch& slavePatch = mesh.boundaryMesh()[slavePatchName]; @@ -387,19 +381,11 @@ int main(int argc, char *argv[]) } label slaveZoneID = addFaceZone(mesh, mergePatchName + "SlaveZone"); - mesh.faceZones()[slaveZoneID].resetAddressing - ( - osf, - boolList(slavePatch.size(), false) - ); + mesh.faceZones()[slaveZoneID].resetAddressing(osf.xfer(), false); // Add empty zone for cut faces - label cutZoneID = addFaceZone(mesh, cutZoneName); - mesh.faceZones()[cutZoneID].resetAddressing - ( - labelList(0), - boolList(0, false) - ); + const label cutZoneID = addFaceZone(mesh, cutZoneName); + mesh.faceZones()[cutZoneID].resetAddressing(labelList(0), false); // Add the sliding interface mesh modifier diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C index 066c9c268f..9c67afde9b 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C @@ -247,17 +247,7 @@ Foam::label Foam::ZoneMesh::whichZone const label objectIndex ) const { - const Map