ENH: use List instead of UList for internal decomposition implementation

- enables future use of precision adaptors
This commit is contained in:
Mark Olesen 2019-10-29 10:46:33 +01:00 committed by Andrew Heather
parent 4e706c2625
commit 328513fcaa
18 changed files with 183 additions and 462 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
@ -37,13 +37,9 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
static const char* notImplementedMessage =
"You are trying to use MGridGen but do not have the MGridGen library loaded.\n"
"This message is from the dummy MGridGen stub library instead.\n"
"\n"
"Normally the MGridGen library will be loaded through the LD_LIBRARY_PATH\n"
"environment variable but you are picking up this dummy library from the\n"
"$FOAM_LIBBIN/dummy directory. Please install MGridGen and make sure the\n"
"libMGridGen.so is in your LD_LIBRARY_PATH.";
"Attempted use <MGridGen> without the MGridGen library loaded.\n"
"This message is from the dummy MGridGen stub library instead.\n\n"
"Please install <MGridGen> and ensure libMGridGen.so is in LD_LIBRARY_PATH.\n";
#ifdef __cplusplus
extern "C"

View File

@ -47,10 +47,6 @@ SourceFiles
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
/*---------------------------------------------------------------------------*\
Class metis Declaration
\*---------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
#endif

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,17 +25,15 @@ License
#include "kahipDecomp.H"
#include "addToRunTimeSelectionTable.H"
#include "Time.H"
static const char* notImplementedMessage =
"You are trying to use kahip but do not have the kahipDecomp library loaded."
"\nThis message is from the dummy kahipDecomp stub library instead.\n"
"\n"
"Please install kahip and make sure that libkahip.so is in your "
"LD_LIBRARY_PATH.\n"
"Attempted to use <kahip> without the kahipDecomp library loaded.\n"
"This message is from the dummy kahipDecomp stub library instead.\n\n"
"Please install <kahip> and ensure libkahip.so is in LD_LIBRARY_PATH.\n"
"The kahipDecomp library can then be built from "
"src/parallel/decompose/kahipDecomp and dynamically loading or linking"
" this library will add kahip as a decomposition method.\n";
"src/parallel/decompose/kahipDecomp.\n"
"Dynamically loading or linking this library will add "
"<kahip> as a decomposition method.\n";
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -52,14 +50,14 @@ namespace Foam
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::label Foam::kahipDecomp::decomposeSerial
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cellWeights,
List<label>& decomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cellWeights,
labelList& decomp
) const
{
FatalErrorInFunction

View File

@ -1,12 +1,13 @@
#ifndef KAHIP_H
#define KAHIP_H
/* *** DUMMY VERSION of kaHIP_interface.h - this file should not be included if you have KaHIP
* installed in the correct position in $WM_THIRD_PARTY_DIR - see
* decompositionMethods/kahipDecomp/Make/options
/* *** DUMMY VERSION of kaHIP_interface.h
* This file should not be included if you have kahip correctly installed
* See: etc/config.sh/kahip
* See: src/parallel/decompose/kahipDecomp/Make/options
*/
#warning "Dummy kahip.h - included since it cannot find KaHIP installation."
#warning "Dummy kahip.h - could not find KAHIP installation."
#ifdef __cplusplus
extern "C" {

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
@ -27,17 +27,15 @@ License
#include "metisDecomp.H"
#include "addToRunTimeSelectionTable.H"
#include "Time.H"
static const char* notImplementedMessage =
"You are trying to use metis but do not have the metisDecomp library loaded."
"\nThis message is from the dummy metisDecomp stub library instead.\n"
"\n"
"Please install metis and make sure that libmetis.so is in your "
"LD_LIBRARY_PATH.\n"
"Attempted to use <metis> without the metisDecomp library loaded.\n"
"This message is from the dummy metisDecomp stub library instead.\n\n"
"Please install <metis> and ensure libmetis.so is in LD_LIBRARY_PATH.\n"
"The metisDecomp library can then be built from "
"src/parallel/decompose/metisDecomp and dynamically loading or linking"
" this library will add metis as a decomposition method.\n";
"src/parallel/decompose/metisDecomp.\n"
"Dynamically loading or linking this library will add "
"<metis> as a decomposition method.\n";
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,14 +52,14 @@ namespace Foam
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::label Foam::metisDecomp::decomposeSerial
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cellWeights,
List<label>& decomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cellWeights,
labelList& decomp
) const
{
FatalErrorInFunction

View File

@ -1,12 +1,13 @@
#ifndef METIS_H
#define METIS_H
/* *** DUMMY VERSION of metis.h - this file should not be included if you have metis
* installed in the correct position in $WM_THIRD_PARTY_DIR - see
* decompositionMethods/metisDecomp/Make/options
/* *** DUMMY VERSION of metis.h
* This file should not be included if you have metis correctly installed.
* See: etc/config.sh/metis
* See: src/parallel/decompose/metisDecomp/Make/options
*/
#warning "Dummy metis.h - gets included since it cannot find metis installation."
#warning "Dummy metis.h - could not find METIS installation."
// Integer type: OpenFOAM uses WM_LABEL_SIZE, metis.h uses IDXTYPEWIDTH
#if WM_LABEL_SIZE == 32

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
@ -30,17 +30,16 @@ License
#include "Time.H"
static const char* notImplementedMessage =
"You are trying to use ptscotch but do not have the "
"ptscotchDecomp library loaded."
"\nThis message is from the dummy ptscotchDecomp stub library instead.\n"
"\n"
"Please install ptscotch and make sure that libptscotch.so is in your "
"LD_LIBRARY_PATH.\n"
"The ptscotchDecomp library can then be built in "
"src/parallel/decompose/ptscotchDecomp\n";
"Attempted to use <ptscotch> without the ptscotchDecomp library loaded.\n"
"This message is from the dummy ptscotchDecomp stub library instead.\n\n"
"Please install <ptscotch> and ensure libptscotch.so is in LD_LIBRARY_PATH.\n"
"The ptscotchDecomp library can then be built from "
"src/parallel/decompose/ptscotchDecomp.\n"
"Dynamically loading or linking this library will add "
"<ptscotch> as a decomposition method.\n";
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
@ -54,22 +53,21 @@ namespace Foam
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::ptscotchDecomp::graphPath(const polyMesh& unused) const
{}
void Foam::ptscotchDecomp::graphPath(const polyMesh& unused) const {}
void Foam::ptscotchDecomp::check(const int retVal, const char* str) {}
void Foam::ptscotchDecomp::check(const int retVal, const char* str)
{}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::label Foam::ptscotchDecomp::decompose
(
const labelUList& initxadj,
const labelUList& initadjncy,
const UList<scalar>& initcWeights,
List<label>& finalDecomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cWeights,
labelList& finalDecomp
) const
{
FatalErrorInFunction
@ -79,14 +77,16 @@ Foam::label Foam::ptscotchDecomp::decompose
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::ptscotchDecomp::decompose
(
const label adjncySize,
const label adjncy[],
const label xadjSize,
const label xadj[],
const UList<scalar>& cWeights,
List<label>& finalDecomp
const List<scalar>& cWeights,
labelList& finalDecomp
) const
{
FatalErrorInFunction
@ -131,7 +131,7 @@ Foam::labelList Foam::ptscotchDecomp::decompose
FatalErrorInFunction
<< notImplementedMessage << exit(FatalError);
return labelList::null();
return labelList();
}
@ -146,7 +146,7 @@ Foam::labelList Foam::ptscotchDecomp::decompose
FatalErrorInFunction
<< notImplementedMessage << exit(FatalError);
return labelList::null();
return labelList();
}
@ -160,7 +160,7 @@ Foam::labelList Foam::ptscotchDecomp::decompose
FatalErrorInFunction
<< notImplementedMessage << exit(FatalError);
return labelList::null();
return labelList();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
@ -30,16 +30,16 @@ License
#include "Time.H"
static const char* notImplementedMessage =
"You are trying to use scotch but do not have the scotchDecomp library loaded."
"\nThis message is from the dummy scotchDecomp stub library instead.\n"
"\n"
"Please install scotch and make sure that libscotch.so is in your "
"LD_LIBRARY_PATH.\n"
"The scotchDecomp library can then be built in "
"src/parallel/decompose/decompositionMethods/scotchDecomp\n";
"Attempted to use <scotch> without the scotchDecomp library loaded.\n"
"This message is from the dummy scotchDecomp stub library instead.\n\n"
"Please install <scotch> and ensure libscotch.so is in LD_LIBRARY_PATH.\n"
"The scotchDecomp library can then be built from "
"src/parallel/decompose/scotchDecomp.\n"
"Dynamically loading or linking this library will add "
"<scotch> as a decomposition method.\n";
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
@ -55,24 +55,24 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::scotchDecomp::graphPath(const polyMesh& unused) const
{}
void Foam::scotchDecomp::graphPath(const polyMesh& unused) const {}
void Foam::scotchDecomp::check(const int retVal, const char* str) {}
void Foam::scotchDecomp::check(const int retVal, const char* str)
{}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::label Foam::scotchDecomp::decomposeSerial
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cWeights,
List<label>& decomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cWeights,
labelList& decomp
) const
{
FatalErrorInFunction
<< notImplementedMessage << exit(FatalError);
<< notImplementedMessage << nl
<< exit(FatalError);
return -1;
}
@ -111,7 +111,7 @@ Foam::labelList Foam::scotchDecomp::decompose
FatalErrorInFunction
<< notImplementedMessage << exit(FatalError);
return labelList::null();
return labelList();
}
@ -126,7 +126,7 @@ Foam::labelList Foam::scotchDecomp::decompose
FatalErrorInFunction
<< notImplementedMessage << exit(FatalError);
return labelList::null();
return labelList();
}
@ -140,7 +140,7 @@ Foam::labelList Foam::scotchDecomp::decompose
FatalErrorInFunction
<< notImplementedMessage << exit(FatalError);
return labelList::null();
return labelList();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,10 +31,10 @@ License
Foam::label Foam::metisLikeDecomp::decomposeGeneral
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cWeights,
List<label>& decomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cWeights,
labelList& decomp
) const
{
if (!Pstream::parRun())
@ -131,7 +131,9 @@ Foam::label Foam::metisLikeDecomp::decomposeGeneral
Pstream::commsTypes::scheduled,
Pstream::masterNo()
);
toMaster<< adjncy << SubList<label>(xadj, xadj.size()-1)
toMaster
<< adjncy
<< SubList<label>(xadj, xadj.size()-1)
<< cWeights;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -51,18 +51,9 @@ class metisLikeDecomp
:
public decompositionMethod
{
// Private Member Functions
//- No copy construct
metisLikeDecomp(const metisLikeDecomp&) = delete;
//- No copy assignment
void operator=(const metisLikeDecomp&) = delete;
protected:
// Protected data
// Protected Data
//- Coefficients for all derived methods
const dictionary& coeffsDict_;
@ -73,21 +64,28 @@ protected:
//- Serial and/or collect/distribute for parallel operation
virtual label decomposeGeneral
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cellWeights,
List<label>& decomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cellWeights,
labelList& decomp
) const;
//- Decomposition with metis-like parameters
virtual label decomposeSerial
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cellWeights,
List<label>& decomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cellWeights,
labelList& decomp
) const = 0;
//- No copy construct
metisLikeDecomp(const metisLikeDecomp&) = delete;
//- No copy assignment
void operator=(const metisLikeDecomp&) = delete;
public:
// Constructors

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -70,14 +70,14 @@ Foam::kahipDecomp::configNames
});
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::label Foam::kahipDecomp::decomposeSerial
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cWeights,
List<label>& decomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cWeights,
labelList& decomp
) const
{
// Default setup
@ -159,7 +159,7 @@ Foam::label Foam::kahipDecomp::decomposeSerial
// Verify sizing
int n = 1;
for (auto val : labels)
for (const auto val : labels)
{
n *= val;
vec.push_back(val);
@ -220,8 +220,8 @@ Foam::label Foam::kahipDecomp::decomposeSerial
#if WM_LABEL_SIZE == 32
// Input:
int* xadjPtr = const_cast<UList<int>&>(xadj).begin();
int* adjncyPtr = const_cast<UList<int>&>(adjncy).begin();
int* xadjPtr = const_cast<int*>(xadj.begin());
int* adjncyPtr = const_cast<int*>(adjncy.begin());
// Output: cell -> processor addressing
decomp.setSize(numCells);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,16 +74,17 @@ class kahipDecomp
:
public metisLikeDecomp
{
protected:
// Private Member Functions
// Protected Member Functions
//- Call kahip with options from dictionary.
virtual label decomposeSerial
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cellWeights,
List<label>& decomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cellWeights,
labelList& decomp
) const;
@ -139,7 +140,6 @@ public:
{
return true;
}
};

View File

@ -49,7 +49,7 @@ License
//);
//#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
@ -71,14 +71,14 @@ namespace Foam
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::label Foam::metisDecomp::decomposeSerial
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cWeights,
List<label>& decomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cWeights,
labelList& decomp
) const
{
// Method of decomposition

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
@ -75,16 +75,17 @@ class metisDecomp
:
public metisLikeDecomp
{
protected:
// Private Member Functions
// Protected Member Functions
//- Call Metis with options from dictionary.
//- Decompose non-parallel
virtual label decomposeSerial
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cellWeights,
List<label>& decomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cellWeights,
labelList& decomp
) const;
@ -95,7 +96,6 @@ class metisDecomp
void operator=(const metisDecomp&) = delete;
public:
//- Runtime type information
@ -125,7 +125,6 @@ public:
{
return true;
}
};

