ENH: consolidate decomposition model, constructors for decomposition methods

- make regionName an optional constructor parameter, which eliminates
  a separate set of constructors and construction tables. Adjust
  internals to treat a missing/empty regionName as a no-op.

- pass in fallback dictionary content via new IOdictionary constructor
  with a pointer

ENH: further relax check for matching number of processor dirs

- if the "numberOfSubdomains" entry is missing (or even zero)
  ignore checks of processor dirs as meaningless.
This commit is contained in:
Mark Olesen
2021-04-23 16:44:09 +02:00
parent dedb1c0c90
commit 86f627b9e6
35 changed files with 369 additions and 667 deletions

View File

@ -60,7 +60,7 @@ int main(int argc, char *argv[])
( (
"decomposeParDict", "decomposeParDict",
"file", "file",
"read decomposePar dictionary from specified location" "Use specified file for decomposePar dictionary"
); );
#include "addRegionOption.H" #include "addRegionOption.H"
argList::addBoolOption argList::addBoolOption

View File

@ -457,7 +457,7 @@ int main(int argc, char *argv[])
runTime, runTime,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false // do not register
), ),
decompDictFile decompDictFile
) )

View File

@ -838,7 +838,7 @@ Foam::argList::argList
if (!*optName) if (!*optName)
{ {
Warning Warning
<<"Ignoring lone '-' on the command-line" << endl; << "Ignoring lone '-' on the command-line" << endl;
} }
else if else if
( (
@ -1057,7 +1057,7 @@ void Foam::argList::parse
<< "Date : " << dateString.c_str() << nl << "Date : " << dateString.c_str() << nl
<< "Time : " << timeString.c_str() << nl << "Time : " << timeString.c_str() << nl
<< "Host : " << Foam::hostName().c_str() << nl << "Host : " << Foam::hostName().c_str() << nl
<< "PID : " << pid() << endl; << "PID : " << pid() << nl;
} }
jobInfo.add("startDate", dateString); jobInfo.add("startDate", dateString);
@ -1281,13 +1281,24 @@ void Foam::argList::parse
if (dictStream && dictStream->good()) if (dictStream && dictStream->good())
{ {
dictionary decompDict(*dictStream); dictionary decompDict(*dictStream);
decompDict.readEntry("numberOfSubdomains", dictNProcs); bool nDomainsMandatory = false;
if (decompDict.getOrDefault("distributed", false)) if (decompDict.getOrDefault("distributed", false))
{ {
nDomainsMandatory = true;
parRunControl_.distributed(true); parRunControl_.distributed(true);
decompDict.readEntry("roots", roots); decompDict.readEntry("roots", roots);
} }
// Get numberOfSubdomains if it exists.
// - mandatory when running with distributed roots
decompDict.readEntry
(
"numberOfSubdomains",
dictNProcs,
keyType::LITERAL,
nDomainsMandatory
);
} }
else else
{ {
@ -1325,7 +1336,7 @@ void Foam::argList::parse
roots.resize(Pstream::nProcs()-1, rootName); roots.resize(Pstream::nProcs()-1, rootName);
// Adjust dictNProcs for command-line '-roots' option // Adjust dictNProcs for command-line '-roots' option
if (dictNProcs < 0) if (dictNProcs <= 0)
{ {
dictNProcs = roots.size()+1; dictNProcs = roots.size()+1;
} }
@ -1494,7 +1505,7 @@ void Foam::argList::parse
if (Pstream::master() && bannerEnabled()) if (Pstream::master() && bannerEnabled())
{ {
Info<< "Case : " << (rootPath_/globalCase_).c_str() << nl Info<< "Case : " << (rootPath_/globalCase_).c_str() << nl
<< "nProcs : " << nProcs << endl; << "nProcs : " << nProcs << nl;
if (parRunControl_.parRun()) if (parRunControl_.parRun())
{ {
@ -1532,13 +1543,13 @@ void Foam::argList::parse
<< " commsType : " << " commsType : "
<< Pstream::commsTypeNames[Pstream::defaultCommsType] << nl << Pstream::commsTypeNames[Pstream::defaultCommsType] << nl
<< " polling iterations : " << Pstream::nPollProcInterfaces << " polling iterations : " << Pstream::nPollProcInterfaces
<< endl; << nl;
if (UPstream::allWorlds().size() > 1) if (UPstream::allWorlds().size() > 1)
{ {
Info<< " worlds : " Info<< " worlds : "
<< flatOutput(UPstream::allWorlds()) << nl << flatOutput(UPstream::allWorlds()) << nl
<< " world : " << UPstream::myWorld() << " world : " << UPstream::myWorld()
<< endl; << nl;
} }
} }
} }
@ -1613,7 +1624,7 @@ void Foam::argList::parse
Info<< "Disallowing"; Info<< "Disallowing";
} }
Info<< " user-supplied system call operations" << nl Info<< " user-supplied system call operations" << nl
<< endl; << nl;
IOobject::writeDivider(Info); IOobject::writeDivider(Info);
} }
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -42,7 +42,6 @@ static const char* notImplementedMessage =
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(kahipDecomp, 0); defineTypeNameAndDebug(kahipDecomp, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
@ -71,15 +70,6 @@ Foam::label Foam::kahipDecomp::decomposeSerial
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::kahipDecomp::kahipDecomp
(
const dictionary& decompDict
)
:
metisLikeDecomp("kahip", decompDict)
{}
Foam::kahipDecomp::kahipDecomp Foam::kahipDecomp::kahipDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -43,7 +43,6 @@ static const char* notImplementedMessage =
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(metisDecomp, 0); defineTypeNameAndDebug(metisDecomp, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
@ -72,15 +71,6 @@ Foam::label Foam::metisDecomp::decomposeSerial
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::metisDecomp::metisDecomp
(
const dictionary& decompDict
)
:
metisLikeDecomp("metis", decompDict)
{}
Foam::metisDecomp::metisDecomp Foam::metisDecomp::metisDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,

View File

@ -45,7 +45,6 @@ static const char* notImplementedMessage =
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(ptscotchDecomp, 0); defineTypeNameAndDebug(ptscotchDecomp, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
@ -99,13 +98,6 @@ Foam::label Foam::ptscotchDecomp::decompose
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ptscotchDecomp::ptscotchDecomp(const dictionary& decompDict)
:
decompositionMethod(decompDict),
coeffsDict_()
{}
Foam::ptscotchDecomp::ptscotchDecomp Foam::ptscotchDecomp::ptscotchDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -45,7 +45,6 @@ static const char* notImplementedMessage =
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(scotchDecomp, 0); defineTypeNameAndDebug(scotchDecomp, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
@ -81,15 +80,6 @@ Foam::label Foam::scotchDecomp::decomposeSerial
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::scotchDecomp::scotchDecomp
(
const dictionary& decompDict
)
:
metisLikeDecomp("scotch", decompDict)
{}
Foam::scotchDecomp::scotchDecomp Foam::scotchDecomp::scotchDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2014-2016 OpenFOAM Foundation Copyright (C) 2014-2016 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -45,7 +45,8 @@ const Foam::word Foam::decompositionModel::canonicalName("decomposeParDict");
Foam::decompositionModel::decompositionModel Foam::decompositionModel::decompositionModel
( (
const polyMesh& mesh, const polyMesh& mesh,
const fileName& decompDictFile const fileName& decompDictFile,
const dictionary* fallback
) )
: :
MeshObject MeshObject
@ -60,52 +61,18 @@ Foam::decompositionModel::decompositionModel
( (
IOobject IOobject
( (
canonicalName, decompositionModel::canonicalName,
mesh.time().system(), mesh.time().system(),
mesh.local(), mesh.local(),
mesh.thisDb(), mesh.thisDb(),
IOobject::MUST_READ, (fallback ? IOobject::READ_IF_PRESENT : IOobject::MUST_READ),
IOobject::NO_WRITE,
false, //io.registerObject(),
true //io.globalObject()
),
decompDictFile
)
)
{}
Foam::decompositionModel::decompositionModel
(
const polyMesh& mesh,
const dictionary& dict,
const fileName& decompDictFile
)
:
MeshObject
<
polyMesh,
Foam::UpdateableMeshObject,
decompositionModel
>(mesh),
IOdictionary
(
IOobject::selectIO
(
IOobject
(
canonicalName,
mesh.time().system(),
mesh.local(),
mesh.thisDb(),
(dict.size() ? IOobject::NO_READ : IOobject::MUST_READ),
IOobject::NO_WRITE, IOobject::NO_WRITE,
false, //io.registerObject(), false, //io.registerObject(),
true //io.globalObject() true //io.globalObject()
), ),
decompDictFile decompDictFile
), ),
dict fallback
) )
{} {}
@ -115,7 +82,8 @@ Foam::decompositionModel::decompositionModel
const Foam::decompositionModel& Foam::decompositionModel::New const Foam::decompositionModel& Foam::decompositionModel::New
( (
const polyMesh& mesh, const polyMesh& mesh,
const fileName& decompDictFile const fileName& decompDictFile,
const dictionary* content
) )
{ {
return return
@ -124,24 +92,24 @@ const Foam::decompositionModel& Foam::decompositionModel::New
polyMesh, polyMesh,
Foam::UpdateableMeshObject, Foam::UpdateableMeshObject,
decompositionModel decompositionModel
>::New(mesh, decompDictFile); >::New(mesh, decompDictFile, content);
} }
const Foam::decompositionModel& Foam::decompositionModel::New // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
(
const polyMesh& mesh, Foam::decompositionMethod& Foam::decompositionModel::decomposer() const
const dictionary& dict,
const fileName& decompDictFile
)
{ {
return if (!decomposerPtr_)
MeshObject {
< decomposerPtr_ =
polyMesh, decompositionMethod::New
Foam::UpdateableMeshObject, (
decompositionModel *this,
>::New(mesh, dict, decompDictFile); this->mesh().name() // Name of mesh region
);
}
return *decomposerPtr_;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2014-2016 OpenFOAM Foundation Copyright (C) 2014-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -47,7 +47,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declarations // Forward Declarations
class mapPolyMesh; class mapPolyMesh;
class polyMesh; class polyMesh;
@ -65,7 +65,6 @@ class decompositionModel
>, >,
public IOdictionary public IOdictionary
{ {
// Private Data // Private Data
mutable autoPtr<decompositionMethod> decomposerPtr_; mutable autoPtr<decompositionMethod> decomposerPtr_;
@ -81,61 +80,38 @@ public:
static const word canonicalName; static const word canonicalName;
// Selectors
//- Read (optionally from absolute path) and register on mesh
static const decompositionModel& New
(
const polyMesh& mesh,
const fileName& decompDictFile = ""
);
//- Read (optionally from supplied dictionary) and register on mesh
static const decompositionModel& New
(
const polyMesh& mesh,
const dictionary& dict,
const fileName& decompDictFile = ""
);
// Constructors // Constructors
//- Construct from typeName or optional path to controlDictionary //- Construct from typeName, optional decomposeParDict path/name
decompositionModel //- or with fallback content
explicit decompositionModel
( (
const polyMesh& mesh, const polyMesh& mesh,
const fileName& decompDictFile = "" const fileName& decompDictFile = "",
const dictionary* fallback = nullptr
); );
//- Construct from typeName or optional path to controlDictionary // Selectors
decompositionModel
//- Read and register on mesh,
//- optionally with alternative decomposeParDict path/name
//- or with fallback content
static const decompositionModel& New
( (
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict, const fileName& decompDictFile = "",
const fileName& decompDictFile = "" const dictionary* fallback = nullptr
); );
// Member Functions // Member Functions
decompositionMethod& decomposer() const //- Return demand-driven decomposition method
{ decompositionMethod& decomposer() const;
if (!decomposerPtr_)
{
decomposerPtr_ =
decompositionMethod::New
(
*this,
this->mesh().name() // Name of mesh region
);
}
return *decomposerPtr_;
}
// UpdateableMeshObject // UpdateableMeshObject Functions
virtual bool movePoints() virtual bool movePoints()
{ {
@ -148,18 +124,44 @@ public:
// Housekeeping // Housekeeping
//- Deprecated(2021-04) compatibility constructor
// \deprecated(2021-04)
FOAM_DEPRECATED(2021-04)
decompositionModel
(
const polyMesh& mesh,
const dictionary& dict,
const fileName& decompDictFile = ""
)
:
decompositionModel(mesh, decompDictFile, &dict)
{}
//- Deprecated(2021-04) compatibility selector
// \deprecated(2021-04)
FOAM_DEPRECATED(2021-04)
static const decompositionModel& New
(
const polyMesh& mesh,
const dictionary& dict,
const fileName& decompDictFile = ""
)
{
return Foam::decompositionModel::New(mesh, decompDictFile, &dict);
}
//- Deprecated(2018-08) compatibility method //- Deprecated(2018-08) compatibility method
// \deprecated(2018-08) - use IOobject::selectIO directly // \deprecated(2018-08) - use IOobject::selectIO directly
FOAM_DEPRECATED_FOR(2018-08, "IOobject::selectIO")
static IOobject selectIO static IOobject selectIO
( (
const IOobject& io, const IOobject& io,
const fileName& altFile, const fileName& file,
const word& ioName = "" const word& name = ""
) )
{ {
return IOobject::selectIO(io, altFile, ioName); return IOobject::selectIO(io, file, name);
} }
}; };

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -49,45 +49,63 @@ namespace Foam
{ {
defineTypeNameAndDebug(decompositionMethod, 0); defineTypeNameAndDebug(decompositionMethod, 0);
defineRunTimeSelectionTable(decompositionMethod, dictionary); defineRunTimeSelectionTable(decompositionMethod, dictionary);
defineRunTimeSelectionTable(decompositionMethod, dictionaryRegion);
// Fallback name when searching for optional coefficients directories } // End namespace Foam
static const word defaultName("coeffs");
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
// Find named coefficents dictionary, or use default "coeffs"
static inline const dictionary* cfindCoeffsDict
(
const dictionary& dict,
const word& coeffsName,
const bool allowDefault
)
{
const dictionary* dictptr = dict.findDict(coeffsName);
if (!dictptr && allowDefault)
{
dictptr = dict.findDict("coeffs");
}
return dictptr;
}
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::label Foam::decompositionMethod::nDomains(const dictionary& decompDict)
{
return decompDict.get<label>("numberOfSubdomains");
}
Foam::label Foam::decompositionMethod::nDomains Foam::label Foam::decompositionMethod::nDomains
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName
) )
{ {
const label nDomainsGlobal = nDomains(decompDict); const label nDomainsGlobal = decompDict.get<label>("numberOfSubdomains");
const dictionary& regionDict(optionalRegionDict(decompDict, regionName)); if (!regionName.empty())
label nDomainsRegion;
if (regionDict.readIfPresent("numberOfSubdomains", nDomainsRegion))
{ {
if (nDomainsRegion >= 1 && nDomainsRegion <= nDomainsGlobal) const dictionary& regionDict =
{ optionalRegionDict(decompDict, regionName);
return nDomainsRegion;
}
WarningInFunction label nDomainsRegion;
<< "ignoring out of range numberOfSubdomains " if (regionDict.readIfPresent("numberOfSubdomains", nDomainsRegion))
<< nDomainsRegion << " for region " << regionName {
<< nl << nl if (nDomainsRegion >= 1 && nDomainsRegion <= nDomainsGlobal)
<< endl; {
return nDomainsRegion;
}
WarningInFunction
<< "ignoring out of range numberOfSubdomains "
<< nDomainsRegion << " for region " << regionName
<< nl << nl
<< endl;
}
} }
return nDomainsGlobal; return nDomainsGlobal;
@ -100,19 +118,16 @@ const Foam::dictionary& Foam::decompositionMethod::optionalRegionDict
const word& regionName const word& regionName
) )
{ {
auto finder = decompDict.csearch("regions"); const dictionary* dictptr = nullptr;
if
if (!regionName.empty() && finder.isDict()) (
!regionName.empty()
&& (dictptr = decompDict.findDict("regions")) != nullptr
)
{ {
finder = finder.dict().csearch(regionName); dictptr = dictptr->findDict(regionName);
if (finder.isDict())
{
return finder.dict();
}
} }
return (dictptr ? *dictptr : dictionary::null);
return dictionary::null;
} }
@ -232,19 +247,14 @@ const Foam::dictionary& Foam::decompositionMethod::findCoeffsDict
int select int select
) )
{ {
dictionary::const_searcher fnd; const bool allowDefault = !(select & selectionType::EXACT);
if const dictionary* dictptr =
( cfindCoeffsDict(dict, coeffsName, allowDefault);
(fnd = dict.csearch(coeffsName)).isDict()
|| if (dictptr)
(
!(select & selectionType::EXACT)
&& (fnd = dict.csearch(defaultName)).isDict()
)
)
{ {
return fnd.dict(); return *dictptr;
} }
// Not found // Not found
@ -261,7 +271,7 @@ const Foam::dictionary& Foam::decompositionMethod::findCoeffsDict
return dictionary::null; return dictionary::null;
} }
return dict; return dict; // Return original dictionary
} }
@ -271,36 +281,24 @@ const Foam::dictionary& Foam::decompositionMethod::findCoeffsDict
int select int select
) const ) const
{ {
dictionary::const_searcher fnd; const bool allowDefault = !(select & selectionType::EXACT);
if const dictionary* dictptr = nullptr;
(
!decompRegionDict_.empty() if (!decompRegionDict_.empty())
&&
(
(fnd = decompRegionDict_.csearch(coeffsName)).isDict()
||
(
!(select & selectionType::EXACT)
&& (fnd = decompRegionDict_.csearch(defaultName)).isDict()
)
)
)
{ {
return fnd.dict(); // Region-specific dictionary
dictptr = cfindCoeffsDict(decompRegionDict_, coeffsName, allowDefault);
}
if (!dictptr)
{
// General
dictptr = cfindCoeffsDict(decompDict_, coeffsName, allowDefault);
} }
if if (dictptr)
(
(fnd = decompDict_.csearch(coeffsName)).isDict()
||
(
!(select & selectionType::EXACT)
&& (fnd = decompDict_.csearch(defaultName)).isDict()
)
)
{ {
return fnd.dict(); return *dictptr;
} }
// Not found // Not found
@ -317,25 +315,12 @@ const Foam::dictionary& Foam::decompositionMethod::findCoeffsDict
return dictionary::null; return dictionary::null;
} }
return decompDict_; return decompDict_; // Return general dictionary
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::decompositionMethod::decompositionMethod
(
const dictionary& decompDict
)
:
decompDict_(decompDict),
decompRegionDict_(dictionary::null),
nDomains_(nDomains(decompDict))
{
readConstraints();
}
Foam::decompositionMethod::decompositionMethod Foam::decompositionMethod::decompositionMethod
( (
const dictionary& decompDict, const dictionary& decompDict,
@ -357,10 +342,14 @@ Foam::decompositionMethod::decompositionMethod
Foam::autoPtr<Foam::decompositionMethod> Foam::decompositionMethod::New Foam::autoPtr<Foam::decompositionMethod> Foam::decompositionMethod::New
( (
const dictionary& decompDict const dictionary& decompDict,
const word& regionName
) )
{ {
const word methodType(decompDict.get<word>("method")); word methodType(decompDict.get<word>("method"));
const dictionary& regionDict = optionalRegionDict(decompDict, regionName);
regionDict.readIfPresent("method", methodType);
auto cstrIter = dictionaryConstructorTablePtr_->cfind(methodType); auto cstrIter = dictionaryConstructorTablePtr_->cfind(methodType);
@ -377,52 +366,14 @@ Foam::autoPtr<Foam::decompositionMethod> Foam::decompositionMethod::New
// verbose // verbose
{ {
Info<< "Selecting decompositionMethod " << methodType Info<< "Decomposition method " << methodType
<< " [" << (nDomains(decompDict)) << "]" << endl; << " [" << (nDomains(decompDict, regionName)) << ']';
}
return autoPtr<decompositionMethod>(cstrIter()(decompDict)); if (!regionName.empty())
} {
Info<< " (region " << regionName << ')';
}
Foam::autoPtr<Foam::decompositionMethod> Foam::decompositionMethod::New Info<< endl;
(
const dictionary& decompDict,
const word& regionName
)
{
const dictionary& regionDict(optionalRegionDict(decompDict, regionName));
if (regionDict.empty())
{
// No region-specific information - just forward to normal routine
return decompositionMethod::New(decompDict);
}
word methodType(decompDict.get<word>("method"));
regionDict.readIfPresent("method", methodType);
auto cstrIter = dictionaryRegionConstructorTablePtr_->cfind(methodType);
if (!cstrIter.found())
{
WarningInFunction
<< nl
<< "Unknown region decompositionMethod "
<< methodType << nl << nl
<< "Valid decompositionMethods : " << endl
<< dictionaryRegionConstructorTablePtr_->sortedToc() << nl
<< "Reverting to non-region version" << nl
<< endl;
return decompositionMethod::New(decompDict);
}
// verbose
{
Info<< "Selecting decompositionMethod " << methodType
<< " [" << (nDomains(decompDict, regionName)) << "] (region "
<< regionName << ")" << endl;
} }
return autoPtr<decompositionMethod>(cstrIter()(decompDict, regionName)); return autoPtr<decompositionMethod>(cstrIter()(decompDict, regionName));
@ -1368,4 +1319,27 @@ Foam::labelList Foam::decompositionMethod::decompose
} }
// * * * * * * * * * * * * * * * Stub Functions * * * * * * * * * * * * * * //
Foam::labelList Foam::decompositionMethod::decompose
(
const pointField& points,
const scalarField& pointWeights
) const
{
NotImplemented;
return labelList();
}
Foam::labelList Foam::decompositionMethod::decompose
(
const pointField& points
) const
{
NotImplemented;
return labelList();
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -150,17 +150,6 @@ public:
autoPtr, autoPtr,
decompositionMethod, decompositionMethod,
dictionary, dictionary,
(
const dictionary& decompDict
),
(decompDict)
);
declareRunTimeSelectionTable
(
autoPtr,
decompositionMethod,
dictionaryRegion,
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName
@ -171,19 +160,17 @@ public:
// Static Methods // Static Methods
//- Return the \c numberOfSubdomains entry from the dictionary //- Return region-specific or top-level \c numberOfSubdomains entry.
static label nDomains(const dictionary& decompDict); // The region-specific version is found within the "regions"
// sub-dictionary.
//- Return the \c numberOfSubdomains from a region within the
// "regions" sub-dictionary
static label nDomains static label nDomains
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName = ""
); );
//- Return an optional region dictionary from "regions" sub-dictionary //- Return an optional region-specific dictionary
// or dictionary::null on failure. //- from "regions" sub-dictionary, or dictionary::null on failure
static const dictionary& optionalRegionDict static const dictionary& optionalRegionDict
( (
const dictionary& decompDict, const dictionary& decompDict,
@ -193,31 +180,23 @@ public:
// Selectors // Selectors
//- Return a reference to the selected decomposition method
static autoPtr<decompositionMethod> New
(
const dictionary& decompDict
);
//- Return a reference to the selected decomposition method, //- Return a reference to the selected decomposition method,
//- with region specification //- optionally region-specific
static autoPtr<decompositionMethod> New static autoPtr<decompositionMethod> New
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName = ""
); );
// Constructors // Constructors
//- Construct given the decomposition dictionary //- Construct given the decomposition dictionary,
decompositionMethod(const dictionary& decompDict); //- optionally region-specific
explicit decompositionMethod
//- Construct given the decomposition dictionary for specific region
decompositionMethod
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName = ""
); );
@ -228,7 +207,7 @@ public:
// Member Functions // Member Functions
//- Number of domains //- Number of domains
inline label nDomains() const inline label nDomains() const noexcept
{ {
return nDomains_; return nDomains_;
} }
@ -240,23 +219,15 @@ public:
// No topology (implemented by geometric decomposers) // No topology (implemented by geometric decomposers)
//- Return for every coordinate the wanted processor number. //- Return the wanted processor number for every coordinate.
virtual labelList decompose virtual labelList decompose
( (
const pointField& points, const pointField& points,
const scalarField& pointWeights const scalarField& pointWeights
) const ) const;
{
NotImplemented;
return labelList();
}
//- Decompose with uniform weights on the points //- Decompose with uniform weights on the points
virtual labelList decompose(const pointField& points) const virtual labelList decompose(const pointField& points) const;
{
NotImplemented;
return labelList();
}
// Topology provided by mesh // Topology provided by mesh
@ -419,7 +390,6 @@ public:
const polyMesh& mesh, const polyMesh& mesh,
const scalarField& cWeights const scalarField& cWeights
) const; ) const;
}; };

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -36,20 +36,12 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(hierarchGeomDecomp, 0); defineTypeNameAndDebug(hierarchGeomDecomp, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
hierarchGeomDecomp, hierarchGeomDecomp,
dictionary dictionary
); );
addToRunTimeSelectionTable
(
decompositionMethod,
hierarchGeomDecomp,
dictionaryRegion
);
} }
@ -718,18 +710,6 @@ Foam::label Foam::hierarchGeomDecomp::sortComponent
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::hierarchGeomDecomp::hierarchGeomDecomp
(
const dictionary& decompDict
)
:
geomDecomp(typeName, decompDict),
order_({0,1,2})
{
setOrder();
}
Foam::hierarchGeomDecomp::hierarchGeomDecomp Foam::hierarchGeomDecomp::hierarchGeomDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -187,14 +187,11 @@ public:
// Constructors // Constructors
//- Construct given the decomposition dictionary //- Construct given decomposition dictionary and optional region name
hierarchGeomDecomp(const dictionary& decompDict); explicit hierarchGeomDecomp
//- Construct for decomposition dictionary and region name
hierarchGeomDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName = ""
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -30,40 +30,22 @@ License
#include "labelIOList.H" #include "labelIOList.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(manualDecomp, 0); defineTypeNameAndDebug(manualDecomp, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
manualDecomp, manualDecomp,
dictionary dictionary
); );
addToRunTimeSelectionTable
(
decompositionMethod,
manualDecomp,
dictionaryRegion
);
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::manualDecomp::manualDecomp(const dictionary& decompDict)
:
decompositionMethod(decompDict),
dataFile_
(
findCoeffsDict(typeName + "Coeffs").get<fileName>("dataFile")
)
{}
Foam::manualDecomp::manualDecomp Foam::manualDecomp::manualDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -57,7 +57,7 @@ class manualDecomp
: :
public decompositionMethod public decompositionMethod
{ {
// Private data // Private Data
fileName dataFile_; fileName dataFile_;
@ -79,14 +79,11 @@ public:
// Constructors // Constructors
//- Construct given the decomposition dictionary //- Construct given decomposition dictionary and optional region name
manualDecomp(const dictionary& decompDict); explicit manualDecomp
//- Construct given the decomposition dictionary and region name
manualDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName = ""
); );
@ -124,7 +121,6 @@ public:
NotImplemented; NotImplemented;
return labelList(); return labelList();
} }
}; };

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -154,18 +154,6 @@ Foam::label Foam::metisLikeDecomp::decomposeGeneral
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::metisLikeDecomp::metisLikeDecomp
(
const word& derivedType,
const dictionary& decompDict,
int select
)
:
decompositionMethod(decompDict),
coeffsDict_(findCoeffsDict(derivedType + "Coeffs", select))
{}
Foam::metisLikeDecomp::metisLikeDecomp Foam::metisLikeDecomp::metisLikeDecomp
( (
const word& derivedType, const word& derivedType,
@ -191,10 +179,10 @@ Foam::labelList Foam::metisLikeDecomp::decompose
if (points.size() != mesh.nCells()) if (points.size() != mesh.nCells())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Can use this decomposition method only for entire mesh" << nl << "Can only use this decomposition method for entire mesh" << nl
<< "and supply one coordinate (cellCentre) for every cell." << nl << "and supply one coordinate (cellCentre) for every cell." << nl
<< "The number of coordinates " << points.size() << nl << "The number of coordinates " << points.size() << nl
<< "The number of cells in the mesh " << mesh.nCells() << "The number of cells in the mesh " << mesh.nCells() << nl
<< exit(FatalError); << exit(FatalError);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -81,6 +81,7 @@ protected:
labelList& decomp labelList& decomp
) const = 0; ) const = 0;
//- No copy construct //- No copy construct
metisLikeDecomp(const metisLikeDecomp&) = delete; metisLikeDecomp(const metisLikeDecomp&) = delete;
@ -88,23 +89,21 @@ protected:
void operator=(const metisLikeDecomp&) = delete; void operator=(const metisLikeDecomp&) = delete;
public:
// Constructors // Constructors
//- Construct for derived type name and decomposition dictionary. //- Construct for derived type name and decomposition dictionary.
// The default search for the coefficients will return dictionary::null
// on failure. This avoids a name clash of a metis "method" with the
// top level.
metisLikeDecomp metisLikeDecomp
( (
const word& derivedType, const word& derivedType,
const dictionary& decompDict, const dictionary& decompDict,
int select = selectionType::NULL_DICT int select = selectionType::NULL_DICT
); )
:
metisLikeDecomp(derivedType, decompDict, "", select)
{}
//- Construct for derived type name, decomposition dictionary //- Construct for derived type name, decomposition dictionary
//- and region name //- and (optional) region name
// The default search for the coefficients will return dictionary::null // The default search for the coefficients will return dictionary::null
// on failure. This avoids a name clash of a metis "method" with the // on failure. This avoids a name clash of a metis "method" with the
// top level. // top level.
@ -116,6 +115,7 @@ public:
int select = selectionType::NULL_DICT int select = selectionType::NULL_DICT
); );
public:
//- Destructor //- Destructor
virtual ~metisLikeDecomp() = default; virtual ~metisLikeDecomp() = default;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -32,25 +32,17 @@ License
#include "globalIndex.H" #include "globalIndex.H"
#include "mapDistribute.H" #include "mapDistribute.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(multiLevelDecomp, 0); defineTypeNameAndDebug(multiLevelDecomp, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
multiLevelDecomp, multiLevelDecomp,
dictionary dictionary
); );
addToRunTimeSelectionTable
(
decompositionMethod,
multiLevelDecomp,
dictionaryRegion
);
} }
@ -568,25 +560,6 @@ void Foam::multiLevelDecomp::decompose
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::multiLevelDecomp::multiLevelDecomp(const dictionary& decompDict)
:
decompositionMethod(decompDict),
coeffsDict_
(
findCoeffsDict
(
typeName + "Coeffs",
(selectionType::EXACT | selectionType::MANDATORY)
)
),
methodsDict_(),
methods_()
{
createMethodsDict();
setMethods();
}
Foam::multiLevelDecomp::multiLevelDecomp Foam::multiLevelDecomp::multiLevelDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -51,7 +51,7 @@ class multiLevelDecomp
: :
public decompositionMethod public decompositionMethod
{ {
// Private data // Private Data
//- Original coefficients for this method //- Original coefficients for this method
const dictionary& coeffsDict_; const dictionary& coeffsDict_;
@ -114,14 +114,11 @@ public:
// Constructors // Constructors
//- Construct given the decomposition dictionary //- Construct given decomposition dictionary and optional region name
multiLevelDecomp(const dictionary& decompDict); explicit multiLevelDecomp
//- Construct given decomposition dictionary and region name
multiLevelDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName = ""
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012 OpenFOAM Foundation Copyright (C) 2012 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -29,12 +29,11 @@ License
#include "noDecomp.H" #include "noDecomp.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeName(noDecomp); defineTypeName(noDecomp);
addNamedToRunTimeSelectionTable addNamedToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
@ -42,25 +41,11 @@ namespace Foam
dictionary, dictionary,
none none
); );
addNamedToRunTimeSelectionTable
(
decompositionMethod,
noDecomp,
dictionaryRegion,
none
);
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::noDecomp::noDecomp(const dictionary& decompDict)
:
decompositionMethod(decompDict)
{}
Foam::noDecomp::noDecomp Foam::noDecomp::noDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -53,7 +53,6 @@ class noDecomp
: :
public decompositionMethod public decompositionMethod
{ {
// Private Member Functions // Private Member Functions
//- No copy construct //- No copy construct
@ -66,19 +65,16 @@ class noDecomp
public: public:
//- Runtime type information //- Runtime type information
TypeName("noDecomp"); TypeNameNoDebug("none");
// Constructors // Constructors
//- Construct given the decomposition dictionary //- Construct given decomposition dictionary and optional region name
noDecomp(const dictionary& decompDict); explicit noDecomp
//- Construct given the decomposition dictionary and region name
noDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName = ""
); );
@ -88,7 +84,7 @@ public:
// Member Functions // Member Functions
//- Does not care about proc boundaries, it is all up to the user. //- Does not care about proc boundaries
virtual bool parallelAware() const virtual bool parallelAware() const
{ {
return true; return true;
@ -122,7 +118,6 @@ public:
{ {
return labelList(globalCellCells.size(), Pstream::myProcNo()); return labelList(globalCellCells.size(), Pstream::myProcNo());
} }
}; };

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -29,25 +29,17 @@ License
#include "Random.H" #include "Random.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(randomDecomp, 0); defineTypeName(randomDecomp);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
randomDecomp, randomDecomp,
dictionary dictionary
); );
addToRunTimeSelectionTable
(
decompositionMethod,
randomDecomp,
dictionaryRegion
);
} }
@ -70,12 +62,6 @@ Foam::labelList Foam::randomDecomp::randomMap(const label nCells) const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::randomDecomp::randomDecomp(const dictionary& decompDict)
:
decompositionMethod(decompDict)
{}
Foam::randomDecomp::randomDecomp Foam::randomDecomp::randomDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -65,19 +65,16 @@ class randomDecomp
public: public:
//- Runtime type information //- Runtime type information
TypeName("random"); TypeNameNoDebug("random");
// Constructors // Constructors
//- Construct given the decomposition dictionary //- Construct for decomposition dictionary and optional region name
randomDecomp(const dictionary& decompDict); explicit randomDecomp
//- Construct for decomposition dictionary and region name
randomDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName = ""
); );
@ -93,6 +90,7 @@ public:
return true; return true;
} }
// No topology (implemented by geometric decomposers) // No topology (implemented by geometric decomposers)
//- Return for every coordinate the wanted processor number. //- Return for every coordinate the wanted processor number.

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -32,28 +32,51 @@ License
#include "globalIndex.H" #include "globalIndex.H"
#include "SubField.H" #include "SubField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(simpleGeomDecomp, 0); defineTypeNameAndDebug(simpleGeomDecomp, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
simpleGeomDecomp, simpleGeomDecomp,
dictionary dictionary
); );
addToRunTimeSelectionTable
(
decompositionMethod,
simpleGeomDecomp,
dictionaryRegion
);
} }
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
// A list compare binary predicate for normal sort by vector component
struct vectorLessOp
{
const UList<vector>& values;
direction sortCmpt;
vectorLessOp(const UList<vector>& list, direction cmpt = vector::X)
:
values(list),
sortCmpt(cmpt)
{}
void setComponent(direction cmpt)
{
sortCmpt = cmpt;
}
bool operator()(const label a, const label b) const
{
return values[a][sortCmpt] < values[b][sortCmpt];
}
};
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// assignToProcessorGroup : given nCells cells and nProcGroup processor // assignToProcessorGroup : given nCells cells and nProcGroup processor
@ -149,24 +172,20 @@ Foam::labelList Foam::simpleGeomDecomp::decomposeOneProc
labelList processorGroups(points.size()); labelList processorGroups(points.size());
labelList pointIndices(points.size()); labelList pointIndices(identity(points.size()));
forAll(pointIndices, i)
{
pointIndices[i] = i;
}
const pointField rotatedPoints(rotDelta_ & points); const pointField rotatedPoints(rotDelta_ & points);
vectorLessOp sorter(rotatedPoints);
// and one to take the processor group id's. For each direction. // and one to take the processor group id's. For each direction.
// we assign the processors to groups of processors labelled // we assign the processors to groups of processors labelled
// 0..nX to give a banded structure on the mesh. Then we // 0..nX to give a banded structure on the mesh. Then we
// construct the actual processor number by treating this as // construct the actual processor number by treating this as
// the units part of the processor number. // the units part of the processor number.
sort
( sorter.setComponent(vector::X);
pointIndices, Foam::sort(pointIndices, sorter);
UList<scalar>::less(rotatedPoints.component(vector::X))
);
assignToProcessorGroup(processorGroups, n_.x()); assignToProcessorGroup(processorGroups, n_.x());
@ -178,11 +197,9 @@ Foam::labelList Foam::simpleGeomDecomp::decomposeOneProc
// now do the same thing in the Y direction. These processor group // now do the same thing in the Y direction. These processor group
// numbers add multiples of nX to the proc. number (columns) // numbers add multiples of nX to the proc. number (columns)
sort
( sorter.setComponent(vector::Y);
pointIndices, Foam::sort(pointIndices, sorter);
UList<scalar>::less(rotatedPoints.component(vector::Y))
);
assignToProcessorGroup(processorGroups, n_.y()); assignToProcessorGroup(processorGroups, n_.y());
@ -194,11 +211,9 @@ Foam::labelList Foam::simpleGeomDecomp::decomposeOneProc
// finally in the Z direction. Now we add multiples of nX*nY to give // finally in the Z direction. Now we add multiples of nX*nY to give
// layers // layers
sort
( sorter.setComponent(vector::Z);
pointIndices, Foam::sort(pointIndices, sorter);
UList<scalar>::less(rotatedPoints.component(vector::Z))
);
assignToProcessorGroup(processorGroups, n_.z()); assignToProcessorGroup(processorGroups, n_.z());
@ -222,24 +237,20 @@ Foam::labelList Foam::simpleGeomDecomp::decomposeOneProc
labelList processorGroups(points.size()); labelList processorGroups(points.size());
labelList pointIndices(points.size()); labelList pointIndices(identity(points.size()));
forAll(pointIndices, i)
{
pointIndices[i] = i;
}
const pointField rotatedPoints(rotDelta_ & points); const pointField rotatedPoints(rotDelta_ & points);
vectorLessOp sorter(rotatedPoints);
// and one to take the processor group id's. For each direction. // and one to take the processor group id's. For each direction.
// we assign the processors to groups of processors labelled // we assign the processors to groups of processors labelled
// 0..nX to give a banded structure on the mesh. Then we // 0..nX to give a banded structure on the mesh. Then we
// construct the actual processor number by treating this as // construct the actual processor number by treating this as
// the units part of the processor number. // the units part of the processor number.
sort
( sorter.setComponent(vector::X);
pointIndices, Foam::sort(pointIndices, sorter);
UList<scalar>::less(rotatedPoints.component(vector::X))
);
const scalar summedWeights = sum(weights); const scalar summedWeights = sum(weights);
assignToProcessorGroup assignToProcessorGroup
@ -259,11 +270,9 @@ Foam::labelList Foam::simpleGeomDecomp::decomposeOneProc
// now do the same thing in the Y direction. These processor group // now do the same thing in the Y direction. These processor group
// numbers add multiples of nX to the proc. number (columns) // numbers add multiples of nX to the proc. number (columns)
sort
( sorter.setComponent(vector::Y);
pointIndices, Foam::sort(pointIndices, sorter);
UList<scalar>::less(rotatedPoints.component(vector::Y))
);
assignToProcessorGroup assignToProcessorGroup
( (
@ -282,11 +291,9 @@ Foam::labelList Foam::simpleGeomDecomp::decomposeOneProc
// finally in the Z direction. Now we add multiples of nX*nY to give // finally in the Z direction. Now we add multiples of nX*nY to give
// layers // layers
sort
( sorter.setComponent(vector::Z);
pointIndices, Foam::sort(pointIndices, sorter);
UList<scalar>::less(rotatedPoints.component(vector::Z))
);
assignToProcessorGroup assignToProcessorGroup
( (
@ -308,12 +315,6 @@ Foam::labelList Foam::simpleGeomDecomp::decomposeOneProc
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::simpleGeomDecomp::simpleGeomDecomp(const dictionary& decompDict)
:
geomDecomp(typeName, decompDict)
{}
Foam::simpleGeomDecomp::simpleGeomDecomp Foam::simpleGeomDecomp::simpleGeomDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -95,14 +95,11 @@ public:
// Constructors // Constructors
//- Construct given decomposition dictionary //- Construct given decomposition dictionary and optional region name
simpleGeomDecomp(const dictionary& decompDict); explicit simpleGeomDecomp
//- Construct given decomposition dictionary and region name
simpleGeomDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName = ""
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -32,12 +32,11 @@ License
#include "topoDistanceData.H" #include "topoDistanceData.H"
#include "fvMeshSubset.H" #include "fvMeshSubset.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(structuredDecomp, 0); defineTypeNameAndDebug(structuredDecomp, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
@ -49,7 +48,11 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::structuredDecomp::structuredDecomp(const dictionary& decompDict) Foam::structuredDecomp::structuredDecomp
(
const dictionary& decompDict,
const word& regionName
)
: :
decompositionMethod(decompDict), decompositionMethod(decompDict),
methodDict_(findCoeffsDict(typeName + "Coeffs", selectionType::MANDATORY)), methodDict_(findCoeffsDict(typeName + "Coeffs", selectionType::MANDATORY)),

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -52,7 +52,7 @@ class structuredDecomp
: :
public decompositionMethod public decompositionMethod
{ {
// Private data // Private Data
dictionary methodDict_; dictionary methodDict_;
@ -78,8 +78,12 @@ public:
// Constructors // Constructors
//- Construct given the decomposition dictionary //- Construct given decomposition dictionary. Region ignored
structuredDecomp(const dictionary& decompDict); explicit structuredDecomp
(
const dictionary& decompDict,
const word& regionName = ""
);
//- Destructor //- Destructor

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -44,20 +44,12 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(kahipDecomp, 0); defineTypeNameAndDebug(kahipDecomp, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
kahipDecomp, kahipDecomp,
dictionary dictionary
); );
addToRunTimeSelectionTable
(
decompositionMethod,
kahipDecomp,
dictionaryRegion
);
} }
@ -273,12 +265,6 @@ Foam::label Foam::kahipDecomp::decomposeSerial
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::kahipDecomp::kahipDecomp(const dictionary& decompDict)
:
metisLikeDecomp(typeName, decompDict, selectionType::NULL_DICT)
{}
Foam::kahipDecomp::kahipDecomp Foam::kahipDecomp::kahipDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -121,14 +121,11 @@ public:
// Constructors // Constructors
//- Construct given the decomposition dictionary //- Construct given decomposition dictionary and optional region name
kahipDecomp(const dictionary& decompDict); explicit kahipDecomp
//- Construct given the decomposition dictionary and region name
kahipDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName = ""
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -55,20 +55,12 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(metisDecomp, 0); defineTypeNameAndDebug(metisDecomp, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
metisDecomp, metisDecomp,
dictionary dictionary
); );
addToRunTimeSelectionTable
(
decompositionMethod,
metisDecomp,
dictionaryRegion
);
} }
@ -246,12 +238,6 @@ Foam::label Foam::metisDecomp::decomposeSerial
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::metisDecomp::metisDecomp(const dictionary& decompDict)
:
metisLikeDecomp(typeName, decompDict, selectionType::NULL_DICT)
{}
Foam::metisDecomp::metisDecomp Foam::metisDecomp::metisDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -105,14 +105,11 @@ public:
// Constructors // Constructors
//- Construct given the decomposition dictionary //- Construct given decomposition dictionary and optional region name
metisDecomp(const dictionary& decompDict); explicit metisDecomp
//- Construct given the decomposition dictionary and region name
metisDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName = ""
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -61,20 +61,12 @@ static_assert
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(ptscotchDecomp, 0); defineTypeNameAndDebug(ptscotchDecomp, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
ptscotchDecomp, ptscotchDecomp,
dictionary dictionary
); );
addToRunTimeSelectionTable
(
decompositionMethod,
ptscotchDecomp,
dictionaryRegion
);
} }
@ -644,13 +636,6 @@ Foam::label Foam::ptscotchDecomp::decompose
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ptscotchDecomp::ptscotchDecomp(const dictionary& decompDict)
:
decompositionMethod(decompDict),
coeffsDict_(findCoeffsDict("scotchCoeffs", selectionType::NULL_DICT))
{}
Foam::ptscotchDecomp::ptscotchDecomp Foam::ptscotchDecomp::ptscotchDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,
@ -677,11 +662,10 @@ Foam::labelList Foam::ptscotchDecomp::decompose
if (points.size() != mesh.nCells()) if (points.size() != mesh.nCells())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Can use this decomposition method only for the whole mesh" << "Can only use this decomposition method for entire mesh" << nl
<< endl << "and supply one coordinate (cellCentre) for every cell." << nl
<< "and supply one coordinate (cellCentre) for every cell." << endl << "The number of coordinates " << points.size() << nl
<< "The number of coordinates " << points.size() << endl << "The number of cells in the mesh " << mesh.nCells() << nl
<< "The number of cells in the mesh " << mesh.nCells()
<< exit(FatalError); << exit(FatalError);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -70,7 +70,7 @@ class ptscotchDecomp
: :
public decompositionMethod public decompositionMethod
{ {
// Private data // Private Data
//- Original coefficients for this method //- Original coefficients for this method
dictionary coeffsDict_; dictionary coeffsDict_;
@ -123,12 +123,12 @@ public:
// Constructors // Constructors
//- Construct given the decomposition dictionary //- Construct given decomposition dictionary and optional region name
ptscotchDecomp(const dictionary& decompDict); explicit ptscotchDecomp
(
const dictionary& decompDict,
//- Construct given the decomposition dictionary and region name const word& regionName = ""
ptscotchDecomp(const dictionary& decompDict, const word& regionName); );
//- Destructor //- Destructor

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -60,20 +60,12 @@ static_assert
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(scotchDecomp, 0); defineTypeNameAndDebug(scotchDecomp, 0);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionMethod, decompositionMethod,
scotchDecomp, scotchDecomp,
dictionary dictionary
); );
addToRunTimeSelectionTable
(
decompositionMethod,
scotchDecomp,
dictionaryRegion
);
} }
@ -380,12 +372,6 @@ Foam::label Foam::scotchDecomp::decomposeSerial
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::scotchDecomp::scotchDecomp(const dictionary& decompDict)
:
metisLikeDecomp(typeName, decompDict, selectionType::NULL_DICT)
{}
Foam::scotchDecomp::scotchDecomp Foam::scotchDecomp::scotchDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -276,14 +276,11 @@ public:
// Constructors // Constructors
//- Construct given the decomposition dictionary //- Construct given decomposition dictionary and optional region name
scotchDecomp(const dictionary& decompDict); explicit scotchDecomp
//- Construct given the decomposition dictionary and region name
scotchDecomp
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName = ""
); );