Skip to content

Commit

Permalink
MueLu: Phase 2a - optionally match ML
Browse files Browse the repository at this point in the history
  • Loading branch information
cgcgcg committed Dec 14, 2021
1 parent bb335fa commit 08034ae
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions packages/muelu/doc/UsersGuide/masterList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,10 @@
</parameter>

<parameter>
<name>aggregation: phase2a include root</name>
<name>aggregation: match ML phase2a</name>
<type>bool</type>
<default>true</default>
<description>Whether the root node should be included in the aggregates formed in phase 2a.</description>
<default>false</default>
<description>Match ML's phase 2a. In particular, setting this to true will include the root node into the tentative aggregates in phase 2a.</description>
<visible>false</visible>
<comment-ML>parameter not existing in ML</comment-ML>
</parameter>
Expand Down
2 changes: 1 addition & 1 deletion packages/muelu/doc/UsersGuide/paramlist_hidden.tex
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@

\cbb{aggregation: enable phase 3}{bool}{true}{Turn on/off phase 3 of aggregation}

\cbb{aggregation: phase2a include root}{bool}{true}{Whether the root node should be included in the aggregates formed in phase 2a.}
\cbb{aggregation: match ML phase2a}{bool}{false}{Match ML's phase 2a. In particular, setting this to true will include the root node into the tentative aggregates in phase 2a.}

\cbb{aggregation: phase2a agg factor}{double}{0.5}{Agg factor for Phase 2a sizes}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace MueLu {
SET_VALID_ENTRY("aggregation: preserve Dirichlet points");
SET_VALID_ENTRY("aggregation: allow user-specified singletons");
SET_VALID_ENTRY("aggregation: error on nodes with no on-rank neighbors");
SET_VALID_ENTRY("aggregation: phase2a include root");
SET_VALID_ENTRY("aggregation: match ML phase2a");
SET_VALID_ENTRY("aggregation: phase2a agg factor");
SET_VALID_ENTRY("aggregation: phase3 avoid singletons");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace MueLu {

int minNodesPerAggregate = params.get<int>("aggregation: min agg size");
int maxNodesPerAggregate = params.get<int>("aggregation: max agg size");
bool includeRootInAgg = params.get<bool>("aggregation: phase2a include root");
bool matchMLbehavior = params.get<bool>("aggregation: match ML phase2a");

const LO numRows = graph.GetNodeNumVertices();
const int myRank = graph.GetComm()->getRank();
Expand All @@ -94,7 +94,7 @@ namespace MueLu {

LO numNeighbors = 0;
aggSize = 0;
if (includeRootInAgg) {
if (matchMLbehavior) {
aggList[aggSize++] = rootCandidate;
numNeighbors++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace MueLu {
{
const int minNodesPerAggregate = params.get<int>("aggregation: min agg size");
const int maxNodesPerAggregate = params.get<int>("aggregation: max agg size");
bool includeRootInAgg = params.get<bool>("aggregation: phase2a include root");
bool matchMLbehavior = params.get<bool>("aggregation: match ML phase2a");

const LO numRows = graph.GetNodeNumVertices();
const int myRank = graph.GetComm()->getRank();
Expand Down Expand Up @@ -129,17 +129,18 @@ namespace MueLu {
if(aggStat(rootCandidate) == READY &&
colors(rootCandidate) == color) {

LO aggSize;
if (includeRootInAgg)
aggSize = 1;
else
aggSize = 0;
LO numNeighbors = 0;
LO aggSize = 0;
if (matchMLbehavior) {
aggSize += 1;
numNeighbors +=1;
}

auto neighbors = graph.getNeighborVertices(rootCandidate);

// Loop over neighbors to count how many nodes could join
// the new aggregate
LO numNeighbors = 0;

for(int j = 0; j < neighbors.length; ++j) {
LO neigh = neighbors(j);
if(neigh != rootCandidate) {
Expand All @@ -155,16 +156,15 @@ namespace MueLu {
// If a sufficient number of nodes can join the new aggregate
// then we actually create the aggregate.
if(aggSize > minNodesPerAggregate &&
((includeRootInAgg && aggSize-1 > factor*numNeighbors) ||
(!includeRootInAgg && aggSize > factor*numNeighbors))) {
(aggSize > factor*numNeighbors)) {

// aggregates.SetIsRoot(rootCandidate);
LO aggIndex = Kokkos::
atomic_fetch_add(&numLocalAggregates(), 1);

LO numAggregated = 0;

if (includeRootInAgg) {
if (matchMLbehavior) {
// Add the root.
aggStat(rootCandidate) = AGGREGATED;
vertex2AggId(rootCandidate, 0) = aggIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace MueLu {
SET_VALID_ENTRY("aggregation: enable phase 2a");
SET_VALID_ENTRY("aggregation: enable phase 2b");
SET_VALID_ENTRY("aggregation: enable phase 3");
SET_VALID_ENTRY("aggregation: phase2a include root");
SET_VALID_ENTRY("aggregation: match ML phase2a");
SET_VALID_ENTRY("aggregation: phase2a agg factor");
SET_VALID_ENTRY("aggregation: preserve Dirichlet points");
SET_VALID_ENTRY("aggregation: allow user-specified singletons");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace MueLu {
SET_VALID_ENTRY("aggregation: enable phase 2a");
SET_VALID_ENTRY("aggregation: enable phase 2b");
SET_VALID_ENTRY("aggregation: enable phase 3");
SET_VALID_ENTRY("aggregation: phase2a include root");
SET_VALID_ENTRY("aggregation: match ML phase2a");
SET_VALID_ENTRY("aggregation: phase3 avoid singletons");
SET_VALID_ENTRY("aggregation: error on nodes with no on-rank neighbors");
SET_VALID_ENTRY("aggregation: preserve Dirichlet points");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ namespace MueLu {
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: enable phase 2a", bool, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: enable phase 2b", bool, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: enable phase 3", bool, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: phase2a include root", bool, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: match ML phase2a", bool, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: phase2a agg factor", double, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: preserve Dirichlet points", bool, aggParams);
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: error on nodes with no on-rank neighbors", bool, aggParams);
Expand Down
4 changes: 2 additions & 2 deletions packages/muelu/src/MueCentral/MueLu_MasterList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ namespace MueLu {
"<Parameter name=\"aggregation: enable phase 2a\" type=\"bool\" value=\"true\"/>"
"<Parameter name=\"aggregation: enable phase 2b\" type=\"bool\" value=\"true\"/>"
"<Parameter name=\"aggregation: enable phase 3\" type=\"bool\" value=\"true\"/>"
"<Parameter name=\"aggregation: phase2a include root\" type=\"bool\" value=\"true\"/>"
"<Parameter name=\"aggregation: match ML phase2a\" type=\"bool\" value=\"false\"/>"
"<Parameter name=\"aggregation: phase2a agg factor\" type=\"double\" value=\"0.5\"/>"
"<Parameter name=\"aggregation: error on nodes with no on-rank neighbors\" type=\"bool\" value=\"false\"/>"
"<Parameter name=\"aggregation: phase3 avoid singletons\" type=\"bool\" value=\"false\"/>"
Expand Down Expand Up @@ -677,7 +677,7 @@ namespace MueLu {

("aggregation: enable phase 3","aggregation: enable phase 3")

("aggregation: phase2a include root","aggregation: phase2a include root")
("aggregation: match ML phase2a","aggregation: match ML phase2a")

("aggregation: phase2a agg factor","aggregation: phase2a agg factor")

Expand Down
2 changes: 1 addition & 1 deletion packages/muelu/test/unit_tests/Aggregates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class AggregateGenerator {
aggFact->SetParameter("aggregation: enable phase 2b", Teuchos::ParameterEntry(true));
aggFact->SetParameter("aggregation: enable phase 3", Teuchos::ParameterEntry(true));

aggFact->SetParameter("aggregation: phase2a include root", Teuchos::ParameterEntry(true));
aggFact->SetParameter("aggregation: match ML phase2a", Teuchos::ParameterEntry(true));

// Hybrid
level.Set("aggregationRegionType", regionType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ namespace MueLuTests {
params.set<int> ("aggregation: max agg size", 3);
params.set<bool>("aggregation: deterministic", false);

params.set<bool>("aggregation: phase2a include root", true);
params.set<bool>("aggregation: match ML phase2a", true);
params.set<bool>("aggregation: error on nodes with no on-rank neighbors", false);
params.set<bool>("aggregation: phase3 avoid singletons", false);

Expand Down

0 comments on commit 08034ae

Please sign in to comment.