diff --git a/opm/core/simulator/WellState.hpp b/opm/core/simulator/WellState.hpp index 999dfcfff..7fc82cc12 100644 --- a/opm/core/simulator/WellState.hpp +++ b/opm/core/simulator/WellState.hpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -51,6 +52,7 @@ namespace Opm { // clear old name mapping wellMap_.clear(); + wells_.reset( clone_wells( wells ) ); if (wells) { const int nw = wells->number_of_wells; @@ -222,6 +224,31 @@ namespace Opm virtual ~WellState() {} + WellState() = default; + WellState( const WellState& rhs ) : + bhp_( rhs.bhp_ ), + thp_( rhs.thp_ ), + temperature_( rhs.temperature_ ), + wellrates_( rhs.wellrates_ ), + perfrates_( rhs.perfrates_ ), + perfpress_( rhs.perfpress_ ), + wellMap_( rhs.wellMap_ ), + wells_( clone_wells( rhs.wells_.get() ) ) + {} + + WellState& operator=( const WellState& rhs ) { + this->bhp_ = rhs.bhp_; + this->thp_ = rhs.thp_; + this->temperature_ = rhs.temperature_; + this->wellrates_ = rhs.wellrates_; + this->perfrates_ = rhs.perfrates_; + this->perfpress_ = rhs.perfpress_; + this->wellMap_ = rhs.wellMap_; + this->wells_.reset( clone_wells( rhs.wells_.get() ) ); + + return *this; + } + private: std::vector bhp_; std::vector thp_; @@ -231,6 +258,12 @@ namespace Opm std::vector perfpress_; WellMapType wellMap_; + + protected: + struct wdel { + void operator()( Wells* w ) { destroy_wells( w ); } + }; + std::unique_ptr< Wells, wdel > wells_; }; } // namespace Opm