Skip to content

Commit

Permalink
Merge pull request #13558 from bangerth/cleanup-partition
Browse files Browse the repository at this point in the history
Minor cleanups.
  • Loading branch information
marcfehling committed Mar 22, 2022
2 parents ca0ff3d + 68a587c commit 9922030
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions source/lac/sparsity_tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,23 @@ namespace SparsityTools
AssertThrow(false, ExcMETISNotInstalled());
#else

// generate the data structures for
// METIS. Note that this is particularly
// simple, since METIS wants exactly our
// compressed row storage format. we only
// have to set up a few auxiliary arrays
idx_t n = static_cast<signed int>(sparsity_pattern.n_rows()),
ncon = 1, // number of balancing constraints (should be >0)
nparts =
static_cast<int>(n_partitions), // number of subdomains to create
dummy; // the numbers of edges cut by the
// resulting partition
// Generate the data structures for METIS. Note that this is particularly
// simple, since METIS wants exactly our compressed row storage format.
// We only have to set up a few auxiliary arrays and convert from our
// unsigned cell weights to signed ones.
idx_t n = static_cast<signed int>(sparsity_pattern.n_rows());

idx_t ncon = 1; // number of balancing constraints (should be >0)

// We can not partition n items into more than n parts. METIS will
// generate non-sensical output (everything is owned by a single process)
// and complain with a message (but won't return an error code!):
// ***Cannot bisect a graph with 0 vertices!
// ***You are trying to partition a graph into too many parts!
nparts = std::min(n, nparts);
idx_t nparts =
std::min(n,
static_cast<idx_t>(
n_partitions)); // number of subdomains to create

// use default options for METIS
idx_t options[METIS_NOPTIONS];
Expand All @@ -110,7 +109,7 @@ namespace SparsityTools

std::vector<idx_t> int_partition_indices(sparsity_pattern.n_rows());

// Setup cell weighting option
// Set up cell weighting option
std::vector<idx_t> int_cell_weights;
if (cell_weights.size() > 0)
{
Expand All @@ -134,6 +133,7 @@ namespace SparsityTools
// Select which type of partitioning to create

// Use recursive if the number of partitions is less than or equal to 8
idx_t dummy; // output: # of edges cut by the resulting partition
if (nparts <= 8)
ierr = METIS_PartGraphRecursive(&n,
&ncon,
Expand Down

0 comments on commit 9922030

Please sign in to comment.