View File

@ -23,183 +23,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
From scotch forum:
By: Francois PELLEGRINI RE: Graph mapping 'strategy' string [ reply ]
2008-08-22 10:09 Strategy handling in Scotch is a bit tricky. In order
not to be confused, you must have a clear view of how they are built.
Here are some rules:
1- Strategies are made up of "methods" which are combined by means of
"operators".
2- A method is of the form "m{param=value,param=value,...}", where "m"
is a single character (this is your first error: "f" is a method name,
not a parameter name).
3- There exist different sort of strategies : bipartitioning strategies,
mapping strategies, ordering strategies, which cannot be mixed. For
instance, you cannot build a bipartitioning strategy and feed it to a
mapping method (this is your second error).
To use the "mapCompute" routine, you must create a mapping strategy, not
a bipartitioning one, and so use stratGraphMap() and not
stratGraphBipart(). Your mapping strategy should however be based on the
"recursive bipartitioning" method ("b"). For instance, a simple (and
hence not very efficient) mapping strategy can be :
"b{sep=f}"
which computes mappings with the recursive bipartitioning method "b",
this latter using the Fiduccia-Mattheyses method "f" to compute its
separators.
If you want an exact partition (see your previous post), try
"b{sep=fx}".
However, these strategies are not the most efficient, as they do not
make use of the multi-level framework.
To use the multi-level framework, try for instance:
"b{sep=m{vert=100,low=h,asc=f}x}"
The current default mapping strategy in Scotch can be seen by using the
"-vs" option of program dgpart. It is, to date:
r
{
sep=m
{
asc=b
{
width=3,
bnd=(d{pass=40,dif=1,rem=0,type=b}|)
q{strat=f{move=80,pass=-1,bal=0.01,type=b}}
x{sbbt=5,bal=0.05},
org=q{strat=f{move=80,pass=-1,bal=0.01,type=b}}
x{sbbt=5,bal=0.05}
},
low=q
{
strat=
(
m
{
asc=b
{
bnd=(d{pass=40,type=b}|)
f{move=80,pass=-1,bal=0.05,type=b},
org=f{move=80,pass=-1,bal=0.05,type=b},
width=3
},
low=h{pass=10}
f{move=80,pass=-1,bal=0.05,type=b},
vert=80,
rat=0.8
}
|m
{
asc=b
{
bnd=(d{pass=40,type=b}|)
f{move=80,pass=-1,bal=0.05,type=b},
org=f{move=80,pass=-1,bal=0.05,type=b},
width=3
},
low=h{pass=10}
f{move=80,pass=-1,bal=0.05,type=b},
vert=80,
rat=0.8
}
)
},
seq=q
{
strat=
(
m
{
asc=b
{
bnd=(d{pass=40,type=b}|)
f{move=80,pass=-1,bal=0.05,type=b},
org=f{move=80,pass=-1,bal=0.05,type=b},
width=3
},
low=h{pass=10}
f{move=80,pass=-1,bal=0.05,type=b},
vert=80,
rat=0.8
}
|m
{
asc=b
{
bnd=(d{pass=40,type=b}|)
f{move=80,pass=-1,bal=0.05,type=b},
org=f{move=80,pass=-1,bal=0.05,type=b},
width=3
},
low=h{pass=10}
f{move=80,pass=-1,bal=0.05,type=b},
vert=80,
rat=0.8
}
)
},
pass=5,
vert=10000,
rat=0.8
},
seq=r
{
job=t,
bal=0.05,
map=t,
poli=S,
sep=
(
m
{
asc=b
{
bnd=(d{pass=40,type=b}|)
f{move=80,pass=-1,bal=0.05,type=b},
org=f{move=80,pass=-1,bal=0.05,type=b},
width=3
},
low=h{pass=10}
f{move=80,pass=-1,bal=0.05,type=b},
vert=80,
rat=0.8
}
|m
{
asc=b
{
bnd=(d{pass=40,type=b}|)
f{move=80,pass=-1,bal=0.05,type=b},
org=f{move=80,pass=-1,bal=0.05,type=b},
width=3
},
low=h{pass=10}
f{move=80,pass=-1,bal=0.05,type=b},
vert=80,
rat=0.8
}
)
},
bal=0.05
}
Note: writeGraph=true : writes out .dgr files for debugging. Run with e.g.
mpirun -np 4 dgpart 2 'region0_%r.dgr'
- %r gets replaced by current processor rank
- decompose into 2 domains
\*---------------------------------------------------------------------------*/
#include "ptscotchDecomp.H"
@ -232,8 +55,7 @@ static_assert
"sizeof(Foam::label) == sizeof(SCOTCH_Num), check your scotch headers"
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
@ -268,7 +90,7 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str)
if (retVal)
{
FatalErrorInFunction
<< "Call to scotch routine " << str << " failed."
<< "Call to scotch routine " << str << " failed.\n"
<< exit(FatalError);
}
}
@ -277,10 +99,10 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str)
////- Does prevention of 0 cell domains and calls ptscotch.
//Foam::label Foam::ptscotchDecomp::decomposeZeroDomains
//(
// const labelUList& initadjncy,
// const labelUList& initxadj,
// const UList<scalar>& initcWeights,
// List<label>& finalDecomp
// const labelList& initadjncy,
// const labelList& initxadj,
// const List<scalar>& initcWeights,
// labelList& finalDecomp
//) const
//{
// globalIndex globalCells(initxadj.size()-1);
@ -465,10 +287,10 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str)
Foam::label Foam::ptscotchDecomp::decompose
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cWeights,
List<label>& finalDecomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cWeights,
labelList& finalDecomp
) const
{
List<label> dummyAdjncy;
@ -492,8 +314,8 @@ Foam::label Foam::ptscotchDecomp::decompose
const label adjncy[],
const label xadjSize,
const label xadj[],
const UList<scalar>& cWeights,
List<label>& finalDecomp
const List<scalar>& cWeights,
labelList& finalDecomp
) const
{
if (debug)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -89,10 +89,10 @@ class ptscotchDecomp
//- Decompose. Handles size 0 arrays
label decompose
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cWeights,
List<label>& finalDecomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cWeights,
labelList& finalDecomp
) const;
//- Low level decompose
@ -102,8 +102,8 @@ class ptscotchDecomp
const label adjncy[],
const label xadjSize,
const label xadj[],
const UList<scalar>& cWeights,
List<label>& finalDecomp
const List<scalar>& cWeights,
labelList& finalDecomp
) const;
@ -181,7 +181,6 @@ public:
const pointField& cc,
const scalarField& cWeights
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -23,104 +23,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
From scotch forum:
By: Francois PELLEGRINI RE: Graph mapping 'strategy' string [ reply ]
2008-08-22 10:09 Strategy handling in Scotch is a bit tricky. In order
not to be confused, you must have a clear view of how they are built.
Here are some rules:
1- Strategies are made up of "methods" which are combined by means of
"operators".
2- A method is of the form "m{param=value,param=value,...}", where "m"
is a single character (this is your first error: "f" is a method name,
not a parameter name).
3- There exist different sort of strategies : bipartitioning strategies,
mapping strategies, ordering strategies, which cannot be mixed. For
instance, you cannot build a bipartitioning strategy and feed it to a
mapping method (this is your second error).
To use the "mapCompute" routine, you must create a mapping strategy, not
a bipartitioning one, and so use stratGraphMap() and not
stratGraphBipart(). Your mapping strategy should however be based on the
"recursive bipartitioning" method ("b"). For instance, a simple (and
hence not very efficient) mapping strategy can be :
"b{sep=f}"
which computes mappings with the recursive bipartitioning method "b",
this latter using the Fiduccia-Mattheyses method "f" to compute its
separators.
If you want an exact partition (see your previous post), try
"b{sep=fx}".
However, these strategies are not the most efficient, as they do not
make use of the multi-level framework.
To use the multi-level framework, try for instance:
"b{sep=m{vert=100,low=h,asc=f}x}"
The current default mapping strategy in Scotch can be seen by using the
"-vs" option of program gmap. It is, to date:
m
{
asc=b
{
width=3,
bnd=d{pass=40, dif=1, rem=0}
f{move=80, pass=-1, bal=0.01},
org=f{move=80,pass=-1,bal=0.01}
},
low=r
{
job=t,
bal=0.01,
map=t,
poli=S,
sep=
(
m
{
asc=b
{
bnd=f{move=120, pass=-1, bal=0.01, type=b},
org=f{move=120,pass=-1,bal=0.01,type=b},
width=3
},
low=h{pass=10}
f{move=120,pass=-1,bal=0.01,type=b},
vert=120,
rat=0.8
}
|m
{
asc=b
{
bnd=f{move=120,pass=-1,bal=0.01,type=b},
org=f{move=120,pass=-1,bal=0.01,type=b},
width=3
},
low=h{pass=10}
f{move=120,pass=-1,bal=0.01,type=b},
vert=120,
rat=0.8
}
)
},
vert=10000,
rat=0.8,
type=0
}
Note: instead of gmap run gpart \<nProcs\> -vs \<grfFile\>
where \<grfFile\> can be obtained by running with 'writeGraph=true'
\*---------------------------------------------------------------------------*/
#include "scotchDecomp.H"
@ -152,7 +54,7 @@ static_assert
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
@ -173,6 +75,7 @@ namespace Foam
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::scotchDecomp::graphPath(const polyMesh& mesh) const
@ -186,18 +89,20 @@ void Foam::scotchDecomp::check(const int retVal, const char* str)
if (retVal)
{
FatalErrorInFunction
<< "Call to scotch routine " << str << " failed."
<< "Call to scotch routine " << str << " failed.\n"
<< exit(FatalError);
}
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::label Foam::scotchDecomp::decomposeSerial
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cWeights,
List<label>& decomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cWeights,
labelList& decomp
) const
{
// Dump graph
@ -205,7 +110,7 @@ Foam::label Foam::scotchDecomp::decomposeSerial
{
OFstream str(graphPath_);
Info<< "Dumping Scotch graph file to " << str.name() << endl
Info<< "Dumping Scotch graph file to " << str.name() << nl
<< "Use this in combination with gpart." << endl;
const label version = 0;
@ -215,6 +120,7 @@ Foam::label Foam::scotchDecomp::decomposeSerial
// Numbering starts from 0
const label baseval = 0;
// Has weights?
const label hasEdgeWeights = 0;
const label hasVertexWeights = 0;
@ -263,7 +169,7 @@ Foam::label Foam::scotchDecomp::decomposeSerial
// Graph
// ~~~~~
List<label> velotab;
labelList velotab;
// Check for externally provided cellweights and if so initialise weights
// Note: min, not gMin since routine runs on master only.
@ -340,7 +246,7 @@ Foam::label Foam::scotchDecomp::decomposeSerial
SCOTCH_Arch archdat;
check(SCOTCH_archInit(&archdat), "SCOTCH_archInit");
List<label> processorWeights;
labelList processorWeights;
if
(
coeffsDict_.readIfPresent("processorWeights", processorWeights)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -231,7 +231,7 @@ class scotchDecomp
:
public metisLikeDecomp
{
// Private data
// Private Data
//- Output path and name for optional grf file.
mutable fileName graphPath_;
@ -245,13 +245,18 @@ class scotchDecomp
//- Check and print error message
static void check(const int, const char*);
protected:
// Protected Member Functions
//- Decompose non-parallel
virtual label decomposeSerial
(
const labelUList& adjncy,
const labelUList& xadj,
const UList<scalar>& cWeights,
List<label>& decomp
const labelList& adjncy,
const labelList& xadj,
const List<scalar>& cWeights,
labelList& decomp
) const;