/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 .
\*---------------------------------------------------------------------------*/
#include "mapDistributeBase.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
// The maps (labelListList) are not human-modifiable but if we need to
// inspect them in ASCII, it is much more convenient if each sub-list
// is flattened on a single line.
static Ostream& printMaps(Ostream& os, const labelListList& maps)
{
if (os.format() == IOstreamOption::BINARY || maps.empty())
{
os << maps;
}
else
{
os << nl << maps.size() << nl
<< token::BEGIN_LIST << nl;
// Compact single-line output for each labelList
for (const labelList& map : maps)
{
map.writeList(os) << nl;
}
os << token::END_LIST;
}
return os;
}
static void writeMaps(Ostream& os, const word& key, const labelListList& maps)
{
if (os.format() == IOstreamOption::BINARY || maps.empty())
{
os.writeEntry(key, maps);
}
else
{
os << indent << key;
printMaps(os, maps);
os.endEntry();
}
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::mapDistributeBase::mapDistributeBase
(
const dictionary& dict,
const label comm
)
:
mapDistributeBase(comm)
{
mapDistributeBase::readDict(dict);
}
Foam::mapDistributeBase::mapDistributeBase(Istream& is)
{
is >> *this;
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::mapDistributeBase::readDict(const dictionary& dict)
{
constructSize_ = dict.get