added: log ThresholdPressures to PRT file

This commit is contained in:
Arne Morten Kvarving 2023-03-03 09:22:27 +01:00
parent e2ce26c031
commit 11bda0de07
3 changed files with 53 additions and 0 deletions

View File

@ -46,6 +46,8 @@
#include <ebos/femcpgridcompat.hh>
#endif // HAVE_DUNE_FEM
#include <fmt/format.h>
#include <algorithm>
#include <cassert>
#include <stdexcept>
@ -248,6 +250,53 @@ getRestartVector() const
return result;
}
template<class Grid, class GridView, class ElementMapper, class Scalar>
void
EclGenericThresholdPressure<Grid,GridView,ElementMapper,Scalar>::
logPressures()
{
if (!enableThresholdPressure_)
return;
auto lineFormat = [this](unsigned i, unsigned j, double val)
{
const auto& units = eclState_.getUnits();
return fmt::format("{:4}{:>6}{:23}{:>6}{:24}{:>11.07}{:7}{}\n",
" ", i,
" ", j,
" ", units.from_si(UnitSystem::measure::pressure, val),
" ", units.name(UnitSystem::measure::pressure));
};
auto lineFormatS = [](auto s1, auto s2, auto s3)
{
return fmt::format("{:4}{:^16}{:13}{:^9}{:21}{:^18}\n",
" ", s1, " ", s2, " ", s3);
};
std::string str = "\nLIST OF ALL NON-ZERO THRESHOLD PRESSURES\n"
"----------------------------------------\n"
"\n";
str += lineFormatS("FLOW FROM REGION", "TO REGION", "THRESHOLD PRESSURE");
str += lineFormatS(std::string(16, '-'), std::string(9, '-'), std::string(18, '-'));
const auto& simConfig = eclState_.getSimulationConfig();
const auto& thpres = simConfig.getThresholdPressure();
for (unsigned i = 1; i <= numEquilRegions_; ++i) {
for (unsigned j = (thpres.irreversible() ? 1 : i); j <= numEquilRegions_; ++j) {
if (thpres.hasRegionBarrier(i, j)) {
if (thpres.hasThresholdPressure(i, j)) {
str += lineFormat(i, j, thpres.getThresholdPressure(j, i));
} else {
std::size_t idx = (j - 1) * numEquilRegions_ + (i - 1);
str += lineFormat(i, j, this->thpresDefault_[idx]);
}
}
}
}
str += lineFormatS(std::string(16, '-'), std::string(9, '-'), std::string(18, '-'));
OpmLog::note(str);
}
#if HAVE_DUNE_FEM
template class EclGenericThresholdPressure<Dune::CpGrid,
Dune::GridView<Dune::Fem::GridPart2GridViewTraits<Dune::Fem::AdaptiveLeafGridPart<Dune::CpGrid, Dune::PartitionIteratorType(4), false>>>,

View File

@ -88,6 +88,8 @@ protected:
void configureThpresft_();
void logPressures();
const CartesianIndexMapper& cartMapper_;
const GridView& gridView_;
const ElementMapper& elementMapper_;

View File

@ -154,6 +154,8 @@ private:
// runs. (i.e. take the maximum of all processes)
for (unsigned i = 0; i < this->thpresDefault_.size(); ++i)
this->thpresDefault_[i] = gridView.comm().max(this->thpresDefault_[i]);
this->logPressures();
}
const Simulator& simulator_;