Commit 9a33e067 authored by Spencer Sherwin's avatar Spencer Sherwin

Added an option for --part-only-overlapping which produces an overlapping...

Added an option for --part-only-overlapping which produces an overlapping series of patches for post-processing purposes
parent 018ff02d
......@@ -92,7 +92,8 @@ namespace Nektar
}
void MeshPartition::PartitionMesh(int nParts, bool shared)
void MeshPartition::PartitionMesh(int nParts, bool shared,
bool overlapping)
{
ASSERTL0(m_meshElements.size() >= nParts,
"Too few elements for this many processes.");
......@@ -103,7 +104,7 @@ namespace Nektar
WeightElements();
}
CreateGraph(m_mesh);
PartitionGraph(m_mesh, nParts, m_localPartition);
PartitionGraph(m_mesh, nParts, m_localPartition, overlapping);
}
void MeshPartition::WriteLocalPartition(LibUtilities::SessionReaderSharedPtr& pSession)
......@@ -1067,7 +1068,8 @@ namespace Nektar
void MeshPartition::PartitionGraph(BoostSubGraph& pGraph,
int nParts,
std::vector<BoostSubGraph>& pLocalPartition)
std::vector<BoostSubGraph>& pLocalPartition,
bool overlapping)
{
int i;
int nGraphVerts = boost::num_vertices(pGraph);
......@@ -1075,6 +1077,7 @@ namespace Nektar
// Convert boost graph into CSR format
BoostVertexIterator vertit, vertit_end;
BoostAdjacencyIterator adjvertit, adjvertit_end;
Array<OneD, int> part(nGraphVerts,0);
if (m_comm->GetRowComm()->TreatAsRankZero())
......@@ -1082,7 +1085,6 @@ namespace Nektar
int acnt = 0;
int vcnt = 0;
int nWeight = nGraphVerts;
BoostAdjacencyIterator adjvertit, adjvertit_end;
Array<OneD, int> xadj(nGraphVerts+1,0);
Array<OneD, int> adjncy(2*nGraphEdges);
Array<OneD, int> vwgt(nWeight, 1);
......@@ -1180,8 +1182,27 @@ namespace Nektar
pGraph[*vertit].partition = part[i];
boost::add_vertex(i, pLocalPartition[part[i]]);
}
}
if(overlapping)
{
//
for ( boost::tie(vertit, vertit_end) = boost::vertices(pGraph);
vertit != vertit_end;
++vertit)
{
for (boost::tie(adjvertit, adjvertit_end) = boost::adjacent_vertices(*vertit,pGraph);
adjvertit != adjvertit_end; ++adjvertit)
{
if(part[*adjvertit] != part[*vertit])
{
boost::add_vertex(*adjvertit, pLocalPartition[part[*vertit]]);
}
}
}
}
}
void MeshPartition::CheckPartitions(int nParts, Array<OneD, int> &pPart)
{
......
......@@ -66,7 +66,7 @@ namespace Nektar
LIB_UTILITIES_EXPORT MeshPartition(const SessionReaderSharedPtr& pSession);
LIB_UTILITIES_EXPORT virtual ~MeshPartition();
LIB_UTILITIES_EXPORT void PartitionMesh(int nParts, bool shared = false);
LIB_UTILITIES_EXPORT void PartitionMesh(int nParts, bool shared = false, bool overlapping = false);
LIB_UTILITIES_EXPORT void WriteLocalPartition(
SessionReaderSharedPtr& pSession);
LIB_UTILITIES_EXPORT void WriteAllPartitions(
......@@ -213,7 +213,8 @@ namespace Nektar
void CreateGraph(BoostSubGraph& pGraph);
void PartitionGraph(BoostSubGraph& pGraph,
int nParts,
std::vector<BoostSubGraph>& pLocalPartition);
std::vector<BoostSubGraph>& pLocalPartition,
bool overlapping = false);
virtual void PartitionGraphImpl(
int& nVerts,
......
......@@ -338,6 +338,8 @@ namespace Nektar
"number of slices in Z-dir")
("part-only", po::value<int>(),
"only partition mesh into N partitions.")
("part-only-overlapping", po::value<int>(),
"only partition mesh into N overlapping partitions.")
("part-info", "Output partition information")
;
......@@ -1600,7 +1602,8 @@ namespace Nektar
// Mesh has not been partitioned so do partitioning if required.
// Note in the serial case nothing is done as we have already loaded
// the mesh.
if (DefinesCmdLineArgument("part-only"))
if (DefinesCmdLineArgument("part-only")||
DefinesCmdLineArgument("part-only-overlapping"))
{
// Perform partitioning of the mesh only. For this we insist
// the code is run in serial (parallel execution is pointless).
......@@ -1608,12 +1611,21 @@ namespace Nektar
"The 'part-only' option should be used in serial.");
// Number of partitions is specified by the parameter.
int nParts = GetCmdLineArgument<int>("part-only");
int nParts;
SessionReaderSharedPtr vSession = GetSharedThisPtr();
MeshPartitionSharedPtr vPartitioner =
GetMeshPartitionFactory().CreateInstance(
vPartitionerName, vSession);
vPartitioner->PartitionMesh(nParts, true);
if(DefinesCmdLineArgument("part-only"))
{
nParts = GetCmdLineArgument<int>("part-only");
vPartitioner->PartitionMesh(nParts, true);
}
else
{
nParts = GetCmdLineArgument<int>("part-only-overlapping");
vPartitioner->PartitionMesh(nParts, true, true);
}
vPartitioner->WriteAllPartitions(vSession);
vPartitioner->GetCompositeOrdering(m_compOrder);
vPartitioner->GetBndRegionOrdering(m_bndRegOrder);
......
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