From 11bda0de078447db1140663b08ce49b5091973d9 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 3 Mar 2023 09:22:27 +0100 Subject: [PATCH] added: log ThresholdPressures to PRT file --- ebos/eclgenericthresholdpressure.cc | 49 +++++++++++++++++++++++++++++ ebos/eclgenericthresholdpressure.hh | 2 ++ ebos/eclthresholdpressure.hh | 2 ++ 3 files changed, 53 insertions(+) diff --git a/ebos/eclgenericthresholdpressure.cc b/ebos/eclgenericthresholdpressure.cc index cd65d9f8c..a0a6331a3 100644 --- a/ebos/eclgenericthresholdpressure.cc +++ b/ebos/eclgenericthresholdpressure.cc @@ -46,6 +46,8 @@ #include #endif // HAVE_DUNE_FEM +#include + #include #include #include @@ -248,6 +250,53 @@ getRestartVector() const return result; } +template +void +EclGenericThresholdPressure:: +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>>, diff --git a/ebos/eclgenericthresholdpressure.hh b/ebos/eclgenericthresholdpressure.hh index 750edc387..e5d67711d 100644 --- a/ebos/eclgenericthresholdpressure.hh +++ b/ebos/eclgenericthresholdpressure.hh @@ -88,6 +88,8 @@ protected: void configureThpresft_(); + void logPressures(); + const CartesianIndexMapper& cartMapper_; const GridView& gridView_; const ElementMapper& elementMapper_; diff --git a/ebos/eclthresholdpressure.hh b/ebos/eclthresholdpressure.hh index 1d2d75ed2..10021d3bb 100644 --- a/ebos/eclthresholdpressure.hh +++ b/ebos/eclthresholdpressure.hh @@ -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_;