processorTopology: Un-templated

The template parameters were only ever polyBoundaryMesh and
processorPolyPatch. Un-templating makes mainteance and bug-fixing
quicker as it means minor modifications no longer cause a full rebuild
of OpenFOAM.
This commit is contained in:
Will Bainbridge
2022-03-17 11:27:00 +00:00
parent ec3187fa52
commit a578586c2c
17 changed files with 200 additions and 237 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,6 +54,7 @@ Description
#include "wedgePolyPatch.H"
#include "planeExtrusion.H"
#include "emptyPolyPatch.H"
#include "processorPolyPatch.H"
using namespace Foam;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -51,6 +51,7 @@ Description
#include "searchableSurface.H"
#include "fvMeshTools.H"
#include "systemDict.H"
#include "processorPolyPatch.H"
using namespace Foam;

View File

@ -25,6 +25,7 @@ License
#include "mapMeshes.H"
#include "surfaceMesh.H"
#include "processorFvPatch.H"
#include "pointMesh.H"
#include "mapLagrangian.H"
#include "MapVolFields.H"

View File

@ -501,12 +501,12 @@ polyBoundaryMesh = $(polyMesh)/polyBoundaryMesh
$(polyBoundaryMesh)/polyBoundaryMesh.C
$(polyBoundaryMesh)/polyBoundaryMeshEntries.C
meshes/ProcessorTopology/commSchedule.C
globalMeshData = $(polyMesh)/globalMeshData
$(globalMeshData)/globalMeshData.C
$(globalMeshData)/globalPoints.C
$(globalMeshData)/globalIndex.C
$(globalMeshData)/commSchedule.C
$(globalMeshData)/processorTopology.C
$(polyMesh)/syncTools/syncTools.C
$(polyMesh)/polyMeshTetDecomposition/polyMeshTetDecomposition.C

View File

@ -1,122 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::ProcessorTopology
Description
Determines processor-processor connection. After instantiation contains
on all processors the processor-processor connection table.
*this[proci] gives the list of neighbouring processors.
TODO: This does not currently correctly support multiple processor
patches connecting two processors.
SourceFiles
ProcessorTopology.C
\*---------------------------------------------------------------------------*/
#ifndef ProcessorTopology_H
#define ProcessorTopology_H
#include "labelList.H"
#include "lduSchedule.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class ProcessorTopology Declaration
\*---------------------------------------------------------------------------*/
template<class Container, class ProcPatch>
class ProcessorTopology
:
public labelListList
{
// Private Data
//- Local map from neighbour proc to patchi. Different per processor!
// -1 or patchi for connection to procID
labelList procPatchMap_;
//- Order in which the patches should be initialised/evaluated
// corresponding to the schedule
lduSchedule patchSchedule_;
// Private Member Functions
//- Return all neighbouring processors of this processor. Set
// procPatchMap_.
labelList procNeighbours(const label nProcs, const Container&);
public:
// Constructors
//- Construct from boundaryMesh
ProcessorTopology(const Container& patches, const label comm);
// Member Functions
//- From neighbour processor to index in boundaryMesh. Local information
// (so not same over all processors)
const labelList& procPatchMap() const
{
return procPatchMap_;
}
//- Order in which the patches should be initialised/evaluated
// corresponding to the schedule
const lduSchedule& patchSchedule() const
{
return patchSchedule_;
}
//- Calculate non-blocking (i.e. unscheduled) schedule
static lduSchedule nonBlockingSchedule(const Container& patches);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "ProcessorTopology.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -1768,11 +1768,11 @@ void Foam::globalMeshData::calcGlobalCoPointSlaves() const
Foam::globalMeshData::globalMeshData(const polyMesh& mesh)
:
processorTopology(mesh.boundaryMesh(), UPstream::worldComm),
mesh_(mesh),
nTotalPoints_(-1),
nTotalFaces_(-1),
nTotalCells_(-1),
processorTopology_(mesh.boundaryMesh(), UPstream::worldComm),
processorPatches_(0),
processorPatchIndices_(0),
processorPatchNeighbours_(0),

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -104,8 +104,6 @@ class PackedBoolList;
\*---------------------------------------------------------------------------*/
class globalMeshData
:
public processorTopology
{
// Private Data
@ -128,6 +126,9 @@ class globalMeshData
// Processor patch addressing (be careful if not running in parallel!)
//- Processor topology class
processorTopology processorTopology_;
//- List of processor patch labels
// (size of list = number of processor patches)
labelList processorPatches_;
@ -251,9 +252,10 @@ class globalMeshData
//- Calculate shared edge addressing
void calcSharedEdges() const;
//- Calculate global point addressing.
//- Calculate global point addressing.
void calcGlobalPointSlaves() const;
// Global edge addressing
//- Calculate connected points
@ -293,6 +295,7 @@ class globalMeshData
//- Calculate global point to global boundary cell addressing.
void calcGlobalPointBoundaryCells() const;
// Other
// Point to collocated points. Note that not all points on
@ -395,6 +398,19 @@ public:
// Processor patch addressing (be careful when not running in parallel)
//- Return the processor-processor connection table
const labelListList& procNbrProcs() const
{
return processorTopology_.procNbrProcs();
}
//- Order in which the patches should be initialised/evaluated
// corresponding to the schedule
const lduSchedule& patchSchedule() const
{
return processorTopology_.patchSchedule();
}
//- Return list of processor patch labels
// (size of list = number of processor patches)
const labelList& processorPatches() const

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,19 +23,17 @@ License
\*---------------------------------------------------------------------------*/
#include "ProcessorTopology.H"
#include "ListOps.H"
#include "Pstream.H"
#include "processorTopology.H"
#include "polyBoundaryMesh.H"
#include "processorPolyPatch.H"
#include "commSchedule.H"
#include "boolList.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Container, class ProcPatch>
Foam::labelList Foam::ProcessorTopology<Container, ProcPatch>::procNeighbours
Foam::labelList Foam::processorTopology::procNeighbours
(
const label nProcs,
const Container& patches
const polyBoundaryMesh& patches
)
{
// Determine number of processor neighbours and max neighbour id.
@ -48,12 +46,12 @@ Foam::labelList Foam::ProcessorTopology<Container, ProcPatch>::procNeighbours
forAll(patches, patchi)
{
const typename Container::const_reference patch = patches[patchi];
const polyPatch& patch = patches[patchi];
if (isA<ProcPatch>(patch))
if (isA<processorPolyPatch>(patch))
{
const ProcPatch& procPatch =
refCast<const ProcPatch>(patch);
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patch);
label pNeighbProcNo = procPatch.neighbProcNo();
@ -85,12 +83,12 @@ Foam::labelList Foam::ProcessorTopology<Container, ProcPatch>::procNeighbours
forAll(patches, patchi)
{
const typename Container::const_reference patch = patches[patchi];
const polyPatch& patch = patches[patchi];
if (isA<ProcPatch>(patch))
if (isA<processorPolyPatch>(patch))
{
const ProcPatch& procPatch =
refCast<const ProcPatch>(patch);
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patch);
// Construct reverse map
procPatchMap_[procPatch.neighbProcNo()] = patchi;
@ -101,27 +99,82 @@ Foam::labelList Foam::ProcessorTopology<Container, ProcPatch>::procNeighbours
}
Foam::lduSchedule Foam::processorTopology::nonBlockingSchedule
(
const polyBoundaryMesh& patches
)
{
lduSchedule patchSchedule(2*patches.size());
label patchEvali = 0;
// 1. All non-processor patches
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Have evaluate directly after initEvaluate. Could have them separated
// as long as they're not intermingled with processor patches since
// then e.g. any reduce parallel traffic would interfere with the
// processor swaps.
forAll(patches, patchi)
{
if (!isA<processorPolyPatch>(patches[patchi]))
{
patchSchedule[patchEvali].patch = patchi;
patchSchedule[patchEvali++].init = true;
patchSchedule[patchEvali].patch = patchi;
patchSchedule[patchEvali++].init = false;
}
}
// 2. All processor patches
// ~~~~~~~~~~~~~~~~~~~~~~~~
// 2a. initEvaluate
forAll(patches, patchi)
{
if (isA<processorPolyPatch>(patches[patchi]))
{
patchSchedule[patchEvali].patch = patchi;
patchSchedule[patchEvali++].init = true;
}
}
// 2b. evaluate
forAll(patches, patchi)
{
if (isA<processorPolyPatch>(patches[patchi]))
{
patchSchedule[patchEvali].patch = patchi;
patchSchedule[patchEvali++].init = false;
}
}
return patchSchedule;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Container, class ProcPatch>
Foam::ProcessorTopology<Container, ProcPatch>::ProcessorTopology
Foam::processorTopology::processorTopology
(
const Container& patches,
const polyBoundaryMesh& patches,
const label comm
)
:
labelListList(Pstream::nProcs(comm)),
procNbrProcs_(Pstream::nProcs(comm)),
procPatchMap_(),
patchSchedule_(2*patches.size())
{
if (Pstream::parRun())
{
// Fill my 'slot' with my neighbours
operator[](Pstream::myProcNo(comm)) =
procNeighbours(this->size(), patches);
procNbrProcs_[Pstream::myProcNo(comm)] =
procNeighbours(procNbrProcs_.size(), patches);
// Distribute to all processors
Pstream::gatherList(*this, Pstream::msgType(), comm);
Pstream::scatterList(*this, Pstream::msgType(), comm);
Pstream::gatherList(procNbrProcs_, Pstream::msgType(), comm);
Pstream::scatterList(procNbrProcs_, Pstream::msgType(), comm);
}
if
@ -137,7 +190,7 @@ Foam::ProcessorTopology<Container, ProcPatch>::ProcessorTopology
forAll(patches, patchi)
{
if (!isA<ProcPatch>(patches[patchi]))
if (!isA<processorPolyPatch>(patches[patchi]))
{
patchSchedule_[patchEvali].patch = patchi;
patchSchedule_[patchEvali++].init = true;
@ -153,15 +206,15 @@ Foam::ProcessorTopology<Container, ProcPatch>::ProcessorTopology
// to determine the schedule. Each processor pair stands for both
// send and receive.
label nComms = 0;
forAll(*this, proci)
forAll(procNbrProcs_, proci)
{
nComms += operator[](proci).size();
nComms += procNbrProcs_[proci].size();
}
DynamicList<labelPair> comms(nComms);
forAll(*this, proci)
forAll(procNbrProcs_, proci)
{
const labelList& nbrs = operator[](proci);
const labelList& nbrs = procNbrProcs_[proci];
forAll(nbrs, i)
{
@ -218,63 +271,4 @@ Foam::ProcessorTopology<Container, ProcPatch>::ProcessorTopology
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Container, class ProcPatch>
Foam::lduSchedule
Foam::ProcessorTopology<Container, ProcPatch>::nonBlockingSchedule
(
const Container& patches
)
{
lduSchedule patchSchedule(2*patches.size());
label patchEvali = 0;
// 1. All non-processor patches
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Have evaluate directly after initEvaluate. Could have them separated
// as long as they're not intermingled with processor patches since
// then e.g. any reduce parallel traffic would interfere with the
// processor swaps.
forAll(patches, patchi)
{
if (!isA<ProcPatch>(patches[patchi]))
{
patchSchedule[patchEvali].patch = patchi;
patchSchedule[patchEvali++].init = true;
patchSchedule[patchEvali].patch = patchi;
patchSchedule[patchEvali++].init = false;
}
}
// 2. All processor patches
// ~~~~~~~~~~~~~~~~~~~~~~~~
// 2a. initEvaluate
forAll(patches, patchi)
{
if (isA<ProcPatch>(patches[patchi]))
{
patchSchedule[patchEvali].patch = patchi;
patchSchedule[patchEvali++].init = true;
}
}
// 2b. evaluate
forAll(patches, patchi)
{
if (isA<ProcPatch>(patches[patchi]))
{
patchSchedule[patchEvali].patch = patchi;
patchSchedule[patchEvali++].init = false;
}
}
return patchSchedule;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -21,22 +21,90 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::ProcessorTopology
Description
Determines processor-processor connection. After instantiation contains
on all processors the processor-processor connection table.
TODO: This does not currently correctly support multiple processor
patches connecting two processors.
SourceFiles
ProcessorTopology.C
\*---------------------------------------------------------------------------*/
#ifndef processorTopology_H
#define processorTopology_H
#include "ProcessorTopology.H"
#include "processorPolyPatch.H"
#include "labelList.H"
#include "lduSchedule.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Forward declaration of friend functions and operators
class polyBoundaryMesh;
/*---------------------------------------------------------------------------*\
Class processorTopology Declaration
\*---------------------------------------------------------------------------*/
class processorTopology
{
// Private Data
//- Processor-processor connection table
labelListList procNbrProcs_;
//- Local map from neighbour proc to patchi. Different per processor!
// -1 or patchi for connection to procID
labelList procPatchMap_;
//- Order in which the patches should be initialised/evaluated
// corresponding to the schedule
lduSchedule patchSchedule_;
// Private Member Functions
//- Return all neighbouring processors of this processor. Set
// procPatchMap_.
labelList procNeighbours(const label nProcs, const polyBoundaryMesh&);
//- Calculate non-blocking (i.e. unscheduled) schedule
lduSchedule nonBlockingSchedule(const polyBoundaryMesh& patches);
public:
// Constructors
//- Construct from boundaryMesh
processorTopology(const polyBoundaryMesh& patches, const label comm);
// Member Functions
//- Return the processor-processor connection table
const labelListList& procNbrProcs() const
{
return procNbrProcs_;
}
//- Order in which the patches should be initialised/evaluated
// corresponding to the schedule
const lduSchedule& patchSchedule() const
{
return patchSchedule_;
}
};
typedef ProcessorTopology<polyPatchList, processorPolyPatch> processorTopology;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "ensightParts.H"
#include "processorPolyPatch.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "fvMeshTools.H"
#include "processorPolyPatch.H"
#include "pointFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -597,12 +597,12 @@ void Foam::motionSmootherAlgo::correctBoundaryConditions
if (patchSchedule[patchEvalI].init)
{
displacementBf[patchi]
.initEvaluate(Pstream::commsTypes::blocking);
.initEvaluate(Pstream::commsTypes::scheduled);
}
else
{
displacementBf[patchi]
.evaluate(Pstream::commsTypes::blocking);
.evaluate(Pstream::commsTypes::scheduled);
}
}
}
@ -618,12 +618,12 @@ void Foam::motionSmootherAlgo::correctBoundaryConditions
if (patchSchedule[patchEvalI].init)
{
displacementBf[patchi]
.initEvaluate(Pstream::commsTypes::blocking);
.initEvaluate(Pstream::commsTypes::scheduled);
}
else
{
displacementBf[patchi]
.evaluate(Pstream::commsTypes::blocking);
.evaluate(Pstream::commsTypes::scheduled);
}
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -156,7 +156,7 @@ void Foam::Cloud<ParticleType>::move
const labelList& procPatchNeighbours = pData.processorPatchNeighbours();
// Which processors this processor is connected to
const labelList& neighbourProcs = pData[Pstream::myProcNo()];
const labelList& neighbourProcs = pData.procNbrProcs()[Pstream::myProcNo()];
// Indexing from the processor number into the neighbourProcs list
labelList neighbourProcIndices(Pstream::nProcs(), -1);

View File

@ -27,6 +27,7 @@ License
#include "Time.H"
#include "globalIndex.H"
#include "meshToMeshMethod.H"
#include "processorPolyPatch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,6 +25,7 @@ License
#include "thresholdCellFaces.H"
#include "emptyPolyPatch.H"
#include "processorPolyPatch.H"
#include "polygonTriangulate.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //