Commit 8c27cc2d authored by Kenneth Leiter's avatar Kenneth Leiter
Browse files

ENH: Add ability to repartition partitioned meshes from command line.

Just input file into partitioner with new number of processes. The file
is unpartitioned in memory and repartitioned.
parent ae42e9d5
...@@ -766,7 +766,7 @@ namespace { ...@@ -766,7 +766,7 @@ namespace {
{ {
std::cerr << "usage: " << programName << " " std::cerr << "usage: " << programName << " "
<< "[-s metis_scheme] [-u]" << "[-s metis_scheme] [-r] [-u]"
<< "<input file> <number of partitions> [output file]" << "<input file> <number of partitions> [output file]"
<< std::endl; << std::endl;
std::cerr << "\t-s metis_scheme: 1 - Dual Graph" << std::endl; std::cerr << "\t-s metis_scheme: 1 - Dual Graph" << std::endl;
...@@ -796,7 +796,7 @@ namespace { ...@@ -796,7 +796,7 @@ namespace {
int c; int c;
bool errorFlag = false; bool errorFlag = false;
while( (c=getopt(ac, av, "s:u")) != -1 ) while( (c=getopt(ac, av, "s:ur")) != -1 )
switch(c){ switch(c){
case 's': { case 's': {
...@@ -931,7 +931,8 @@ int main(int argc, char* argv[]) ...@@ -931,7 +931,8 @@ int main(int argc, char* argv[])
} }
} }
else { else {
if(domain->getNumberUnstructuredGrids() <= 0) { if(domain->getNumberUnstructuredGrids() == 0 &&
domain->getNumberGridCollections() == 0) {
std::cout << "No grids to partition" << std::endl; std::cout << "No grids to partition" << std::endl;
return 1; return 1;
} }
...@@ -946,19 +947,24 @@ int main(int argc, char* argv[]) ...@@ -946,19 +947,24 @@ int main(int argc, char* argv[])
shared_ptr<XdmfPartitioner> partitioner = XdmfPartitioner::New(); shared_ptr<XdmfPartitioner> partitioner = XdmfPartitioner::New();
shared_ptr<XdmfGrid> toWrite;
if(unpartition) { if(unpartition) {
shared_ptr<XdmfUnstructuredGrid> toWrite = shared_ptr<XdmfUnstructuredGrid> toWrite =
partitioner->unpartition(domain->getGridCollection(0)); partitioner->unpartition(domain->getGridCollection(0));
newDomain->insert(toWrite); newDomain->insert(toWrite);
} }
else { else {
shared_ptr<XdmfUnstructuredGrid> gridToPartition;
if(domain->getNumberUnstructuredGrids() == 0) {
gridToPartition = partitioner->unpartition(domain->getGridCollection(0));
}
else {
gridToPartition = domain->getUnstructuredGrid(0);
}
shared_ptr<XdmfGridCollection> toWrite = shared_ptr<XdmfGridCollection> toWrite =
partitioner->partition(domain->getUnstructuredGrid(0), partitioner->partition(gridToPartition,
numPartitions, numPartitions,
metisScheme, metisScheme,
heavyDataWriter); heavyDataWriter);
newDomain->insert(toWrite); newDomain->insert(toWrite);
} }
......
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