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

ENH: use List instead of UList for internal decomposition implementation

- enables future use of precision adaptors
parent 4e706c26
......@@ -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"
......
......@@ -47,10 +47,6 @@ SourceFiles
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
/*---------------------------------------------------------------------------*\
Class metis Declaration
\*---------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
#endif
......
......@@ -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
......
#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" {
......
......@@ -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
......
#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
......
......@@ -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
{}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
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();
}
......
......@@ -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();
}
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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);
......
......@@ -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;
}
};
......
......@@ -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
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |