From 4ad52ea1087ee4da926ee27291e0bb92ce452409 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Wed, 27 Mar 2024 13:29:44 +0000 Subject: [PATCH] zones: General code clean-up and rationalisation to reduce duplication --- .../extrude2DMesh/extrude2DMesh.C | 5 +- .../createBaffles/createBaffles.C | 6 +- .../manipulation/mergeMeshes/mergePolyMesh.C | 17 ++---- .../foamToEnsight/ensightField.C | 8 +-- .../foamToEnsight/ensightMesh.C | 8 +-- .../PVReaders/vtkPVFoam/vtkPVFoamMesh.C | 2 +- .../vtkPVFoam/vtkPVFoamPointFields.H | 4 +- src/OpenFOAM/meshes/zones/Zone/Zone.C | 55 +++++++++++++++---- src/OpenFOAM/meshes/zones/Zone/Zone.H | 3 + src/OpenFOAM/meshes/zones/Zones/Zones.C | 23 ++++++++ src/OpenFOAM/meshes/zones/Zones/Zones.H | 3 + .../meshes/zones/cellZones/cellZone.C | 32 +---------- .../meshes/zones/cellZones/cellZone.H | 7 +-- .../meshes/zones/faceZones/faceZone.C | 20 +++---- .../meshes/zones/faceZones/faceZone.H | 5 +- .../meshes/zones/faceZones/faceZones.C | 19 +++++++ .../meshes/zones/faceZones/faceZones.H | 3 + .../meshes/zones/pointZones/pointZone.C | 32 +---------- .../meshes/zones/pointZones/pointZone.H | 7 +-- ...surfaceDisplacementPointPatchVectorField.C | 4 +- ...aceSlipDisplacementPointPatchVectorField.C | 4 +- .../FacePostProcessing/FacePostProcessing.C | 6 +- .../meshRefinement/meshRefinementBaffles.C | 5 +- .../displacementLayeredMotionMotionSolver.C | 4 +- .../parallel/domainDecompositionDecompose.C | 8 +-- .../polyTopoChange/addPatchCellLayer.C | 10 +--- .../polyTopoChange/edgeCollapser.C | 4 +- 27 files changed, 147 insertions(+), 157 deletions(-) diff --git a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/extrude2DMesh/extrude2DMesh.C b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/extrude2DMesh/extrude2DMesh.C index 9848fe6626..2ce07b0817 100644 --- a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/extrude2DMesh/extrude2DMesh.C +++ b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/extrude2DMesh/extrude2DMesh.C @@ -493,10 +493,7 @@ void Foam::extrude2DMesh::setRefinement void Foam::extrude2DMesh::updateZones() { // Add the cellZones to the merged mesh - forAll(cellZonesAddedCells_, zonei) - { - mesh_.cellZones()[zonei].insert(cellZonesAddedCells_[zonei]); - } + mesh_.cellZones().insert(cellZonesAddedCells_); } diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C index bd0f86d509..ba549d4fb4 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C +++ b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C @@ -190,7 +190,7 @@ label createFaces // Pass 1. Do selected side of zone for (label facei = 0; facei < mesh.nInternalFaces(); facei++) { - const label zoneFacei = fZone.whichFace(facei); + const label zoneFacei = fZone.localIndex(facei); if (zoneFacei != -1) { @@ -233,7 +233,7 @@ label createFaces // Pass 2. Do other side of zone for (label facei = 0; facei < mesh.nInternalFaces(); facei++) { - label zoneFacei = fZone.whichFace(facei); + label zoneFacei = fZone.localIndex(facei); if (zoneFacei != -1) { @@ -278,7 +278,7 @@ label createFaces forAll(pp, i) { const label facei = pp.start() + i; - const label zoneFacei = fZone.whichFace(facei); + const label zoneFacei = fZone.localIndex(facei); if (zoneFacei != -1) { diff --git a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C index da3730efef..4e6065ab93 100644 --- a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C +++ b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C @@ -342,7 +342,7 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m) forAll(zones, zonei) { const faceZone& fzi = fz[zones[zonei]]; - const bool flip = fzi.flipMap()[fzi.whichFace(facei)]; + const bool flip = fzi.flipMap()[fzi.localIndex(facei)]; faceZonesAddedFaces_[faceZoneIndices[zonei]] .insert(renumberFaces[facei], flip); @@ -499,22 +499,13 @@ void Foam::mergePolyMesh::merge() autoPtr map(meshMod_.changeMesh(mesh_)); // Add the new points to the pointZones in the merged mesh - forAll(pointZonesAddedPoints_, zonei) - { - mesh_.pointZones()[zonei].insert(pointZonesAddedPoints_[zonei]); - } + mesh_.pointZones().insert(pointZonesAddedPoints_); // Add the new faces to the faceZones in the merged mesh - forAll(faceZonesAddedFaces_, zonei) - { - mesh_.faceZones()[zonei].insert(faceZonesAddedFaces_[zonei]); - } + mesh_.faceZones().insert(faceZonesAddedFaces_); // Add the new cells to the cellZones in the merged mesh - forAll(cellZonesAddedCells_, zonei) - { - mesh_.cellZones()[zonei].insert(cellZonesAddedCells_[zonei]); - } + mesh_.cellZones().insert(cellZonesAddedCells_); mesh_.topoChange(map); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C index 962137f623..3d0a06a7e8 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C @@ -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 @@ -672,7 +672,7 @@ void ensightPointField const faceZone& fz = mesh.faceZones()[zoneID]; - if (returnReduce(fz().nPoints(), sumOp