Skip to content
Snippets Groups Projects
Commit 0c3a9388 authored by Mattijs Janssens's avatar Mattijs Janssens
Browse files

Merge branch 'feature-masterCoarsest-multi-masters' into 'develop'

Feature master coarsest multi masters

See merge request !565
parents 3a6a7604 62244c6c
Branches
1 merge request!565Feature master coarsest multi masters
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2014 OpenFOAM Foundation Copyright (C) 2013-2014 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -52,8 +53,48 @@ Foam::masterCoarsestGAMGProcAgglomeration::masterCoarsestGAMGProcAgglomeration ...@@ -52,8 +53,48 @@ Foam::masterCoarsestGAMGProcAgglomeration::masterCoarsestGAMGProcAgglomeration
const dictionary& controlDict const dictionary& controlDict
) )
: :
GAMGProcAgglomeration(agglom, controlDict) GAMGProcAgglomeration(agglom, controlDict),
{} nProcessorsPerMaster_
(
controlDict.getOrDefault<label>
(
"nProcessorsPerMaster",
0,
keyType::LITERAL
)
)
{
const auto* ePtr = controlDict.findEntry("nMasters", keyType::LITERAL);
if (ePtr)
{
if (nProcessorsPerMaster_ > 0)
{
FatalIOErrorInFunction(controlDict)
<< "Cannot specify both \"nMasters\" and"
<< " \"nProcessorsPerMaster\"" << exit(FatalIOError);
}
const label nMasters(readLabel(ePtr->stream()));
if (nMasters <= 0)
{
FatalIOErrorInFunction(controlDict)
<< "Illegal value \"nMasters\" "
<< nMasters << exit(FatalIOError);
}
nProcessorsPerMaster_ =
(Pstream::nProcs(agglom.mesh().comm())+nMasters-1)
/ nMasters;
}
if (nProcessorsPerMaster_ < 0)
{
FatalIOErrorInFunction(controlDict)
<< "Illegal value \"nProcessorsPerMaster\" "
<< nProcessorsPerMaster_ << exit(FatalIOError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
...@@ -75,7 +116,7 @@ Foam::masterCoarsestGAMGProcAgglomeration:: ...@@ -75,7 +116,7 @@ Foam::masterCoarsestGAMGProcAgglomeration::
bool Foam::masterCoarsestGAMGProcAgglomeration::agglomerate() bool Foam::masterCoarsestGAMGProcAgglomeration::agglomerate()
{ {
if (debug) if (debug & 2)
{ {
Pout<< nl << "Starting mesh overview" << endl; Pout<< nl << "Starting mesh overview" << endl;
printStats(Pout, agglom_); printStats(Pout, agglom_);
...@@ -97,7 +138,23 @@ bool Foam::masterCoarsestGAMGProcAgglomeration::agglomerate() ...@@ -97,7 +138,23 @@ bool Foam::masterCoarsestGAMGProcAgglomeration::agglomerate()
if (nProcs > 1) if (nProcs > 1)
{ {
// Processor restriction map: per processor the coarse processor // Processor restriction map: per processor the coarse processor
labelList procAgglomMap(nProcs, Zero); labelList procAgglomMap(nProcs);
if (nProcessorsPerMaster_ > 0)
{
forAll(procAgglomMap, fineProci)
{
procAgglomMap[fineProci] =
(
fineProci
/ nProcessorsPerMaster_
);
}
}
else
{
procAgglomMap = Zero;
}
// Master processor // Master processor
labelList masterProcs; labelList masterProcs;
...@@ -112,6 +169,32 @@ bool Foam::masterCoarsestGAMGProcAgglomeration::agglomerate() ...@@ -112,6 +169,32 @@ bool Foam::masterCoarsestGAMGProcAgglomeration::agglomerate()
agglomProcIDs agglomProcIDs
); );
if (debug)
{
if (masterProcs.size())
{
labelListList masterToProcs
(
invertOneToMany
(
masterProcs.size(),
procAgglomMap
)
);
Info<< typeName << " : agglomerating" << nl
<< "\tmaster\tnProcs\tprocIDs" << endl;
for (const auto& p : masterToProcs)
{
Info<< '\t' << p[0]
<< '\t' << p.size()
<< '\t'
<< flatOutput(SubList<label>(p, p.size()-1, 1))
<< endl;
}
}
}
// Allocate a communicator for the processor-agglomerated matrix // Allocate a communicator for the processor-agglomerated matrix
comms_.append comms_.append
( (
...@@ -139,7 +222,7 @@ bool Foam::masterCoarsestGAMGProcAgglomeration::agglomerate() ...@@ -139,7 +222,7 @@ bool Foam::masterCoarsestGAMGProcAgglomeration::agglomerate()
} }
// Print a bit // Print a bit
if (debug) if (debug & 2)
{ {
Pout<< nl << "Agglomerated mesh overview" << endl; Pout<< nl << "Agglomerated mesh overview" << endl;
printStats(Pout, agglom_); printStats(Pout, agglom_);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013 OpenFOAM Foundation Copyright (C) 2013 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -29,6 +30,28 @@ Class ...@@ -29,6 +30,28 @@ Class
Description Description
Processor agglomeration of GAMGAgglomerations. Processor agglomeration of GAMGAgglomerations.
- by default agglomerates onto the master processor
- optionally have multiple masters through the nProcessorsPerMaster
parameter. e.g.
p
{
solver GAMG;
tolerance 1e-06;
relTol 0.1;
smoother GaussSeidel;
nCellsInCoarsestLevel 10;
processorAgglomerator masterCoarsest;
// Groups of 32 cores get combined so each 'master' gets
// (roughly) 32*nCellsInCoarsestLevel cells.
nProcessorsPerMaster 32;
// Alternative : specify number of (equi-distributed) masters
nMasters 2;
}
SourceFiles SourceFiles
masterCoarsestGAMGProcAgglomeration.C masterCoarsestGAMGProcAgglomeration.C
...@@ -57,8 +80,11 @@ class masterCoarsestGAMGProcAgglomeration ...@@ -57,8 +80,11 @@ class masterCoarsestGAMGProcAgglomeration
{ {
// Private data // Private data
label nProcessorsPerMaster_;
DynamicList<label> comms_; DynamicList<label> comms_;
// Private Member Functions // Private Member Functions
//- No copy construct //- No copy construct
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment