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

View File

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

View File

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

View File

@ -1,12 +1,13 @@
#ifndef KAHIP_H #ifndef KAHIP_H
#define KAHIP_H #define KAHIP_H
/* *** DUMMY VERSION of kaHIP_interface.h - this file should not be included if you have KaHIP /* *** DUMMY VERSION of kaHIP_interface.h
* installed in the correct position in $WM_THIRD_PARTY_DIR - see * This file should not be included if you have kahip correctly installed
* decompositionMethods/kahipDecomp/Make/options * 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 #ifdef __cplusplus
extern "C" { extern "C" {

View File

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

View File

@ -1,12 +1,13 @@
#ifndef METIS_H #ifndef METIS_H
#define METIS_H #define METIS_H
/* *** DUMMY VERSION of metis.h - this file should not be included if you have metis /* *** DUMMY VERSION of metis.h
* installed in the correct position in $WM_THIRD_PARTY_DIR - see * This file should not be included if you have metis correctly installed.
* decompositionMethods/metisDecomp/Make/options * 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 // Integer type: OpenFOAM uses WM_LABEL_SIZE, metis.h uses IDXTYPEWIDTH
#if WM_LABEL_SIZE == 32 #if WM_LABEL_SIZE == 32

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,183 +23,6 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 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" #include "ptscotchDecomp.H"
@ -232,8 +55,7 @@ static_assert
"sizeof(Foam::label) == sizeof(SCOTCH_Num), check your scotch headers" "sizeof(Foam::label) == sizeof(SCOTCH_Num), check your scotch headers"
); );
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
@ -268,7 +90,7 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str)
if (retVal) if (retVal)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Call to scotch routine " << str << " failed." << "Call to scotch routine " << str << " failed.\n"
<< exit(FatalError); << 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. ////- Does prevention of 0 cell domains and calls ptscotch.
//Foam::label Foam::ptscotchDecomp::decomposeZeroDomains //Foam::label Foam::ptscotchDecomp::decomposeZeroDomains
//( //(
// const labelUList& initadjncy, // const labelList& initadjncy,
// const labelUList& initxadj, // const labelList& initxadj,
// const UList<scalar>& initcWeights, // const List<scalar>& initcWeights,
// List<label>& finalDecomp // labelList& finalDecomp
//) const //) const
//{ //{
// globalIndex globalCells(initxadj.size()-1); // globalIndex globalCells(initxadj.size()-1);
@ -465,10 +287,10 @@ void Foam::ptscotchDecomp::check(const int retVal, const char* str)
Foam::label Foam::ptscotchDecomp::decompose Foam::label Foam::ptscotchDecomp::decompose
( (
const labelUList& adjncy, const labelList& adjncy,
const labelUList& xadj, const labelList& xadj,
const UList<scalar>& cWeights, const List<scalar>& cWeights,
List<label>& finalDecomp labelList& finalDecomp
) const ) const
{ {
List<label> dummyAdjncy; List<label> dummyAdjncy;
@ -492,8 +314,8 @@ Foam::label Foam::ptscotchDecomp::decompose
const label adjncy[], const label adjncy[],
const label xadjSize, const label xadjSize,
const label xadj[], const label xadj[],
const UList<scalar>& cWeights, const List<scalar>& cWeights,
List<label>& finalDecomp labelList& finalDecomp
) const ) const
{ {
if (debug) if (debug)

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -23,104 +23,6 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 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" #include "scotchDecomp.H"
@ -152,7 +54,7 @@ static_assert
); );
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
@ -173,6 +75,7 @@ namespace Foam
); );
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::scotchDecomp::graphPath(const polyMesh& mesh) const void Foam::scotchDecomp::graphPath(const polyMesh& mesh) const
@ -186,18 +89,20 @@ void Foam::scotchDecomp::check(const int retVal, const char* str)
if (retVal) if (retVal)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Call to scotch routine " << str << " failed." << "Call to scotch routine " << str << " failed.\n"
<< exit(FatalError); << exit(FatalError);
} }
} }
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::label Foam::scotchDecomp::decomposeSerial Foam::label Foam::scotchDecomp::decomposeSerial
( (
const labelUList& adjncy, const labelList& adjncy,
const labelUList& xadj, const labelList& xadj,
const UList<scalar>& cWeights, const List<scalar>& cWeights,
List<label>& decomp labelList& decomp
) const ) const
{ {
// Dump graph // Dump graph
@ -205,7 +110,7 @@ Foam::label Foam::scotchDecomp::decomposeSerial
{ {
OFstream str(graphPath_); 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; << "Use this in combination with gpart." << endl;
const label version = 0; const label version = 0;
@ -215,6 +120,7 @@ Foam::label Foam::scotchDecomp::decomposeSerial
// Numbering starts from 0 // Numbering starts from 0
const label baseval = 0; const label baseval = 0;
// Has weights? // Has weights?
const label hasEdgeWeights = 0; const label hasEdgeWeights = 0;
const label hasVertexWeights = 0; const label hasVertexWeights = 0;
@ -263,7 +169,7 @@ Foam::label Foam::scotchDecomp::decomposeSerial
// Graph // Graph
// ~~~~~ // ~~~~~
List<label> velotab; labelList velotab;
// Check for externally provided cellweights and if so initialise weights // Check for externally provided cellweights and if so initialise weights
// Note: min, not gMin since routine runs on master only. // Note: min, not gMin since routine runs on master only.
@ -340,7 +246,7 @@ Foam::label Foam::scotchDecomp::decomposeSerial
SCOTCH_Arch archdat; SCOTCH_Arch archdat;
check(SCOTCH_archInit(&archdat), "SCOTCH_archInit"); check(SCOTCH_archInit(&archdat), "SCOTCH_archInit");
List<label> processorWeights; labelList processorWeights;
if if
( (
coeffsDict_.readIfPresent("processorWeights", processorWeights) coeffsDict_.readIfPresent("processorWeights", processorWeights)

View File

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