Commit 66434cfd authored by Thomas Witkowski's avatar Thomas Witkowski

Small feature updates.

parent d850f7ad
......@@ -16,7 +16,7 @@
namespace AMDiS {
void CheckerPartitioner::createInitialPartitioning()
bool CheckerPartitioner::createInitialPartitioning()
{
FUNCNAME("CheckerPartitioner::createInitialPartitioning()");
......@@ -127,6 +127,8 @@ namespace AMDiS {
elInfo = stack.traverseNext(elInfo);
}
return true;
}
}
......@@ -62,7 +62,7 @@ namespace AMDiS {
~CheckerPartitioner() {}
void createInitialPartitioning();
bool createInitialPartitioning();
/// \ref MeshPartitioner::partition
bool partition(map<int, double> &elemWeights, PartitionMode mode = INITIAL)
......
......@@ -357,14 +357,12 @@ namespace AMDiS {
createMacroElementInfo();
// create an initial partitioning of the mesh
partitioner->createInitialPartitioning();
bool useInitialPartitioning = partitioner->createInitialPartitioning();
// set the element weights, which are 1 at the very first begin
setInitialElementWeights();
string filename = "";
Parameters::get("parallel->partitioner->read meta arh", filename);
if (filename == "" || ArhReader::readMetaData(filename) != mpiSize) {
if (!useInitialPartitioning) {
// and now partition the mesh
bool partitioningSucceed = partitioner->partition(elemWeights, INITIAL);
TEST_EXIT(partitioningSucceed)("Initial partitioning does not work!\n");
......
......@@ -18,7 +18,7 @@
namespace AMDiS {
void MeshPartitioner::createInitialPartitioning()
bool MeshPartitioner::createInitialPartitioning()
{
FUNCNAME("MeshPartitioner::createInitialPartitioning()");
......@@ -26,7 +26,7 @@ namespace AMDiS {
int mpiSize = mpiComm->Get_size();
int nLeaves = mesh->getNumberOfLeaves();
int elPerRank = nLeaves / mpiSize;
bool useInitialPartitioning = false;
// === Check for reading ARH meta file to create initial partitioning. ===
......@@ -35,14 +35,23 @@ namespace AMDiS {
string partitioningFile = "";
Parameters::get("parallel->initial partitioning file", partitioningFile);
if (partitioningFile != "") {
if (partitioningFile != "") {
MSG("Read initial partitioning file: %s\n", partitioningFile.c_str());
ifstream file;
file.open(partitioningFile.c_str());
TEST_EXIT(file.is_open())("Should not happen!\n");
int nElements = 0;
file >> nElements;
for (int i = 0; i < nElements; i++)
file >> mapElInRank[i];
for (int i = 0; i < nElements; i++) {
int rank = -1;
file >> rank;
mapElInRank[i] = rank;
}
file.close();
useInitialPartitioning = true;
} else {
string arhMetaFile = "";
Parameters::get("parallel->partitioner->read meta arh", arhMetaFile);
......@@ -51,6 +60,8 @@ namespace AMDiS {
int nProc = ArhReader::readMetaData(arhMetaFile, mapElInRank, arhElCodeSize);
if (nProc != mpiSize)
partitioningArhBased = false;
else
useInitialPartitioning = true;
}
}
......@@ -157,6 +168,8 @@ namespace AMDiS {
}
}
}
return useInitialPartitioning;
}
......
......@@ -62,10 +62,16 @@ namespace AMDiS {
virtual ~MeshPartitioner() {}
/// Creates an initial paritioning of the AMDiS mesh. This partitioning
/// can be arbitrary, the only requirement is that each macro element
/// must be uniquely assign to a rank.
virtual void createInitialPartitioning();
/** \brief
* Creates an initial paritioning of the AMDiS mesh. This partitioning
* can be arbitrary, the only requirement is that each macro element
* must be uniquely assign to a rank.
*
* \return If the function returns true, the initial partitioning should
* be used for the very first computations. This can be e.g. due
* to the usage of an initial partitioning file.
*/
virtual bool createInitialPartitioning();
/** \brief
* Function the takes a weighted set of macro elements and returns a
......
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