Skip to content

Commit

Permalink
Merge pull request #13577 from maxfirmbach/Set-factory-more-specifica…
Browse files Browse the repository at this point in the history
…lly-for-aggregate-export

MueLu: Tell aggregate export about Graph and Aggregates
  • Loading branch information
cgcgcg authored Nov 11, 2024
2 parents 813f04e + a319a19 commit 67c25f4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,8 @@ void ParameterListInterpreter<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
MUELU_TEST_AND_SET_PARAM_2LIST(paramList, defaultList, "aggregation: output file: build colormap", bool, aggExportParams);
aggExport->SetParameterList(aggExportParams);
aggExport->SetFactory("DofsPerNode", manager.GetFactory("DofsPerNode"));
aggExport->SetFactory("Aggregates", manager.GetFactory("Aggregates"));
aggExport->SetFactory("Graph", manager.GetFactory("Graph"));

if (!RAP.is_null())
RAP->AddTransferFactory(aggExport);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class AggregationExportFactory : public TwoLevelFactoryBase, public Visualizatio
// Data that the different styles need to have available when building geometry
mutable Teuchos::RCP<CoordinateMultiVector> coords_; // fine local coordinates
mutable Teuchos::RCP<CoordinateMultiVector> coordsCoarse_; // coarse local coordinates
mutable Teuchos::ArrayRCP<LocalOrdinal> vertex2AggId_;
mutable Teuchos::RCP<LocalOrdinalMultiVector> vertex2AggId_;
mutable Teuchos::ArrayRCP<LocalOrdinal> aggSizes_;
mutable std::vector<bool> isRoot_;
mutable bool doFineGraphEdges_;
Expand Down
28 changes: 15 additions & 13 deletions packages/muelu/src/Utils/MueLu_AggregationExportFactory_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,9 @@ void AggregationExportFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build(
}
}
GetOStream(Runtime0) << "AggregationExportFactory: DofsPerNode: " << DofsPerNode << std::endl;
Teuchos::RCP<LocalOrdinalMultiVector> vertex2AggId_vector = aggregates->GetVertex2AggId();
Teuchos::RCP<LocalOrdinalVector> procWinner_vector = aggregates->GetProcWinner();
Teuchos::ArrayRCP<LocalOrdinal> vertex2AggId = aggregates->GetVertex2AggId()->getDataNonConst(0);
Teuchos::ArrayRCP<LocalOrdinal> procWinner = aggregates->GetProcWinner()->getDataNonConst(0);

vertex2AggId_ = vertex2AggId;
Teuchos::RCP<LocalOrdinalMultiVector> vertex2AggId = aggregates->GetVertex2AggId();
vertex2AggId_ = vertex2AggId;

// prepare for calculating global aggregate ids
std::vector<GlobalOrdinal> numAggsGlobal(numProcs, 0);
Expand Down Expand Up @@ -263,9 +260,10 @@ void AggregationExportFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build(
}
if (aggStyle == "Point Cloud")
this->doPointCloud(vertices, geomSizes, numAggs_, numNodes_);
else if (aggStyle == "Jacks")
this->doJacks(vertices, geomSizes, numAggs_, numNodes_, isRoot_, vertex2AggId_);
else if (aggStyle == "Jacks++") // Not actually implemented
else if (aggStyle == "Jacks") {
auto vertex2AggIds = vertex2AggId_->getDataNonConst(0);
this->doJacks(vertices, geomSizes, numAggs_, numNodes_, isRoot_, vertex2AggIds);
} else if (aggStyle == "Jacks++") // Not actually implemented
doJacksPlus_(vertices, geomSizes);
else if (aggStyle == "Convex Hulls")
doConvexHulls(vertices, geomSizes);
Expand Down Expand Up @@ -305,11 +303,13 @@ void AggregationExportFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::doConv
Teuchos::ArrayRCP<const typename Teuchos::ScalarTraits<Scalar>::coordinateType> yCoords = coords_->getData(1);
Teuchos::ArrayRCP<const typename Teuchos::ScalarTraits<Scalar>::coordinateType> zCoords = Teuchos::null;

auto vertex2AggIds = vertex2AggId_->getDataNonConst(0);

if (dims_ == 2) {
this->doConvexHulls2D(vertices, geomSizes, numAggs_, numNodes_, isRoot_, vertex2AggId_, xCoords, yCoords);
this->doConvexHulls2D(vertices, geomSizes, numAggs_, numNodes_, isRoot_, vertex2AggIds, xCoords, yCoords);
} else {
zCoords = coords_->getData(2);
this->doConvexHulls3D(vertices, geomSizes, numAggs_, numNodes_, isRoot_, vertex2AggId_, xCoords, yCoords, zCoords);
this->doConvexHulls3D(vertices, geomSizes, numAggs_, numNodes_, isRoot_, vertex2AggIds, xCoords, yCoords, zCoords);
}
}

Expand Down Expand Up @@ -571,6 +571,8 @@ void AggregationExportFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::writeF
if (dims_ == 3)
zCoords = coords_->getData(2);

auto vertex2AggIds = vertex2AggId_->getDataNonConst(0);

vector<int> uniqueFine = this->makeUnique(vertices);
string indent = " ";
fout << "<!--" << styleName << " Aggregates Visualization-->" << endl;
Expand All @@ -596,10 +598,10 @@ void AggregationExportFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::writeF
fout << " <DataArray type=\"Int32\" Name=\"Aggregate\" format=\"ascii\">" << endl;
fout << indent;
for (size_t i = 0; i < uniqueFine.size(); i++) {
if (vertex2AggId_[uniqueFine[i]] == -1)
fout << vertex2AggId_[uniqueFine[i]] << " ";
if (vertex2AggIds[uniqueFine[i]] == -1)
fout << vertex2AggIds[uniqueFine[i]] << " ";
else
fout << aggsOffset_ + vertex2AggId_[uniqueFine[i]] << " ";
fout << aggsOffset_ + vertex2AggIds[uniqueFine[i]] << " ";
if (i % 10 == 9)
fout << endl
<< indent;
Expand Down

0 comments on commit 67c25f4

Please sign in to comment.