Skip to content

Commit

Permalink
Tell aggregate export about Graph and Aggregates
Browse files Browse the repository at this point in the history
Signed-off-by: maxfirmbach <[email protected]>
  • Loading branch information
maxfirmbach committed Nov 7, 2024
1 parent 4e6e2ca commit a319a19
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 a319a19

Please sign in to comment.