Commit 83454524 authored by Mark Olesen's avatar Mark Olesen Committed by Andrew Heather
Browse files

STYLE: additional constructor for randomDecomp

parent d88b9569
......@@ -24,8 +24,8 @@ License
\*---------------------------------------------------------------------------*/
#include "randomDecomp.H"
#include "addToRunTimeSelectionTable.H"
#include "Random.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -39,14 +39,48 @@ namespace Foam
randomDecomp,
dictionary
);
addToRunTimeSelectionTable
(
decompositionMethod,
randomDecomp,
dictionaryRegion
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::labelList Foam::randomDecomp::decompose(const label nCells) const
{
Random rndGen(0);
labelList finalDecomp(nCells);
for (label& val : finalDecomp)
{
val = rndGen.position<label>(0, nDomains_ - 1);
}
return finalDecomp;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::randomDecomp::randomDecomp(const dictionary& decompositionDict)
Foam::randomDecomp::randomDecomp(const dictionary& decompDict)
:
decompositionMethod(decompositionDict)
decompositionMethod(decompDict)
{}
Foam::randomDecomp::randomDecomp
(
const dictionary& decompDict,
const word& regionName
)
:
decompositionMethod(decompDict, regionName)
{}
......@@ -55,19 +89,11 @@ Foam::randomDecomp::randomDecomp(const dictionary& decompositionDict)
Foam::labelList Foam::randomDecomp::decompose
(
const polyMesh& mesh,
const pointField& points,
const scalarField& pointWeights
const pointField&,
const scalarField&
) const
{
Random rndGen(0);
labelList finalDecomp(mesh.nCells());
forAll(finalDecomp, celli)
{
finalDecomp[celli] = rndGen.position<label>(0, nDomains_ - 1);
}
return finalDecomp;
return decompose(mesh.nCells()); // or cc.size()
}
......@@ -78,15 +104,7 @@ Foam::labelList Foam::randomDecomp::decompose
const scalarField&
) const
{
Random rndGen(0);
labelList finalDecomp(globalCellCells.size());
forAll(finalDecomp, celli)
{
finalDecomp[celli] = rndGen.position<label>(0, nDomains_ - 1);
}
return finalDecomp;
return decompose(globalCellCells.size()); // or cc.size()
}
......
......@@ -41,7 +41,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class randomDecomp Declaration
Class randomDecomp Declaration
\*---------------------------------------------------------------------------*/
class randomDecomp
......@@ -50,9 +50,14 @@ class randomDecomp
{
// Private Member Functions
//- Disallow default bitwise copy construct and assignment
void operator=(const randomDecomp&);
randomDecomp(const randomDecomp&);
//- Random distribution on the 0-nCells interval
labelList decompose(const label nCells) const;
//- No copy construct
void operator=(const randomDecomp&) = delete;
//- No copy assignment
randomDecomp(const randomDecomp&) = delete;
public:
......@@ -64,24 +69,29 @@ public:
// Constructors
//- Construct given the decomposition dictionary
randomDecomp(const dictionary& decompositionDict);
randomDecomp(const dictionary& decompDict);
//- Construct for decomposition dictionary and region name
randomDecomp
(
const dictionary& decompDict,
const word& regionName
);
//- Destructor
virtual ~randomDecomp()
{}
virtual ~randomDecomp() = default;
// Member Functions
//- Manual decompose does not care about proc boundaries - is all
// up to the user.
//- Does not care about proc boundaries
virtual bool parallelAware() const
{
return true;
}
//- Return for every coordinate the wanted processor number. Use the
// mesh connectivity (if needed)
//- Return for every coordinate the wanted processor number.
virtual labelList decompose
(
const polyMesh& mesh,
......@@ -89,13 +99,8 @@ public:
const scalarField& cWeights
) const;
//- Return for every coordinate the wanted processor number. Explicitly
// provided connectivity - does not use mesh_.
// The connectivity is equal to mesh.cellCells() except for
// - in parallel the cell numbers are global cell numbers (starting
// from 0 at processor0 and then incrementing all through the
// processors)
// - the connections are across coupled patches
//- Return for every coordinate the wanted processor number.
// Explicitly provided connectivity - does not use mesh_.
virtual labelList decompose
(
const labelListList& globalCellCells,
......
Markdown is supported
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