diff --git a/ebos/eclgenericthresholdpressure.cc b/ebos/eclgenericthresholdpressure.cc index 2079846c5..cd65d9f8c 100644 --- a/ebos/eclgenericthresholdpressure.cc +++ b/ebos/eclgenericthresholdpressure.cc @@ -220,6 +220,34 @@ configureThpresft_() } } +template +std::vector +EclGenericThresholdPressure:: +getRestartVector() const +{ + if (!enableThresholdPressure_) + return {}; + + std::vector result(numEquilRegions_ * numEquilRegions_, 0.0); + const auto& simConfig = eclState_.getSimulationConfig(); + const auto& thpres = simConfig.getThresholdPressure(); + + std::size_t idx = 0; + for (unsigned j = 1; j <= numEquilRegions_; ++j) { + for (unsigned i = 1; i <= numEquilRegions_; ++i, ++idx) { + if (thpres.hasRegionBarrier(i, j)) { + if (thpres.hasThresholdPressure(i, j)) { + result[idx] = thpres.getThresholdPressure(i, j); + } else { + result[idx] = this->thpresDefault_[idx]; + } + } + } + } + + return result; +} + #if HAVE_DUNE_FEM template class EclGenericThresholdPressure>>, diff --git a/ebos/eclgenericthresholdpressure.hh b/ebos/eclgenericthresholdpressure.hh index 404d932b3..750edc387 100644 --- a/ebos/eclgenericthresholdpressure.hh +++ b/ebos/eclgenericthresholdpressure.hh @@ -72,6 +72,10 @@ public: void setFromRestart(const std::vector& values) { thpres_ = values; } + //! \brief Returns a fully expanded vector for restart file writing. + //! \details Returns the union of explicitly configured entries and defaulted values. + std::vector getRestartVector() const; + protected: /*! * \brief Actually compute the threshold pressures over a face as a pre-compute step. @@ -90,7 +94,7 @@ protected: const EclipseState& eclState_; std::vector thpresDefault_; std::vector thpres_; - unsigned numEquilRegions_; + unsigned numEquilRegions_{}; std::vector elemEquilRegion_; // threshold pressure accross faults. EXPERIMENTAL! diff --git a/ebos/eclwriter.hh b/ebos/eclwriter.hh index 04978a209..14a18dfb0 100644 --- a/ebos/eclwriter.hh +++ b/ebos/eclwriter.hh @@ -377,7 +377,7 @@ public: this->actionState(), this->udqState(), this->summaryState(), - simulator_.problem().thresholdPressure().data(), + simulator_.problem().thresholdPressure().getRestartVector(), curTime, nextStepSize, EWOMS_GET_PARAM(TypeTag, bool, EclOutputDoublePrecision), isFlowsn,