Prevent spurious warnings about NNCs when applying EDITNNC in parallel.

If we use transmissibilities for loadbalancing, then we calculate
transmissibilities twice. First on the global grid before
loadbalancing and then on the local grid after that. This is the
default. In this case all warnings will be shown correctly when
calculating the global transmissibilities.

If the user requests the same weights for all faces (command line
parameter --edge-weights-method=0) then the transmissibilities are only
calculated on the loadbalanced grid. Unfortunately, in this case only
rank 0 will issue warnings for his part including the false positives
mentioned below.

Due to load balancing many NNCs might be stored on another process,
but we still use all EDITNNC entries when computing transmissibilties
locally. Hence when applying EDITNNC on the loadbalanced grid we
will issue warnings for cases where there are no problems (e.g. NNC
between two overlap cells.

With this PR we will only warn when computing the transmissibilities
for the first time. For the default settings this will remove spurious
and duplicate warnings.

Not that for --edge-weights-method=0 nothing changes and we will still
see only warnings for the first rank including spurious one.
This commit is contained in:
Markus Blatt 2024-05-14 16:05:31 +02:00
parent b2c06415f4
commit fc67eaeeda
2 changed files with 27 additions and 13 deletions

View File

@ -226,17 +226,18 @@ protected:
void applyNncToGridTrans_(const std::unordered_map<std::size_t,int>& cartesianToCompressed);
/// \brief Multiplies the grid transmissibilities according to EDITNNC.
void applyEditNncToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal);
void applyEditNncToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal, const bool warn);
/// \brief Resets the grid transmissibilities according to EDITNNCR.
void applyEditNncrToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal);
void applyEditNncrToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal, const bool warn);
void applyNncMultreg_(const std::unordered_map<std::size_t,int>& globalToLocal);
void applyEditNncToGridTransHelper_(const std::unordered_map<std::size_t,int>& globalToLocal,
const std::string& keyword, const std::vector<NNCdata>& nncs,
const std::function<KeywordLocation(const NNCdata&)>& getLocation,
const std::function<void(Scalar&, const Scalar&)>& apply);
const std::function<void(Scalar&, const Scalar&)>& apply,
const bool warn);
void extractPermeability_();
@ -287,6 +288,7 @@ protected:
bool enableEnergy_;
bool enableDiffusivity_;
bool enableDispersivity_;
bool warnEditNNC_ = true;
std::unordered_map<std::uint64_t, Scalar> thermalHalfTrans_; //NB this is based on direction map size is ca 2*trans_ (diffusivity_)
std::unordered_map<std::uint64_t, Scalar> diffusivity_;
std::unordered_map<std::uint64_t, Scalar> dispersivity_;

View File

@ -574,12 +574,18 @@ update(bool global, const TransUpdateQuantities update_quantities,
}
if (!disableNNC) {
this->applyEditNncToGridTrans_(globalToLocal);
// For EDITNNC and EDITNNCR we warn only once
// If transmissibility is used for load balancing this will be done
// when computing the gobal transmissibilities and all warnings will
// be seen in a parallel. Unfortunately, when we do not use transmissibilities
// we will only see warnings for the partition of process 0 and also false positives.
this->applyEditNncToGridTrans_(globalToLocal, warnEditNNC_);
this->applyNncToGridTrans_(globalToLocal);
this->applyEditNncrToGridTrans_(globalToLocal);
this->applyEditNncrToGridTrans_(globalToLocal, warnEditNNC_);
if (applyNncMultregT) {
this->applyNncMultreg_(globalToLocal);
}
warnEditNNC_ = false;
}
// If disableNNC == true, remove all non-neighbouring transmissibilities.
@ -1124,7 +1130,7 @@ applyNncToGridTrans_(const std::unordered_map<std::size_t,int>& cartesianToCompr
template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
void Transmissibility<Grid,GridView,ElementMapper,CartesianIndexMapper,Scalar>::
applyEditNncToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal)
applyEditNncToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal, bool warn)
{
const auto& input = eclState_.getInputNNC();
applyEditNncToGridTransHelper_(globalToLocal, "EDITNNC",
@ -1132,12 +1138,13 @@ applyEditNncToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLoca
[&input](const NNCdata& nnc){
return input.edit_location(nnc);},
// Multiply transmissibility with EDITNNC value
[](Scalar& trans, const Scalar& rhs){ trans *= rhs;});
[](Scalar& trans, const Scalar& rhs){ trans *= rhs;},
warn);
}
template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
void Transmissibility<Grid,GridView,ElementMapper,CartesianIndexMapper,Scalar>::
applyEditNncrToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal)
applyEditNncrToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal, bool warn)
{
const auto& input = eclState_.getInputNNC();
applyEditNncToGridTransHelper_(globalToLocal, "EDITNNCR",
@ -1145,7 +1152,8 @@ applyEditNncrToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLoc
[&input](const NNCdata& nnc){
return input.editr_location(nnc);},
// Replace Transmissibility with EDITNNCR value
[](Scalar& trans, const Scalar& rhs){ trans = rhs;});
[](Scalar& trans, const Scalar& rhs){ trans = rhs;},
warn);
}
template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
@ -1154,7 +1162,8 @@ applyEditNncToGridTransHelper_(const std::unordered_map<std::size_t,int>& global
const std::string& keyword,
const std::vector<NNCdata>& nncs,
const std::function<KeywordLocation(const NNCdata&)>& getLocation,
const std::function<void(Scalar&, const Scalar&)>& apply)
const std::function<void(Scalar&, const Scalar&)>& apply,
const bool warn)
{
if (nncs.empty())
return;
@ -1190,9 +1199,12 @@ applyEditNncToGridTransHelper_(const std::unordered_map<std::size_t,int>& global
auto highIt = globalToLocal.find(c2);
if (lowIt == globalToLocal.end() || highIt == globalToLocal.end()) {
print_warning(*nnc);
// Prevent warnings for NNCs stored on other processes in parallel (both cells inactive)
if ( lowIt != highIt && warn) {
print_warning(*nnc);
warning_count++;
}
++nnc;
warning_count++;
continue;
}
@ -1202,7 +1214,7 @@ applyEditNncToGridTransHelper_(const std::unordered_map<std::size_t,int>& global
std::swap(low, high);
auto candidate = trans_.find(details::isId(low, high));
if (candidate == trans_.end()) {
if (candidate == trans_.end() && warn) {
print_warning(*nnc);
++nnc;
warning_count++;