STYLE: minor code cleanup of commSchedule

- obtain sorted order directly without SortableList,
  relocate private method to static local.
This commit is contained in:
Mark Olesen
2022-02-24 09:08:44 +01:00
committed by Andrew Heather
parent f4ebc90a02
commit 05b1bc9e79
2 changed files with 24 additions and 22 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,8 +27,7 @@ License
\*---------------------------------------------------------------------------*/
#include "commSchedule.H"
#include "SortableList.H"
#include "boolList.H"
#include "ListOps.H"
#include "IOstreams.H"
#include "IOmanip.H"
#include "StringStream.H"
@ -41,26 +41,33 @@ namespace Foam
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
Foam::label Foam::commSchedule::outstandingComms
namespace Foam
{
// Private Member Functions
// Count the number of outstanding communications for a single processor
static label outstandingComms
(
const labelList& commToSchedule,
DynamicList<label>& procComms
) const
)
{
label nOutstanding = 0;
forAll(procComms, i)
for (const label commi : procComms)
{
if (commToSchedule[procComms[i]] == -1)
if (commToSchedule[commi] == -1)
{
nOutstanding++;
++nOutstanding;
}
}
return nOutstanding;
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -94,7 +101,7 @@ Foam::commSchedule::commSchedule
if (debug && Pstream::master())
{
Pout<< "commSchedule::commSchedule : Wanted communication:" << endl;
Pout<< "commSchedule : Wanted communication:" << endl;
forAll(comms, i)
{
@ -106,7 +113,7 @@ Foam::commSchedule::commSchedule
Pout<< endl;
Pout<< "commSchedule::commSchedule : Schedule:" << endl;
Pout<< "commSchedule : Schedule:" << endl;
// Print header. Use buffered output to prevent parallel output messing
// up.
@ -239,8 +246,9 @@ Foam::commSchedule::commSchedule
}
// Sort commToSchedule and obtain order in comms
schedule_ = SortableList<label>(commToSchedule).indices();
// Sort commToSchedule to obtain order in comms
Foam::sortedOrder(commToSchedule, schedule_);
// Sort schedule_ by processor

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -49,10 +50,9 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef commSchedule_H
#define commSchedule_H
#ifndef Foam_commSchedule_H
#define Foam_commSchedule_H
#include "DynamicList.H"
#include "labelPair.H"
#include "labelList.H"
@ -67,7 +67,7 @@ namespace Foam
class commSchedule
{
// Private data
// Private Data
//- Order in which input communication has been scheduled
labelList schedule_;
@ -75,12 +75,6 @@ class commSchedule
//- Per processor the order in which communication has been scheduled
labelListList procSchedule_;
// Private Member Functions
//- Count the number of outstanding communications for a single
// processor
label outstandingComms(const labelList&, DynamicList<label>&) const;
public: