diff --git a/opm/models/blackoil/blackoilintensivequantities.hh b/opm/models/blackoil/blackoilintensivequantities.hh index 49e1685df..7c2031aa6 100644 --- a/opm/models/blackoil/blackoilintensivequantities.hh +++ b/opm/models/blackoil/blackoilintensivequantities.hh @@ -162,9 +162,46 @@ public: } } - BlackOilIntensiveQuantities(const BlackOilIntensiveQuantities& other) = default; + BlackOilIntensiveQuantities(const BlackOilIntensiveQuantities& other) { + if (other.dirMob_) { + dirMob_ = std::make_unique( + other.dirMob_->mobilityX_, + other.dirMob_->mobilityY_, + other.dirMob_->mobilityY_ + ); + } + }; - BlackOilIntensiveQuantities& operator=(const BlackOilIntensiveQuantities& other) = default; + BlackOilIntensiveQuantities& operator=(const BlackOilIntensiveQuantities& other) { + fluidState_ = other.fluidState_; + referencePorosity_ = other.referencePorosity_; + porosity_ = other.porosity_; + rockCompTransMultiplier_ = other.rockCompTransMultiplier_; + mobility_ = other.mobility_; + if (other.dirMob_) { + dirMob_ = std::make_unique( + other.dirMob_->mobilityX_, + other.dirMob_->mobilityY_, + other.dirMob_->mobilityY_ + ); + } + else { + dirMob_.release(); // release any memory, and assign nullptr + } + // call assignment operators in the parent classes + GetPropType::operator=(other); + GetPropType::FluxIntensiveQuantities::operator=(other); + BlackOilDiffusionIntensiveQuantities() >::operator=(other); + BlackOilSolventIntensiveQuantities::operator=(other); + BlackOilExtboIntensiveQuantities::operator=(other); + BlackOilPolymerIntensiveQuantities::operator=(other); + BlackOilFoamIntensiveQuantities::operator=(other); + BlackOilBrineIntensiveQuantities::operator=(other); + BlackOilEnergyIntensiveQuantities::operator=(other); + BlackOilMICPIntensiveQuantities::operator=(other); + + return *this; + }; /*! * \copydoc IntensiveQuantities::update @@ -688,7 +725,7 @@ private: Evaluation porosity_; Evaluation rockCompTransMultiplier_; std::array mobility_; - std::shared_ptr dirMob_; + std::unique_ptr dirMob_; }; } // namespace Opm