mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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
This commit is contained in:
@ -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
|
||||
|
||||
@ -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)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -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())
|
||||
|
||||
@ -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<CloudType>::setPositions
|
||||
}
|
||||
|
||||
// Parallel operation manipulations
|
||||
const label myProci = UPstream::myProcNo();
|
||||
globalIndex globalPositions(positions.size());
|
||||
|
||||
List<vector> allPositions(globalPositions.totalSize(), point::max);
|
||||
List<label> allInjectorCells(globalPositions.totalSize(), -1);
|
||||
List<label> allInjectorTetFaces(globalPositions.totalSize(), -1);
|
||||
@ -116,8 +118,7 @@ void Foam::CellZoneInjection<CloudType>::setPositions
|
||||
SubList<vector>
|
||||
(
|
||||
allPositions,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.localStart(Pstream::myProcNo())
|
||||
globalPositions.range(myProci)
|
||||
) = positions;
|
||||
|
||||
Pstream::listCombineReduce(allPositions, minEqOp<point>());
|
||||
@ -126,20 +127,17 @@ void Foam::CellZoneInjection<CloudType>::setPositions
|
||||
SubList<label>
|
||||
(
|
||||
allInjectorCells,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.localStart(Pstream::myProcNo())
|
||||
globalPositions.range(myProci)
|
||||
) = injectorCells;
|
||||
SubList<label>
|
||||
(
|
||||
allInjectorTetFaces,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.localStart(Pstream::myProcNo())
|
||||
globalPositions.range(myProci)
|
||||
) = injectorTetFaces;
|
||||
SubList<label>
|
||||
(
|
||||
allInjectorTetPts,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.localStart(Pstream::myProcNo())
|
||||
globalPositions.range(myProci)
|
||||
) = injectorTetPts;
|
||||
|
||||
// Transfer data
|
||||
|
||||
@ -3437,11 +3437,12 @@ Foam::bitSet Foam::meshRefinement::getMasterPoints
|
||||
const labelList& meshPoints
|
||||
)
|
||||
{
|
||||
const label myProci = UPstream::myProcNo();
|
||||
const globalIndex globalPoints(meshPoints.size());
|
||||
|
||||
labelList myPoints
|
||||
(
|
||||
identity(globalPoints.localSize(), globalPoints.localStart())
|
||||
Foam::identity(globalPoints.range(myProci))
|
||||
);
|
||||
|
||||
syncTools::syncPointList
|
||||
@ -3457,7 +3458,7 @@ Foam::bitSet Foam::meshRefinement::getMasterPoints
|
||||
bitSet isPatchMasterPoint(meshPoints.size());
|
||||
forAll(meshPoints, pointi)
|
||||
{
|
||||
if (myPoints[pointi] == globalPoints.toGlobal(pointi))
|
||||
if (myPoints[pointi] == globalPoints.toGlobal(myProci, pointi))
|
||||
{
|
||||
isPatchMasterPoint.set(pointi);
|
||||
}
|
||||
@ -3473,11 +3474,12 @@ Foam::bitSet Foam::meshRefinement::getMasterEdges
|
||||
const labelList& meshEdges
|
||||
)
|
||||
{
|
||||
const label myProci = UPstream::myProcNo();
|
||||
const globalIndex globalEdges(meshEdges.size());
|
||||
|
||||
labelList myEdges
|
||||
(
|
||||
identity(globalEdges.localSize(), globalEdges.localStart())
|
||||
Foam::identity(globalEdges.range(myProci))
|
||||
);
|
||||
|
||||
syncTools::syncEdgeList
|
||||
@ -3493,7 +3495,7 @@ Foam::bitSet Foam::meshRefinement::getMasterEdges
|
||||
bitSet isMasterEdge(meshEdges.size());
|
||||
forAll(meshEdges, edgei)
|
||||
{
|
||||
if (myEdges[edgei] == globalEdges.toGlobal(edgei))
|
||||
if (myEdges[edgei] == globalEdges.toGlobal(myProci, edgei))
|
||||
{
|
||||
isMasterEdge.set(edgei);
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ void Foam::vtk::coordSetWriter::writeVerts()
|
||||
|
||||
/// label off =
|
||||
/// (
|
||||
/// parallel_ ? globalIndex(nLocalConns).localStart() : 0
|
||||
/// parallel_ ? globalIndex::calcOffset(nLocalConns) : 0
|
||||
/// );
|
||||
|
||||
auto iter = vertOffsets.begin();
|
||||
@ -356,7 +356,7 @@ void Foam::vtk::coordSetWriter::writeLines()
|
||||
|
||||
/// label off =
|
||||
/// (
|
||||
/// parallel_ ? globalIndex(nLocalConns).localStart() : 0
|
||||
/// parallel_ ? globalIndex::calcOffset(nLocalConns) : 0
|
||||
/// );
|
||||
|
||||
auto iter = vertOffsets.begin();
|
||||
@ -539,7 +539,7 @@ bool Foam::vtk::coordSetWriter::writeGeometry()
|
||||
|
||||
//const label pointOffset =
|
||||
//(
|
||||
// parallel_ ? globalIndex(nLocalPoints_).localStart() : 0
|
||||
// parallel_ ? globalIndex::calcOffset(nLocalPoints_) : 0
|
||||
//);
|
||||
|
||||
if (legacy())
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -262,7 +262,7 @@ void Foam::vtk::internalMeshWriter::writeCellsConnectivity
|
||||
// processor-local connectivity offsets
|
||||
const globalIndex procOffset
|
||||
(
|
||||
vertOffsets.empty() ? 0 : vertOffsets.last()
|
||||
vertOffsets.empty() ? 0 : vertOffsets.back()
|
||||
);
|
||||
|
||||
vtk::writeListParallel(format_.ref(), vertOffsets, procOffset);
|
||||
@ -431,17 +431,19 @@ void Foam::vtk::internalMeshWriter::writeCellsFaces
|
||||
const List<uint8_t>& cellTypes = vtuCells_.cellTypes();
|
||||
const label nLocalCells = cellTypes.size();
|
||||
|
||||
const globalIndex procOffset(faceLabels.size());
|
||||
// processor-local offsets for faceLabels
|
||||
const label labelsOffset =
|
||||
globalIndex::calcOffset(faceLabels.size());
|
||||
|
||||
labelList faceOffsetsRenumber;
|
||||
|
||||
if (faceOffsets.size()) // Or check procOffset.localSize()
|
||||
if (faceOffsets.size()) // Or check faceLabels.size()
|
||||
{
|
||||
faceOffsetsRenumber =
|
||||
vtk::vtuSizing::copyFaceOffsetsXml
|
||||
(
|
||||
faceOffsets,
|
||||
procOffset.localStart()
|
||||
labelsOffset
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -567,7 +569,7 @@ bool Foam::vtk::internalMeshWriter::writeGeometry()
|
||||
// Include addPointCellLabels for the point offsets
|
||||
const label pointOffset =
|
||||
(
|
||||
parallel_ ? globalIndex(vtuCells_.nFieldPoints()).localStart() : 0
|
||||
parallel_ ? globalIndex::calcOffset(vtuCells_.nFieldPoints()) : 0
|
||||
);
|
||||
|
||||
if (legacy())
|
||||
@ -670,13 +672,13 @@ void Foam::vtk::internalMeshWriter::writePointIDs()
|
||||
// Point offset for regular mesh points (without decomposed)
|
||||
const label pointOffset =
|
||||
(
|
||||
parallel_ ? globalIndex(vtuCells_.nPoints()).localStart() : 0
|
||||
parallel_ ? globalIndex::calcOffset(vtuCells_.nPoints()) : 0
|
||||
);
|
||||
|
||||
// Cell offset for *regular* mesh cells (without decomposed)
|
||||
const label cellOffset =
|
||||
(
|
||||
parallel_ ? globalIndex(vtuCells_.nCells()).localStart() : 0
|
||||
parallel_ ? globalIndex::calcOffset(vtuCells_.nCells()) : 0
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -312,7 +312,7 @@ void Foam::vtk::patchMeshWriter::writePolys(const label pointOffset)
|
||||
// processor-local connectivity offsets
|
||||
label off =
|
||||
(
|
||||
parallel_ ? globalIndex(nLocalPolyConn_).localStart() : 0
|
||||
parallel_ ? globalIndex::calcOffset(nLocalPolyConn_) : 0
|
||||
);
|
||||
|
||||
|
||||
@ -470,7 +470,7 @@ bool Foam::vtk::patchMeshWriter::writeGeometry()
|
||||
|
||||
const label pointOffset =
|
||||
(
|
||||
parallel_ ? globalIndex(nLocalPoints_).localStart() : 0
|
||||
parallel_ ? globalIndex::calcOffset(nLocalPoints_) : 0
|
||||
);
|
||||
|
||||
if (legacy())
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -112,7 +112,7 @@ bool Foam::vtk::writeCellSetFaces
|
||||
// processor-local cellID offset
|
||||
const label cellIdOffset =
|
||||
(
|
||||
writer.parallel() ? globalIndex(mesh.nCells()).localStart() : 0
|
||||
writer.parallel() ? globalIndex::calcOffset(mesh.nCells()) : 0
|
||||
);
|
||||
|
||||
forAll(faceValues, facei)
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -73,7 +73,7 @@ bool Foam::vtk::writeFaceSet
|
||||
// processor-local faceID offset
|
||||
const label faceIdOffset =
|
||||
(
|
||||
writer.parallel() ? globalIndex(mesh.nFaces()).localStart() : 0
|
||||
writer.parallel() ? globalIndex::calcOffset(mesh.nFaces()) : 0
|
||||
);
|
||||
|
||||
if (faceIdOffset)
|
||||
|
||||
@ -246,7 +246,7 @@ void Foam::cellCellStencil::globalCellCells
|
||||
|
||||
// 1. Determine global cell number on other side of coupled patches
|
||||
|
||||
labelList globalCellIDs(identity(gi.localSize(), gi.localStart()));
|
||||
labelList globalCellIDs(Foam::identity(gi.range()));
|
||||
|
||||
labelList nbrGlobalCellIDs;
|
||||
syncTools::swapBoundaryCellList
|
||||
|
||||
Reference in New Issue
Block a user