mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
added: hook up RPTRST CONV output to restart file if requested
This commit is contained in:
parent
44bb4172fa
commit
be84969338
@ -91,6 +91,9 @@ public:
|
|||||||
const data::Solution& globalCellData() const
|
const data::Solution& globalCellData() const
|
||||||
{ return globalCellData_; }
|
{ return globalCellData_; }
|
||||||
|
|
||||||
|
data::Solution& globalCellData()
|
||||||
|
{ return globalCellData_; }
|
||||||
|
|
||||||
const data::Wells& globalWellData() const
|
const data::Wells& globalWellData() const
|
||||||
{ return globalWellData_; }
|
{ return globalWellData_; }
|
||||||
|
|
||||||
|
@ -1499,6 +1499,20 @@ setupBlockData(std::function<bool(int)> isCartIdxOnThisRank)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class FluidSystem, class Scalar>
|
||||||
|
void EclGenericOutputBlackoilModule<FluidSystem,Scalar>::
|
||||||
|
assignGlobalFieldsToSolution(data::Solution& sol)
|
||||||
|
{
|
||||||
|
if (!this->cnvData_.empty()) {
|
||||||
|
constexpr std::array names = {"CNV_OIL", "CNV_GAS", "CNV_WAT"};
|
||||||
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
|
if (!this->cnvData_[i].empty()) {
|
||||||
|
sol.insert(names[i], this->cnvData_[i], data::TargetType::RESTART_SOLUTION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template class EclGenericOutputBlackoilModule<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,double>;
|
template class EclGenericOutputBlackoilModule<BlackOilFluidSystem<double,BlackOilDefaultIndexTraits>,double>;
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -35,9 +35,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <numeric>
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <stdexcept>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -268,6 +266,11 @@ public:
|
|||||||
local_data_valid_ = true;
|
local_data_valid_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setCnvData(const std::vector<std::vector<int>>& data)
|
||||||
|
{
|
||||||
|
cnvData_ = data;
|
||||||
|
}
|
||||||
|
|
||||||
// Virtual destructor for safer inheritance.
|
// Virtual destructor for safer inheritance.
|
||||||
virtual ~EclGenericOutputBlackoilModule();
|
virtual ~EclGenericOutputBlackoilModule();
|
||||||
|
|
||||||
@ -277,6 +280,12 @@ public:
|
|||||||
serializer(initialInplace_);
|
serializer(initialInplace_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! \brief Assign fields that are in global numbering to the solution.
|
||||||
|
//! \detail This is used to add fields that for some reason cannot be collected
|
||||||
|
//! using the regular collect mechanism to the solution. In particular this
|
||||||
|
//! is used with RPTRST CONV output.
|
||||||
|
void assignGlobalFieldsToSolution(data::Solution& sol);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using ScalarBuffer = std::vector<Scalar>;
|
using ScalarBuffer = std::vector<Scalar>;
|
||||||
using StringBuffer = std::vector<std::string>;
|
using StringBuffer = std::vector<std::string>;
|
||||||
@ -490,6 +499,8 @@ protected:
|
|||||||
std::map<std::size_t, Scalar> gasConnectionSaturations_;
|
std::map<std::size_t, Scalar> gasConnectionSaturations_;
|
||||||
std::map<std::pair<std::string, int>, double> blockData_;
|
std::map<std::pair<std::string, int>, double> blockData_;
|
||||||
|
|
||||||
|
std::vector<std::vector<int>> cnvData_; //!< Data for CNV_xxx arrays
|
||||||
|
|
||||||
std::optional<Inplace> initialInplace_;
|
std::optional<Inplace> initialInplace_;
|
||||||
bool local_data_valid_;
|
bool local_data_valid_;
|
||||||
};
|
};
|
||||||
|
@ -108,6 +108,11 @@ public:
|
|||||||
return outputNnc_;
|
return outputNnc_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CollectDataToIORankType& collectToIORank() const
|
||||||
|
{
|
||||||
|
return collectToIORank_;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const TransmissibilityType& globalTrans() const;
|
const TransmissibilityType& globalTrans() const;
|
||||||
unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const;
|
unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <dune/common/fvector.hh>
|
#include <dune/common/fvector.hh>
|
||||||
|
|
||||||
|
#include <ebos/eclbasevanguard.hh>
|
||||||
#include <ebos/eclgenericoutputblackoilmodule.hh>
|
#include <ebos/eclgenericoutputblackoilmodule.hh>
|
||||||
|
|
||||||
#include <opm/common/Exceptions.hpp>
|
#include <opm/common/Exceptions.hpp>
|
||||||
@ -53,12 +54,8 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <initializer_list>
|
|
||||||
#include <numeric>
|
|
||||||
#include <optional>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -760,7 +760,7 @@ public:
|
|||||||
if (enableDamarisOutput_) {
|
if (enableDamarisOutput_) {
|
||||||
damarisWriter_->writeOutput(localCellData, isSubStep) ;
|
damarisWriter_->writeOutput(localCellData, isSubStep) ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (enableEclOutput_){
|
if (enableEclOutput_){
|
||||||
eclWriter_->writeOutput(std::move(localCellData), timer, isSubStep);
|
eclWriter_->writeOutput(std::move(localCellData), timer, isSubStep);
|
||||||
}
|
}
|
||||||
@ -1777,6 +1777,11 @@ public:
|
|||||||
return eclWriter_;
|
return eclWriter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setConvData(const std::vector<std::vector<int>>& data)
|
||||||
|
{
|
||||||
|
eclWriter_->mutableEclOutputModule().setCnvData(data);
|
||||||
|
}
|
||||||
|
|
||||||
template<class Serializer>
|
template<class Serializer>
|
||||||
void serializeOp(Serializer& serializer)
|
void serializeOp(Serializer& serializer)
|
||||||
{
|
{
|
||||||
|
@ -431,6 +431,11 @@ public:
|
|||||||
/* interRegFlows = */ {},
|
/* interRegFlows = */ {},
|
||||||
flowsn,
|
flowsn,
|
||||||
floresn);
|
floresn);
|
||||||
|
if (this->collectToIORank_.isIORank()) {
|
||||||
|
this->eclOutputModule_->assignGlobalFieldsToSolution(this->collectToIORank_.globalCellData());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this->eclOutputModule_->assignGlobalFieldsToSolution(localCellData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->collectToIORank_.isIORank()) {
|
if (this->collectToIORank_.isIORank()) {
|
||||||
|
@ -40,9 +40,10 @@
|
|||||||
#include <opm/simulators/aquifers/AquiferGridUtils.hpp>
|
#include <opm/simulators/aquifers/AquiferGridUtils.hpp>
|
||||||
#include <opm/simulators/aquifers/BlackoilAquiferModel.hpp>
|
#include <opm/simulators/aquifers/BlackoilAquiferModel.hpp>
|
||||||
#include <opm/simulators/flow/BlackoilModelEbosNldd.hpp>
|
#include <opm/simulators/flow/BlackoilModelEbosNldd.hpp>
|
||||||
|
#include <opm/simulators/flow/BlackoilModelParametersEbos.hpp>
|
||||||
#include <opm/simulators/flow/countGlobalCells.hpp>
|
#include <opm/simulators/flow/countGlobalCells.hpp>
|
||||||
#include <opm/simulators/flow/NonlinearSolverEbos.hpp>
|
#include <opm/simulators/flow/NonlinearSolverEbos.hpp>
|
||||||
#include <opm/simulators/flow/BlackoilModelParametersEbos.hpp>
|
#include <opm/simulators/flow/RSTConv.hpp>
|
||||||
#include <opm/simulators/timestepping/AdaptiveTimeSteppingEbos.hpp>
|
#include <opm/simulators/timestepping/AdaptiveTimeSteppingEbos.hpp>
|
||||||
#include <opm/simulators/timestepping/ConvergenceReport.hpp>
|
#include <opm/simulators/timestepping/ConvergenceReport.hpp>
|
||||||
#include <opm/simulators/timestepping/SimulatorReport.hpp>
|
#include <opm/simulators/timestepping/SimulatorReport.hpp>
|
||||||
@ -233,6 +234,8 @@ namespace Opm {
|
|||||||
, phaseUsage_(phaseUsageFromDeck(eclState()))
|
, phaseUsage_(phaseUsageFromDeck(eclState()))
|
||||||
, param_( param )
|
, param_( param )
|
||||||
, well_model_ (well_model)
|
, well_model_ (well_model)
|
||||||
|
, rst_conv_(ebosSimulator_.problem().eclWriter()->collectToIORank().localIdxToGlobalIdxMapping(),
|
||||||
|
grid_.comm())
|
||||||
, terminal_output_ (terminal_output)
|
, terminal_output_ (terminal_output)
|
||||||
, current_relaxation_(1.0)
|
, current_relaxation_(1.0)
|
||||||
, dx_old_(ebosSimulator_.model().numGridDof())
|
, dx_old_(ebosSimulator_.model().numGridDof())
|
||||||
@ -303,6 +306,22 @@ namespace Opm {
|
|||||||
|
|
||||||
report.pre_post_time += perfTimer.stop();
|
report.pre_post_time += perfTimer.stop();
|
||||||
|
|
||||||
|
auto getIdx = [](unsigned phaseIdx) -> int
|
||||||
|
{
|
||||||
|
if (FluidSystem::phaseIsActive(phaseIdx)) {
|
||||||
|
const unsigned sIdx = FluidSystem::solventComponentIndex(phaseIdx);
|
||||||
|
return Indices::canonicalToActiveComponentIndex(sIdx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
const auto& schedule = ebosSimulator_.vanguard().schedule();
|
||||||
|
rst_conv_.init(ebosSimulator_.vanguard().globalNumCells(),
|
||||||
|
schedule[timer.reportStepNum()].rst_config(),
|
||||||
|
{getIdx(FluidSystem::oilPhaseIdx),
|
||||||
|
getIdx(FluidSystem::gasPhaseIdx),
|
||||||
|
getIdx(FluidSystem::waterPhaseIdx)});
|
||||||
|
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,14 +394,19 @@ namespace Opm {
|
|||||||
convergence_reports_.back().report.reserve(11);
|
convergence_reports_.back().report.reserve(11);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SimulatorReportSingle result;
|
||||||
if ((this->param_.nonlinear_solver_ != "nldd") ||
|
if ((this->param_.nonlinear_solver_ != "nldd") ||
|
||||||
(iteration < this->param_.nldd_num_initial_newton_iter_))
|
(iteration < this->param_.nldd_num_initial_newton_iter_))
|
||||||
{
|
{
|
||||||
return this->nonlinearIterationNewton(iteration, timer, nonlinear_solver);
|
result = this->nonlinearIterationNewton(iteration, timer, nonlinear_solver);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return this->nlddSolver_->nonlinearIterationNldd(iteration, timer, nonlinear_solver);
|
result = this->nlddSolver_->nonlinearIterationNldd(iteration, timer, nonlinear_solver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rst_conv_.update(ebosSimulator_.model().linearizer().residual());
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -479,6 +503,7 @@ namespace Opm {
|
|||||||
Dune::Timer perfTimer;
|
Dune::Timer perfTimer;
|
||||||
perfTimer.start();
|
perfTimer.start();
|
||||||
ebosSimulator_.problem().endTimeStep();
|
ebosSimulator_.problem().endTimeStep();
|
||||||
|
ebosSimulator_.problem().setConvData(rst_conv_.getData());
|
||||||
report.pre_post_time += perfTimer.stop();
|
report.pre_post_time += perfTimer.stop();
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
@ -1056,6 +1081,9 @@ namespace Opm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<std::vector<int>>& getConvCells() const
|
||||||
|
{ return rst_conv_.getData(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// --------- Data members ---------
|
// --------- Data members ---------
|
||||||
|
|
||||||
@ -1077,6 +1105,8 @@ namespace Opm {
|
|||||||
// Well Model
|
// Well Model
|
||||||
BlackoilWellModel<TypeTag>& well_model_;
|
BlackoilWellModel<TypeTag>& well_model_;
|
||||||
|
|
||||||
|
RSTConv rst_conv_; //!< Helper class for RPTRST CONV
|
||||||
|
|
||||||
/// \brief Whether we print something to std::cout
|
/// \brief Whether we print something to std::cout
|
||||||
bool terminal_output_;
|
bool terminal_output_;
|
||||||
/// \brief The number of cells of the global grid.
|
/// \brief The number of cells of the global grid.
|
||||||
|
Loading…
Reference in New Issue
Block a user