From 7cfd053079fbedd0bd5426a36c048f098a02f852 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sat, 11 Nov 2023 12:20:39 +0100 Subject: [PATCH] ENH: use updated globalIndex methods - range(proci) instead of localStart(proci), localSize(proci) combination. * does the same thing, can be used directly with various other routines for slicing etc. Eg, Foam::identity(globalNumbering.range(myProci)) - globalIndex::calcOffset() instead of constructing a globalIndex and taking the localStart(). Avoids intermediate resizing and storing of an offsets table (which is then discarded) as well as the subsequent lookup into that table --- .../GAMGProcAgglomeration.C | 8 ++------ src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C | 6 ++++-- src/fileFormats/vtk/write/foamVtkPolyWriter.C | 10 +++++----- .../CellZoneInjection/CellZoneInjection.C | 16 +++++++--------- .../meshRefinement/meshRefinement.C | 10 ++++++---- .../writers/vtk/foamVtkCoordSetWriter.C | 6 +++--- .../vtk/mesh/foamVtkInternalMeshWriter.C | 18 ++++++++++-------- .../output/vtk/patch/foamVtkPatchMeshWriter.C | 4 ++-- .../vtk/topoSet/foamVtkWriteCellSetFaces.C | 4 ++-- .../output/vtk/topoSet/foamVtkWriteFaceSet.C | 4 ++-- .../cellCellStencil/cellCellStencil.C | 2 +- 11 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C index 519e5f9ef5..5d49a1bbeb 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C @@ -127,7 +127,7 @@ Foam::labelListList Foam::GAMGProcAgglomeration::globalCellCells const lduAddressing& addr = mesh.lduAddr(); lduInterfacePtrsList interfaces = mesh.interfaces(); - const label myProcID = UPstream::myProcNo(mesh.comm()); + const label myProci = UPstream::myProcNo(mesh.comm()); const globalIndex globalNumbering ( @@ -138,11 +138,7 @@ Foam::labelListList Foam::GAMGProcAgglomeration::globalCellCells const labelList globalIndices ( - identity - ( - globalNumbering.localSize(myProcID), - globalNumbering.localStart(myProcID) - ) + Foam::identity(globalNumbering.range(myProci)) ); // Get the interface cells diff --git a/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C b/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C index 935c20d370..e847072e24 100644 --- a/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C +++ b/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C @@ -105,12 +105,14 @@ Foam::labelListList Foam::lduPrimitiveMesh::globalCellCells const lduAddressing& addr = mesh.lduAddr(); lduInterfacePtrsList interfaces = mesh.interfaces(); + const label myProci = UPstream::myProcNo(mesh.comm()); + const labelList globalIndices ( - identity + Foam::identity ( addr.size(), - globalNumbering.localStart(UPstream::myProcNo(mesh.comm())) + globalNumbering.localStart(myProci) ) ); diff --git a/src/fileFormats/vtk/write/foamVtkPolyWriter.C b/src/fileFormats/vtk/write/foamVtkPolyWriter.C index ae303a4278..006bf0232c 100644 --- a/src/fileFormats/vtk/write/foamVtkPolyWriter.C +++ b/src/fileFormats/vtk/write/foamVtkPolyWriter.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -320,7 +320,7 @@ void Foam::vtk::polyWriter::writeLines // processor-local connectivity offsets label off = ( - parallel_ ? globalIndex(nLocalConns).localStart() : 0 + parallel_ ? globalIndex::calcOffset(nLocalConns) : 0 ); @@ -521,7 +521,7 @@ void Foam::vtk::polyWriter::writePolys // processor-local connectivity offsets label off = ( - parallel_ ? globalIndex(nLocalConns).localStart() : 0 + parallel_ ? globalIndex::calcOffset(nLocalConns) : 0 ); @@ -632,7 +632,7 @@ bool Foam::vtk::polyWriter::writeLineGeometry const label pointOffset = ( - parallel_ ? globalIndex(nLocalPoints_).localStart() : 0 + parallel_ ? globalIndex::calcOffset(nLocalPoints_) : 0 ); if (legacy()) @@ -662,7 +662,7 @@ bool Foam::vtk::polyWriter::writePolyGeometry const label pointOffset = ( - parallel_ ? globalIndex(nLocalPoints_).localStart() : 0 + parallel_ ? globalIndex::calcOffset(nLocalPoints_) : 0 ); if (legacy()) diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/CellZoneInjection/CellZoneInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/CellZoneInjection/CellZoneInjection.C index 4993effd61..5ee1a9e6ff 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/CellZoneInjection/CellZoneInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/CellZoneInjection/CellZoneInjection.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2022 OpenCFD Ltd. + Copyright (C) 2015-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -106,7 +106,9 @@ void Foam::CellZoneInjection::setPositions } // Parallel operation manipulations + const label myProci = UPstream::myProcNo(); globalIndex globalPositions(positions.size()); + List allPositions(globalPositions.totalSize(), point::max); List