Merge pull request #5111 from lisajulia/feature/deterministic-indicesSyncer

Construct the matrices in the AMG hierarchy with deterministic indices.
This commit is contained in:
Bård Skaflestad
2024-01-29 13:37:54 +01:00
committed by GitHub
2 changed files with 40 additions and 3 deletions

View File

@@ -96,6 +96,18 @@ struct AMGSmootherArgsHelper<Opm::ParallelOverlappingILU0<M,V,V,C>>
};
// trailing return type with decltype used for detecting existence of setUseFixedOrder member function by overloading the setUseFixedOrder function
template <typename C>
auto setUseFixedOrder(C criterion, bool booleanValue) -> decltype(criterion.setUseFixedOrder(booleanValue))
{
return criterion.setUseFixedOrder(booleanValue); // Set flag to ensure that the matrices in the AMG hierarchy are constructed with deterministic indices.
}
template <typename C>
void setUseFixedOrder(C, ...)
{
// do nothing, since the function setUseFixedOrder does not exist yet
}
template <class Operator, class Comm, class Matrix, class Vector>
typename AMGHelper<Operator, Comm, Matrix, Vector>::Criterion
AMGHelper<Operator,Comm,Matrix,Vector>::criterion(const PropertyTree& prm)
@@ -118,6 +130,7 @@ AMGHelper<Operator,Comm,Matrix,Vector>::criterion(const PropertyTree& prm)
criterion.setMaxConnectivity(prm.get<int>("maxconnectivity", 15));
criterion.setMaxAggregateSize(prm.get<int>("maxaggsize", 6));
criterion.setMinAggregateSize(prm.get<int>("minaggsize", 4));
setUseFixedOrder(criterion, true); // If possible, set flag to ensure that the matrices in the AMG hierarchy are constructed with deterministic indices.
return criterion;
}

View File

@@ -187,9 +187,8 @@ public:
std::vector<bool> excluded(fineOperator.getmat().N(), false);
VisitedMap vm(excluded.begin(), Dune::IdentityMap());
ParallelInformation pinfo;
std::size_t aggregates = renumberer.coarsen(pinfo, pg, vm,
*aggregatesMap_, pinfo,
noAggregates);
std::size_t aggregates = coarsen(renumberer, pinfo, pg, vm,*aggregatesMap_, noAggregates, true);
std::vector<bool>& visited=excluded;
typedef std::vector<bool>::iterator Iterator;
@@ -228,6 +227,31 @@ public:
}
private:
// trailing return type with decltype used for detecting the signature of coarsen member function by overloading this coarsen function
template <typename RN, typename PI, typename PG, typename VM, typename AM>
auto coarsen(RN& renumberer,
PI& pinfo,
PG& pg,
VM& vm,
AM& aggregatesMap,
int noAggregates,
bool useFixedOrder) ->
decltype(renumberer.coarsen(pinfo, pg, vm, aggregatesMap, pinfo, noAggregates, useFixedOrder))
{
return renumberer.coarsen(pinfo, pg, vm, aggregatesMap, pinfo, noAggregates, useFixedOrder);
}
template <typename RN, typename PI, typename PG, typename VM, typename AM>
auto coarsen(RN& renumberer,
PI& pinfo,
PG& pg,
VM& vm,
AM& aggregatesMap,
int noAggregates, ...)
{
return renumberer.coarsen(pinfo, pg, vm, aggregatesMap, pinfo, noAggregates);
}
typename O::matrix_type::field_type prolongDamp_;
std::shared_ptr<AggregatesMap> aggregatesMap_;
Criterion criterion_;