ENH: additional parRun selection/protection on syncTools
- allow more control over using parallel communication or not.
This commit is contained in:
parent
6d69506294
commit
a431e0fe9a
@ -84,7 +84,10 @@ static void calcCellCellsImpl
|
||||
globalNeighbour[bfacei] = val;
|
||||
}
|
||||
}
|
||||
syncTools::swapBoundaryFaceList(mesh, globalNeighbour);
|
||||
|
||||
// Swap boundary neighbour information:
|
||||
// - cyclics and (optionally) processor
|
||||
syncTools::swapBoundaryFaceList(mesh, globalNeighbour, parallel);
|
||||
|
||||
|
||||
// Count number of faces (internal + coupled)
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -34,34 +34,34 @@ void Foam::syncTools::swapBoundaryCellPositions
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const UList<point>& cellData,
|
||||
List<point>& neighbourCellData
|
||||
List<point>& neighbourCellData,
|
||||
const bool parRun
|
||||
)
|
||||
{
|
||||
if (cellData.size() != mesh.nCells())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of cell values " << cellData.size()
|
||||
<< " is not equal to the number of cells in the mesh "
|
||||
<< mesh.nCells() << abort(FatalError);
|
||||
<< "Number of values " << cellData.size()
|
||||
<< " != number of cells " << mesh.nCells() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
neighbourCellData.resize(mesh.nBoundaryFaces());
|
||||
|
||||
for (const polyPatch& pp : patches)
|
||||
for (const polyPatch& pp : mesh.boundaryMesh())
|
||||
{
|
||||
label bFacei = pp.start()-mesh.nInternalFaces();
|
||||
const auto& faceCells = pp.faceCells();
|
||||
|
||||
const labelUList& faceCells = pp.faceCells();
|
||||
|
||||
for (const label celli : faceCells)
|
||||
{
|
||||
neighbourCellData[bFacei] = cellData[celli];
|
||||
++bFacei;
|
||||
}
|
||||
// ie, boundarySlice() = patchInternalList()
|
||||
SubList<point>
|
||||
(
|
||||
neighbourCellData,
|
||||
faceCells.size(),
|
||||
pp.offset()
|
||||
) = UIndirectList<point>(cellData, faceCells);
|
||||
}
|
||||
syncTools::swapBoundaryFacePositions(mesh, neighbourCellData);
|
||||
|
||||
syncTools::swapBoundaryFacePositions(mesh, neighbourCellData, parRun);
|
||||
}
|
||||
|
||||
|
||||
@ -127,9 +127,7 @@ Foam::bitSet Foam::syncTools::getMasterFaces(const polyMesh& mesh)
|
||||
{
|
||||
bitSet isMaster(mesh.nFaces(), true);
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
for (const polyPatch& pp : patches)
|
||||
for (const polyPatch& pp : mesh.boundaryMesh())
|
||||
{
|
||||
if (pp.coupled())
|
||||
{
|
||||
@ -151,9 +149,7 @@ Foam::bitSet Foam::syncTools::getInternalOrMasterFaces
|
||||
{
|
||||
bitSet isMaster(mesh.nFaces(), true);
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
for (const polyPatch& pp : patches)
|
||||
for (const polyPatch& pp : mesh.boundaryMesh())
|
||||
{
|
||||
if (pp.coupled())
|
||||
{
|
||||
@ -179,9 +175,7 @@ Foam::bitSet Foam::syncTools::getInternalOrCoupledFaces
|
||||
{
|
||||
bitSet isMaster(mesh.nFaces(), true);
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
for (const polyPatch& pp : patches)
|
||||
for (const polyPatch& pp : mesh.boundaryMesh())
|
||||
{
|
||||
if (!pp.coupled())
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -69,6 +69,7 @@ class syncTools
|
||||
// Private Member Functions
|
||||
|
||||
//- Combine val with existing value in pointValues map at given index
|
||||
// No communication
|
||||
template<class T, class CombineOp>
|
||||
static void combine
|
||||
(
|
||||
@ -79,6 +80,7 @@ class syncTools
|
||||
);
|
||||
|
||||
//- Combine val with existing value in edgeValues at edge index
|
||||
// No communication
|
||||
template<class T, class CombineOp>
|
||||
static void combine
|
||||
(
|
||||
@ -95,6 +97,7 @@ public:
|
||||
// Preferably use specialisations below.
|
||||
|
||||
//- Synchronize values on selected points.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class T, class CombineOp, class TransformOp>
|
||||
static void syncPointMap
|
||||
(
|
||||
@ -105,6 +108,7 @@ public:
|
||||
);
|
||||
|
||||
//- Synchronize values on selected edges.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class T, class CombineOp, class TransformOp>
|
||||
static void syncEdgeMap
|
||||
(
|
||||
@ -115,6 +119,7 @@ public:
|
||||
);
|
||||
|
||||
//- Synchronize values on all mesh points.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class T, class CombineOp, class TransformOp>
|
||||
static void syncPointList
|
||||
(
|
||||
@ -126,6 +131,7 @@ public:
|
||||
);
|
||||
|
||||
//- Synchronize values on selected mesh points.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class T, class CombineOp, class TransformOp>
|
||||
static void syncPointList
|
||||
(
|
||||
@ -138,6 +144,7 @@ public:
|
||||
);
|
||||
|
||||
//- Synchronize values on all mesh edges.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class T, class CombineOp, class TransformOp, class FlipOp>
|
||||
static void syncEdgeList
|
||||
(
|
||||
@ -150,11 +157,12 @@ public:
|
||||
);
|
||||
|
||||
//- Synchronize values on selected mesh edges.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class T, class CombineOp, class TransformOp, class FlipOp>
|
||||
static void syncEdgeList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& meshEdges,
|
||||
const labelUList& meshEdges,
|
||||
List<T>& edgeValues,
|
||||
const CombineOp& cop,
|
||||
const T& nullValue,
|
||||
@ -170,6 +178,7 @@ public:
|
||||
UList<T>& faceValues,
|
||||
const CombineOp& cop,
|
||||
const TransformOp& top,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
);
|
||||
|
||||
@ -177,6 +186,7 @@ public:
|
||||
// Synchronise point-wise data
|
||||
|
||||
//- Synchronize values on all mesh points.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class T, class CombineOp>
|
||||
static void syncPointList
|
||||
(
|
||||
@ -197,6 +207,7 @@ public:
|
||||
}
|
||||
|
||||
//- Synchronize locations on all mesh points.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class CombineOp>
|
||||
static void syncPointPositions
|
||||
(
|
||||
@ -217,11 +228,12 @@ public:
|
||||
}
|
||||
|
||||
//- Synchronize values on selected mesh points.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class T, class CombineOp>
|
||||
static void syncPointList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& meshPoints,
|
||||
const labelUList& meshPoints,
|
||||
List<T>& pointValues,
|
||||
const CombineOp& cop,
|
||||
const T& nullValue
|
||||
@ -239,11 +251,12 @@ public:
|
||||
}
|
||||
|
||||
//- Synchronize locations on selected mesh points.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class CombineOp>
|
||||
static void syncPointPositions
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& meshPoints,
|
||||
const labelUList& meshPoints,
|
||||
List<point>& positions,
|
||||
const CombineOp& cop,
|
||||
const point& nullValue
|
||||
@ -264,6 +277,7 @@ public:
|
||||
// Synchronise edge-wise data
|
||||
|
||||
//- Synchronize values on all mesh edges.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class T, class CombineOp>
|
||||
static void syncEdgeList
|
||||
(
|
||||
@ -285,6 +299,7 @@ public:
|
||||
}
|
||||
|
||||
//- Synchronize locations on all mesh edges.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class CombineOp>
|
||||
static void syncEdgePositions
|
||||
(
|
||||
@ -306,11 +321,12 @@ public:
|
||||
}
|
||||
|
||||
//- Synchronize values on selected mesh edges.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class T, class CombineOp>
|
||||
static void syncEdgeList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& meshEdges,
|
||||
const labelUList& meshEdges,
|
||||
List<T>& edgeValues,
|
||||
const CombineOp& cop,
|
||||
const T& nullValue
|
||||
@ -329,11 +345,12 @@ public:
|
||||
}
|
||||
|
||||
//- Synchronize locations on selected mesh edges.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class CombineOp>
|
||||
static void syncEdgePositions
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& meshEdges,
|
||||
const labelUList& meshEdges,
|
||||
List<point>& positions,
|
||||
const CombineOp& cop,
|
||||
const point& nullValue
|
||||
@ -397,7 +414,9 @@ public:
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
UList<T>& faceValues,
|
||||
const CombineOp& cop
|
||||
const CombineOp& cop,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
)
|
||||
{
|
||||
SubList<T> bndValues
|
||||
@ -412,7 +431,8 @@ public:
|
||||
mesh,
|
||||
bndValues,
|
||||
cop,
|
||||
mapDistribute::transform()
|
||||
mapDistribute::transform(),
|
||||
parRun
|
||||
);
|
||||
}
|
||||
|
||||
@ -422,7 +442,9 @@ public:
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
UList<point>& positions,
|
||||
const CombineOp& cop
|
||||
const CombineOp& cop,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
)
|
||||
{
|
||||
SubList<point> bndValues
|
||||
@ -436,7 +458,8 @@ public:
|
||||
mesh,
|
||||
bndValues,
|
||||
cop,
|
||||
mapDistribute::transformPosition()
|
||||
mapDistribute::transformPosition(),
|
||||
parRun
|
||||
);
|
||||
}
|
||||
|
||||
@ -445,7 +468,9 @@ public:
|
||||
static void swapBoundaryFaceList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
UList<T>& faceValues
|
||||
UList<T>& faceValues,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
)
|
||||
{
|
||||
syncBoundaryFaceList
|
||||
@ -453,7 +478,8 @@ public:
|
||||
mesh,
|
||||
faceValues,
|
||||
eqOp<T>(),
|
||||
mapDistribute::transform()
|
||||
mapDistribute::transform(),
|
||||
parRun
|
||||
);
|
||||
}
|
||||
|
||||
@ -461,7 +487,9 @@ public:
|
||||
static void swapBoundaryFacePositions
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
UList<point>& positions
|
||||
UList<point>& positions,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
)
|
||||
{
|
||||
syncBoundaryFaceList
|
||||
@ -469,7 +497,8 @@ public:
|
||||
mesh,
|
||||
positions,
|
||||
eqOp<point>(),
|
||||
mapDistribute::transformPosition()
|
||||
mapDistribute::transformPosition(),
|
||||
parRun
|
||||
);
|
||||
}
|
||||
|
||||
@ -478,7 +507,9 @@ public:
|
||||
static void swapFaceList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
UList<T>& faceValues
|
||||
UList<T>& faceValues,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
)
|
||||
{
|
||||
SubList<T> bndValues
|
||||
@ -492,31 +523,71 @@ public:
|
||||
mesh,
|
||||
bndValues,
|
||||
eqOp<T>(),
|
||||
mapDistribute::transform()
|
||||
mapDistribute::transform(),
|
||||
parRun
|
||||
);
|
||||
}
|
||||
|
||||
//- Swap to obtain neighbour cell values for all boundary faces
|
||||
//- Extract and swap to obtain neighbour cell values
|
||||
//- for all boundary faces
|
||||
template<class T>
|
||||
static void swapBoundaryCellList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const UList<T>& cellData,
|
||||
List<T>& neighbourCellData
|
||||
List<T>& neighbourCellData,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
);
|
||||
|
||||
//- Swap to obtain neighbour cell positions for all boundary faces
|
||||
//- Extract and swap to obtain neighbour cell positions
|
||||
//- for all boundary faces
|
||||
static void swapBoundaryCellPositions
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const UList<point>& cellData,
|
||||
List<point>& neighbourCellData
|
||||
List<point>& neighbourCellData,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
);
|
||||
|
||||
|
||||
//- Return neighbour cell values for all boundary faces
|
||||
//- by swapping via boundary faces
|
||||
template<class T>
|
||||
static List<T> swapBoundaryCellList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const UList<T>& cellData,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
) FOAM_NODISCARD
|
||||
{
|
||||
List<T> nbrCellData;
|
||||
swapBoundaryCellList(mesh, cellData, nbrCellData, parRun);
|
||||
return nbrCellData;
|
||||
}
|
||||
|
||||
//- Return neighbour cell positions for all boundary faces
|
||||
//- by swapping via boundary faces
|
||||
static List<point> swapBoundaryCellPositions
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const UList<point>& cellData,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
) FOAM_NODISCARD
|
||||
{
|
||||
List<point> nbrCellData;
|
||||
swapBoundaryCellPositions(mesh, cellData, nbrCellData, parRun);
|
||||
return nbrCellData;
|
||||
}
|
||||
|
||||
|
||||
// Sparse versions
|
||||
|
||||
//- Synchronize values on selected points.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class T, class CombineOp>
|
||||
static void syncPointMap
|
||||
(
|
||||
@ -535,6 +606,7 @@ public:
|
||||
}
|
||||
|
||||
//- Synchronize locations on selected points.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class CombineOp>
|
||||
static void syncPointPositions
|
||||
(
|
||||
@ -552,9 +624,10 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
//- Synchronize values on selected edges. Edges are represented
|
||||
// by the two vertices that make it up so global edges never get
|
||||
// constructed.
|
||||
//- Synchronize values on selected edges.
|
||||
//- Edges are represented by the two vertices that make it up
|
||||
//- so global edges never get constructed.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class T, class CombineOp>
|
||||
static void syncEdgeMap
|
||||
(
|
||||
@ -573,6 +646,7 @@ public:
|
||||
}
|
||||
|
||||
//- Synchronize locations on selected edges.
|
||||
// Communication if UPstream::parRun() == true.
|
||||
template<class CombineOp>
|
||||
static void syncEdgePositions
|
||||
(
|
||||
@ -601,7 +675,7 @@ public:
|
||||
// offset when accessing values.
|
||||
// \param faceValues The face values to synchronize
|
||||
// \param cop The combine operation
|
||||
// \param parRun True if this is a parallel simulation
|
||||
// \param parRun Allow parallel communication
|
||||
template<unsigned Width, class CombineOp>
|
||||
static void syncFaceList
|
||||
(
|
||||
@ -619,6 +693,7 @@ public:
|
||||
const polyMesh& mesh,
|
||||
PackedList<Width>& faceValues,
|
||||
const CombineOp& cop,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
);
|
||||
|
||||
@ -629,6 +704,7 @@ public:
|
||||
const polyMesh& mesh,
|
||||
PackedList<Width>& faceValues,
|
||||
const CombineOp& cop,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
);
|
||||
|
||||
@ -637,7 +713,9 @@ public:
|
||||
static void swapFaceList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
PackedList<Width>& faceValues
|
||||
PackedList<Width>& faceValues,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
);
|
||||
|
||||
//- Swap coupled boundary face values. Uses eqOp
|
||||
@ -645,7 +723,9 @@ public:
|
||||
static void swapBoundaryFaceList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
PackedList<Width>& faceValues
|
||||
PackedList<Width>& faceValues,
|
||||
//! Allow parallel communication
|
||||
const bool parRun = UPstream::parRun()
|
||||
);
|
||||
|
||||
template<unsigned Width, class CombineOp>
|
||||
|
@ -79,6 +79,8 @@ void Foam::syncTools::combine
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class CombineOp, class TransformOp>
|
||||
void Foam::syncTools::syncPointMap
|
||||
(
|
||||
@ -488,7 +490,7 @@ void Foam::syncTools::syncEdgeMap
|
||||
forAllConstIters(nbrPatchInfo, nbrIter)
|
||||
{
|
||||
const edge& e = nbrIter.key();
|
||||
const edge meshEdge(meshPts[e[0]], meshPts[e[1]]);
|
||||
const edge meshEdge(meshPts, e);
|
||||
|
||||
combine
|
||||
(
|
||||
@ -535,7 +537,7 @@ void Foam::syncTools::syncEdgeMap
|
||||
|
||||
{
|
||||
const edge& e0 = edgesA[twoEdges[0]];
|
||||
const edge meshEdge0(meshPtsA[e0[0]], meshPtsA[e0[1]]);
|
||||
const edge meshEdge0(meshPtsA, e0);
|
||||
|
||||
const auto iter = edgeValues.cfind(meshEdge0);
|
||||
|
||||
@ -546,7 +548,7 @@ void Foam::syncTools::syncEdgeMap
|
||||
}
|
||||
{
|
||||
const edge& e1 = edgesB[twoEdges[1]];
|
||||
const edge meshEdge1(meshPtsB[e1[0]], meshPtsB[e1[1]]);
|
||||
const edge meshEdge1(meshPtsB, e1);
|
||||
|
||||
const auto iter = edgeValues.cfind(meshEdge1);
|
||||
|
||||
@ -573,7 +575,7 @@ void Foam::syncTools::syncEdgeMap
|
||||
if (half1Fnd.good())
|
||||
{
|
||||
const edge& e0 = edgesA[twoEdges[0]];
|
||||
const edge meshEdge0(meshPtsA[e0[0]], meshPtsA[e0[1]]);
|
||||
const edge meshEdge0(meshPtsA, e0);
|
||||
|
||||
combine
|
||||
(
|
||||
@ -589,7 +591,7 @@ void Foam::syncTools::syncEdgeMap
|
||||
if (half0Fnd.good())
|
||||
{
|
||||
const edge& e1 = edgesB[twoEdges[1]];
|
||||
const edge meshEdge1(meshPtsB[e1[0]], meshPtsB[e1[1]]);
|
||||
const edge meshEdge1(meshPtsB, e1);
|
||||
|
||||
combine
|
||||
(
|
||||
@ -749,8 +751,8 @@ void Foam::syncTools::syncPointList
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of values " << pointValues.size()
|
||||
<< " is not equal to the number of points in the mesh "
|
||||
<< mesh.nPoints() << abort(FatalError);
|
||||
<< " != number of points " << mesh.nPoints() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
mesh.globalData().syncPointData(pointValues, cop, top);
|
||||
@ -772,8 +774,8 @@ void Foam::syncTools::syncPointList
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of values " << pointValues.size()
|
||||
<< " is not equal to the number of meshPoints "
|
||||
<< meshPoints.size() << abort(FatalError);
|
||||
<< " != number of meshPoints " << meshPoints.size() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
const globalMeshData& gd = mesh.globalData();
|
||||
const indirectPrimitivePatch& cpp = gd.coupledPatch();
|
||||
@ -829,8 +831,8 @@ void Foam::syncTools::syncEdgeList
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of values " << edgeValues.size()
|
||||
<< " is not equal to the number of edges in the mesh "
|
||||
<< mesh.nEdges() << abort(FatalError);
|
||||
<< " != number of edges " << mesh.nEdges() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const edgeList& edges = mesh.edges();
|
||||
@ -915,7 +917,7 @@ template<class T, class CombineOp, class TransformOp, class FlipOp>
|
||||
void Foam::syncTools::syncEdgeList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& meshEdges,
|
||||
const labelUList& meshEdges,
|
||||
List<T>& edgeValues,
|
||||
const CombineOp& cop,
|
||||
const T& nullValue,
|
||||
@ -927,8 +929,8 @@ void Foam::syncTools::syncEdgeList
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of values " << edgeValues.size()
|
||||
<< " is not equal to the number of meshEdges "
|
||||
<< meshEdges.size() << abort(FatalError);
|
||||
<< " != number of meshEdges " << meshEdges.size() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
const edgeList& edges = mesh.edges();
|
||||
const globalMeshData& gd = mesh.globalData();
|
||||
@ -946,7 +948,7 @@ void Foam::syncTools::syncEdgeList
|
||||
const auto iter = mpm.cfind(meshEdgei);
|
||||
if (iter.good())
|
||||
{
|
||||
const label cppEdgei = iter();
|
||||
const label cppEdgei = iter.val();
|
||||
const edge& cppE = cppEdges[cppEdgei];
|
||||
const edge& meshE = edges[meshEdgei];
|
||||
|
||||
@ -992,7 +994,7 @@ void Foam::syncTools::syncEdgeList
|
||||
const auto iter = mpm.cfind(meshEdgei);
|
||||
if (iter.good())
|
||||
{
|
||||
label cppEdgei = iter();
|
||||
label cppEdgei = iter.val();
|
||||
const edge& cppE = cppEdges[cppEdgei];
|
||||
const edge& meshE = edges[meshEdgei];
|
||||
|
||||
@ -1029,14 +1031,13 @@ void Foam::syncTools::syncBoundaryFaceList
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of values " << faceValues.size()
|
||||
<< " is not equal to the number of boundary faces in the mesh "
|
||||
<< mesh.nBoundaryFaces() << nl
|
||||
<< " != number of boundary faces " << mesh.nBoundaryFaces() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
if (parRun)
|
||||
if (parRun && UPstream::parRun())
|
||||
{
|
||||
// Avoid mesh.globalData() - possible race condition
|
||||
|
||||
@ -1104,7 +1105,7 @@ void Foam::syncTools::syncBoundaryFaceList
|
||||
}
|
||||
|
||||
// Wait for all comms to finish
|
||||
Pstream::waitRequests(startRequest);
|
||||
UPstream::waitRequests(startRequest);
|
||||
|
||||
// Combine with existing data
|
||||
for (const polyPatch& pp : patches)
|
||||
@ -1274,20 +1275,20 @@ void Foam::syncTools::syncFaceList
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of values " << faceValues.size()
|
||||
<< " is not equal to the number of "
|
||||
<< " != number of "
|
||||
<< (isBoundaryOnly ? "boundary" : "mesh") << " faces "
|
||||
<< ((mesh.nFaces() - boundaryOffset)) << nl
|
||||
<< (mesh.nFaces() - boundaryOffset) << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
if (parRun)
|
||||
if (parRun && UPstream::parRun())
|
||||
{
|
||||
const label startRequest = UPstream::nRequests();
|
||||
|
||||
// Receive buffers
|
||||
PtrList<PackedList<Width>> recvInfos(patches.size());
|
||||
PtrList<PackedList<Width>> recvBufs(patches.size());
|
||||
|
||||
// Set up reads
|
||||
for (const polyPatch& pp : patches)
|
||||
@ -1298,23 +1299,21 @@ void Foam::syncTools::syncFaceList
|
||||
{
|
||||
const auto& procPatch = *ppp;
|
||||
const label patchi = pp.index();
|
||||
const label patchSize = pp.size();
|
||||
|
||||
recvInfos.set(patchi, new PackedList<Width>(patchSize));
|
||||
PackedList<Width>& recvInfo = recvInfos[patchi];
|
||||
auto& recvbuf = recvBufs.emplace_set(patchi, pp.size());
|
||||
|
||||
UIPstream::read
|
||||
(
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
procPatch.neighbProcNo(),
|
||||
recvInfo.data_bytes(),
|
||||
recvInfo.size_bytes()
|
||||
recvbuf.data_bytes(),
|
||||
recvbuf.size_bytes()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Send buffers
|
||||
PtrList<PackedList<Width>> sendInfos(patches.size());
|
||||
PtrList<PackedList<Width>> sendBufs(patches.size());
|
||||
|
||||
// Set up writes
|
||||
for (const polyPatch& pp : patches)
|
||||
@ -1326,24 +1325,16 @@ void Foam::syncTools::syncFaceList
|
||||
const auto& procPatch = *ppp;
|
||||
const label patchi = pp.index();
|
||||
|
||||
const labelRange range
|
||||
(
|
||||
pp.start()-boundaryOffset,
|
||||
pp.size()
|
||||
);
|
||||
sendInfos.set
|
||||
(
|
||||
patchi,
|
||||
new PackedList<Width>(faceValues, range)
|
||||
);
|
||||
PackedList<Width>& sendInfo = sendInfos[patchi];
|
||||
const labelRange range(pp.start()-boundaryOffset, pp.size());
|
||||
|
||||
auto& sendbuf = sendBufs.emplace_set(patchi, faceValues, range);
|
||||
|
||||
UOPstream::write
|
||||
(
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
procPatch.neighbProcNo(),
|
||||
sendInfo.cdata_bytes(),
|
||||
sendInfo.size_bytes()
|
||||
sendbuf.cdata_bytes(),
|
||||
sendbuf.size_bytes()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1361,13 +1352,13 @@ void Foam::syncTools::syncFaceList
|
||||
const label patchi = pp.index();
|
||||
const label patchSize = pp.size();
|
||||
|
||||
const PackedList<Width>& recvInfo = recvInfos[patchi];
|
||||
const auto& recvbuf = recvBufs[patchi];
|
||||
|
||||
// Combine (bitwise)
|
||||
label bFacei = pp.start()-boundaryOffset;
|
||||
for (label i = 0; i < patchSize; ++i)
|
||||
{
|
||||
unsigned int recvVal = recvInfo[i];
|
||||
unsigned int recvVal = recvbuf[i];
|
||||
unsigned int faceVal = faceValues[bFacei];
|
||||
|
||||
cop(faceVal, recvVal);
|
||||
@ -1420,15 +1411,16 @@ void Foam::syncTools::swapBoundaryCellList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const UList<T>& cellData,
|
||||
List<T>& neighbourCellData
|
||||
List<T>& neighbourCellData,
|
||||
const bool parRun
|
||||
)
|
||||
{
|
||||
if (cellData.size() != mesh.nCells())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of cell values " << cellData.size()
|
||||
<< " is not equal to the number of cells in the mesh "
|
||||
<< mesh.nCells() << abort(FatalError);
|
||||
<< " != number of cells " << mesh.nCells() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
@ -1437,15 +1429,18 @@ void Foam::syncTools::swapBoundaryCellList
|
||||
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
label bFacei = pp.offset();
|
||||
const auto& faceCells = pp.faceCells();
|
||||
|
||||
for (const label celli : pp.faceCells())
|
||||
{
|
||||
neighbourCellData[bFacei] = cellData[celli];
|
||||
++bFacei;
|
||||
}
|
||||
// ie, boundarySlice() = patchInternalList()
|
||||
SubList<T>
|
||||
(
|
||||
neighbourCellData,
|
||||
faceCells.size(),
|
||||
pp.offset()
|
||||
) = UIndirectList<T>(cellData, faceCells);
|
||||
}
|
||||
syncTools::swapBoundaryFaceList(mesh, neighbourCellData);
|
||||
|
||||
syncTools::swapBoundaryFaceList(mesh, neighbourCellData, parRun);
|
||||
}
|
||||
|
||||
|
||||
@ -1479,10 +1474,17 @@ template<unsigned Width>
|
||||
void Foam::syncTools::swapFaceList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
PackedList<Width>& faceValues
|
||||
PackedList<Width>& faceValues,
|
||||
const bool parRun
|
||||
)
|
||||
{
|
||||
syncFaceList(mesh, faceValues, eqOp<unsigned int>());
|
||||
syncFaceList
|
||||
(
|
||||
mesh,
|
||||
faceValues,
|
||||
eqOp<unsigned int>(),
|
||||
parRun
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1490,10 +1492,17 @@ template<unsigned Width>
|
||||
void Foam::syncTools::swapBoundaryFaceList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
PackedList<Width>& faceValues
|
||||
PackedList<Width>& faceValues,
|
||||
const bool parRun
|
||||
)
|
||||
{
|
||||
syncBoundaryFaceList(mesh, faceValues, eqOp<unsigned int>());
|
||||
syncBoundaryFaceList
|
||||
(
|
||||
mesh,
|
||||
faceValues,
|
||||
eqOp<unsigned int>(),
|
||||
parRun
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1510,8 +1519,8 @@ void Foam::syncTools::syncPointList
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of values " << pointValues.size()
|
||||
<< " is not equal to the number of points in the mesh "
|
||||
<< mesh.nPoints() << abort(FatalError);
|
||||
<< " != number of points " << mesh.nPoints() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const globalMeshData& gd = mesh.globalData();
|
||||
@ -1553,8 +1562,8 @@ void Foam::syncTools::syncEdgeList
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Number of values " << edgeValues.size()
|
||||
<< " is not equal to the number of edges in the mesh "
|
||||
<< mesh.nEdges() << abort(FatalError);
|
||||
<< " != number of edges " << mesh.nEdges() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const globalMeshData& gd = mesh.globalData();
|
||||
|
Loading…
Reference in New Issue
Block a user