Make struct wells unique member of WellState

This commit is contained in:
Jørgen Kvalsvik 2016-05-31 09:59:18 +02:00
parent ec28c46842
commit 254bb2e1e6

View File

@ -26,6 +26,7 @@
#include <array>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include <cassert>
@ -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<double> bhp_;
std::vector<double> thp_;
@ -231,6 +258,12 @@ namespace Opm
std::vector<double> perfpress_;
WellMapType wellMap_;
protected:
struct wdel {
void operator()( Wells* w ) { destroy_wells( w ); }
};
std::unique_ptr< Wells, wdel > wells_;
};
} // namespace Opm