ENH: centralise communicator clearing (GAMG)

This commit is contained in:
Mark Olesen 2023-05-17 14:26:05 +02:00
parent a64357983c
commit b45ea8c2aa
10 changed files with 110 additions and 156 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -380,7 +380,21 @@ Foam::autoPtr<Foam::GAMGProcAgglomeration> Foam::GAMGProcAgglomeration::New
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::GAMGProcAgglomeration::~GAMGProcAgglomeration()
{}
{
clearCommunicators();
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::GAMGProcAgglomeration::clearCommunicators()
{
forAllReverse(comms_, i)
{
UPstream::freeCommunicator(comms_[i]);
}
comms_.clear();
}
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2014 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,19 +35,22 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef GAMGProcAgglomeration_H
#define GAMGProcAgglomeration_H
#ifndef Foam_GAMGProcAgglomeration_H
#define Foam_GAMGProcAgglomeration_H
#include "runTimeSelectionTables.H"
#include "labelList.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward Declarations
class GAMGAgglomeration;
class lduMesh;
class lduPrimitiveMesh;
/*---------------------------------------------------------------------------*\
Class GAMGProcAgglomeration Declaration
@ -54,14 +58,17 @@ class lduMesh;
class GAMGProcAgglomeration
{
protected:
// Protected data
// Protected Data
//- Reference to agglomeration
GAMGAgglomeration& agglom_;
//- Allocated communicators
DynamicList<label> comms_;
// Protected Member Functions
//- Debug: write agglomeration info
@ -80,17 +87,8 @@ protected:
//- Debug: calculate global cell-cells
static labelListList globalCellCells(const lduMesh&);
private:
// Private data
// Private Member Functions
//- No copy construct
GAMGProcAgglomeration(const GAMGProcAgglomeration&) = delete;
//- No copy assignment
void operator=(const GAMGProcAgglomeration&) = delete;
//- Clear/free allocated communicators
void clearCommunicators();
public:
@ -118,6 +116,13 @@ public:
);
//- No copy construct
GAMGProcAgglomeration(const GAMGProcAgglomeration&) = delete;
//- No copy assignment
void operator=(const GAMGProcAgglomeration&) = delete;
// Constructors
//- Construct given agglomerator and controls
@ -139,15 +144,14 @@ public:
);
//- Destructor
//- Destructor. Clears allocated communicators
virtual ~GAMGProcAgglomeration();
// Member Functions
//- Modify agglomeration. Return true if modified
//- Modify agglomeration. \returns True if modified
virtual bool agglomerate() = 0;
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -60,14 +60,8 @@ Foam::eagerGAMGProcAgglomeration::eagerGAMGProcAgglomeration
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::eagerGAMGProcAgglomeration::
~eagerGAMGProcAgglomeration()
{
forAllReverse(comms_, i)
{
UPstream::freeCommunicator(comms_[i]);
}
}
Foam::eagerGAMGProcAgglomeration::~eagerGAMGProcAgglomeration()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -122,9 +116,8 @@ bool Foam::eagerGAMGProcAgglomeration::agglomerate()
agglomProcIDs
);
// Allocate a communicator for the processor-agglomerated
// matrix
comms_.append
// Communicator for the processor-agglomerated matrix
comms_.push_back
(
UPstream::allocateCommunicator
(
@ -135,7 +128,7 @@ bool Foam::eagerGAMGProcAgglomeration::agglomerate()
// Use processor agglomeration maps to do the actual
// collecting.
if (Pstream::myProcNo(levelComm) != -1)
if (UPstream::myProcNo(levelComm) != -1)
{
GAMGProcAgglomeration::agglomerate
(
@ -143,7 +136,7 @@ bool Foam::eagerGAMGProcAgglomeration::agglomerate()
procAgglomMap,
masterProcs,
agglomProcIDs,
comms_.last()
comms_.back()
);
}
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,19 +37,16 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef eagerGAMGProcAgglomeration_H
#define eagerGAMGProcAgglomeration_H
#ifndef Foam_eagerGAMGProcAgglomeration_H
#define Foam_eagerGAMGProcAgglomeration_H
#include "GAMGProcAgglomeration.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class GAMGAgglomeration;
/*---------------------------------------------------------------------------*\
Class eagerGAMGProcAgglomeration Declaration
\*---------------------------------------------------------------------------*/
@ -57,30 +55,23 @@ class eagerGAMGProcAgglomeration
:
public GAMGProcAgglomeration
{
// Private data
// Private Data
//- Agglpmeration level
const label mergeLevels_;
DynamicList<label> comms_;
// Private Member Functions
//- No copy construct
eagerGAMGProcAgglomeration
(
const eagerGAMGProcAgglomeration&
) = delete;
//- No copy assignment
void operator=(const eagerGAMGProcAgglomeration&) = delete;
public:
//- Runtime type information
TypeName("eager");
//- No copy construct
eagerGAMGProcAgglomeration(const eagerGAMGProcAgglomeration&) = delete;
//- No copy assignment
void operator=(const eagerGAMGProcAgglomeration&) = delete;
// Constructors
@ -98,9 +89,8 @@ public:
// Member Functions
//- Modify agglomeration. Return true if modified
//- Modify agglomeration. Return true if modified
virtual bool agglomerate();
};

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2015 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,14 +60,8 @@ Foam::manualGAMGProcAgglomeration::manualGAMGProcAgglomeration
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::manualGAMGProcAgglomeration::
~manualGAMGProcAgglomeration()
{
forAllReverse(comms_, i)
{
UPstream::freeCommunicator(comms_[i]);
}
}
Foam::manualGAMGProcAgglomeration::~manualGAMGProcAgglomeration()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -165,9 +160,8 @@ bool Foam::manualGAMGProcAgglomeration::agglomerate()
}
// Allocate a communicator for the processor-agglomerated
// matrix
comms_.append
// Communicator for the processor-agglomerated matrix
comms_.push_back
(
UPstream::allocateCommunicator
(
@ -178,7 +172,7 @@ bool Foam::manualGAMGProcAgglomeration::agglomerate()
// Use processor agglomeration maps to do the actual
// collecting
if (Pstream::myProcNo(levelMesh.comm()) != -1)
if (UPstream::myProcNo(levelMesh.comm()) != -1)
{
GAMGProcAgglomeration::agglomerate
(
@ -186,7 +180,7 @@ bool Foam::manualGAMGProcAgglomeration::agglomerate()
procAgglomMap,
coarseToMaster,
agglomProcIDs,
comms_.last()
comms_.back()
);
}
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,11 +59,10 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef manualGAMGProcAgglomeration_H
#define manualGAMGProcAgglomeration_H
#ifndef Foam_manualGAMGProcAgglomeration_H
#define Foam_manualGAMGProcAgglomeration_H
#include "GAMGProcAgglomeration.H"
#include "DynamicList.H"
#include "Tuple2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -70,8 +70,6 @@ SourceFiles
namespace Foam
{
class GAMGAgglomeration;
/*---------------------------------------------------------------------------*\
Class manualGAMGProcAgglomeration Declaration
\*---------------------------------------------------------------------------*/
@ -80,26 +78,11 @@ class manualGAMGProcAgglomeration
:
public GAMGProcAgglomeration
{
// Private data
// Private Data
//- Per level the agglomeration map
const List<Tuple2<label, List<labelList>>> procAgglomMaps_;
//- Any allocated communicators
DynamicList<label> comms_;
// Private Member Functions
//- No copy construct
manualGAMGProcAgglomeration
(
const manualGAMGProcAgglomeration&
) = delete;
//- No copy assignment
void operator=(const manualGAMGProcAgglomeration&) = delete;
public:
@ -107,6 +90,13 @@ public:
TypeName("manual");
//- No copy construct
manualGAMGProcAgglomeration(const manualGAMGProcAgglomeration&) = delete;
//- No copy assignment
void operator=(const manualGAMGProcAgglomeration&) = delete;
// Constructors
//- Construct given agglomerator and controls
@ -123,9 +113,8 @@ public:
// Member Functions
//- Modify agglomeration. Return true if modified
//- Modify agglomeration. Return true if modified
virtual bool agglomerate();
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2014 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2022-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -101,12 +101,7 @@ Foam::masterCoarsestGAMGProcAgglomeration::masterCoarsestGAMGProcAgglomeration
Foam::masterCoarsestGAMGProcAgglomeration::
~masterCoarsestGAMGProcAgglomeration()
{
forAllReverse(comms_, i)
{
UPstream::freeCommunicator(comms_[i]);
}
}
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -192,8 +187,8 @@ bool Foam::masterCoarsestGAMGProcAgglomeration::agglomerate()
}
// Allocate a communicator for the processor-agglomerated matrix
comms_.append
// Communicator for the processor-agglomerated matrix
comms_.push_back
(
UPstream::allocateCommunicator
(
@ -203,7 +198,7 @@ bool Foam::masterCoarsestGAMGProcAgglomeration::agglomerate()
);
// Use processor agglomeration maps to do the actual collecting.
if (Pstream::myProcNo(levelComm) != -1)
if (UPstream::myProcNo(levelComm) != -1)
{
GAMGProcAgglomeration::agglomerate
(
@ -211,7 +206,7 @@ bool Foam::masterCoarsestGAMGProcAgglomeration::agglomerate()
procAgglomMap,
masterProcs,
agglomProcIDs,
comms_.last()
comms_.back()
);
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2022-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,19 +57,16 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef masterCoarsestGAMGProcAgglomeration_H
#define masterCoarsestGAMGProcAgglomeration_H
#ifndef Foam_masterCoarsestGAMGProcAgglomeration_H
#define Foam_masterCoarsestGAMGProcAgglomeration_H
#include "GAMGProcAgglomeration.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class GAMGAgglomeration;
/*---------------------------------------------------------------------------*\
Class masterCoarsestGAMGProcAgglomeration Declaration
\*---------------------------------------------------------------------------*/
@ -78,30 +75,25 @@ class masterCoarsestGAMGProcAgglomeration
:
public GAMGProcAgglomeration
{
// Private data
// Private Data
label nProcessorsPerMaster_;
DynamicList<label> comms_;
// Private Member Functions
//- No copy construct
masterCoarsestGAMGProcAgglomeration
(
const masterCoarsestGAMGProcAgglomeration&
) = delete;
//- No copy assignment
void operator=(const masterCoarsestGAMGProcAgglomeration&) = delete;
public:
//- Runtime type information
TypeName("masterCoarsest");
//- No copy construct
masterCoarsestGAMGProcAgglomeration
(
const masterCoarsestGAMGProcAgglomeration&
) = delete;
//- No copy assignment
void operator=(const masterCoarsestGAMGProcAgglomeration&) = delete;
// Constructors
@ -119,9 +111,8 @@ public:
// Member Functions
//- Modify agglomeration. Return true if modified
//- Modify agglomeration. Return true if modified
virtual bool agglomerate();
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -231,12 +231,7 @@ Foam::procFacesGAMGProcAgglomeration::procFacesGAMGProcAgglomeration
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::procFacesGAMGProcAgglomeration::~procFacesGAMGProcAgglomeration()
{
forAllReverse(comms_, i)
{
UPstream::freeCommunicator(comms_[i]);
}
}
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -289,9 +284,8 @@ bool Foam::procFacesGAMGProcAgglomeration::agglomerate()
agglomProcIDs
);
// Allocate a communicator for the processor-agglomerated
// matrix
comms_.append
// Communicator for the processor-agglomerated matrix
comms_.push_back
(
UPstream::allocateCommunicator
(
@ -300,7 +294,6 @@ bool Foam::procFacesGAMGProcAgglomeration::agglomerate()
)
);
// Use processor agglomeration maps to do the actual
// collecting.
GAMGProcAgglomeration::agglomerate
@ -309,7 +302,7 @@ bool Foam::procFacesGAMGProcAgglomeration::agglomerate()
procAgglomMap,
masterProcs,
agglomProcIDs,
comms_.last()
comms_.back()
);
}
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,11 +40,10 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef procFacesGAMGProcAgglomeration_H
#define procFacesGAMGProcAgglomeration_H
#ifndef Foam_procFacesGAMGProcAgglomeration_H
#define Foam_procFacesGAMGProcAgglomeration_H
#include "GAMGProcAgglomeration.H"
#include "DynamicList.H"
#include "labelField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -51,11 +51,6 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class GAMGAgglomeration;
class lduMesh;
class lduPrimitiveMesh;
/*---------------------------------------------------------------------------*\
Class procFacesGAMGProcAgglomeration Declaration
\*---------------------------------------------------------------------------*/
@ -69,8 +64,6 @@ class procFacesGAMGProcAgglomeration
//- When to processor agglomerate
const label nAgglomeratingCells_;
//- Allocated communicators
DynamicList<label> comms_;
// Private Member Functions
@ -90,21 +83,19 @@ class procFacesGAMGProcAgglomeration
//- Do we need to agglomerate across processors?
bool doProcessorAgglomeration(const lduMesh&) const;
//- No copy construct
procFacesGAMGProcAgglomeration
(
const procFacesGAMGProcAgglomeration&
) = delete;
//- No copy assignment
void operator=(const procFacesGAMGProcAgglomeration&) = delete;
public:
//- Runtime type information
TypeName("procFaces");
//- No copy construct
procFacesGAMGProcAgglomeration(const procFacesGAMGProcAgglomeration&)
= delete;
//- No copy assignment
void operator=(const procFacesGAMGProcAgglomeration&) = delete;
// Constructors