diff --git a/opm/polymer/fullyimplicit/FullyImplicitBlackoilPolymerSolver_impl.hpp b/opm/polymer/fullyimplicit/FullyImplicitBlackoilPolymerSolver_impl.hpp index e608a69e8..f285c4650 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitBlackoilPolymerSolver_impl.hpp +++ b/opm/polymer/fullyimplicit/FullyImplicitBlackoilPolymerSolver_impl.hpp @@ -1310,15 +1310,19 @@ namespace detail { // Update primary variables, if necessary. if (bhp_changed) { ADB::V new_bhp = Eigen::Map<ADB::V>(xw.bhp().data(), nw); - bhp = ADB::function(new_bhp, bhp.derivative()); + // Avoiding the copy below would require a value setter method + // in AutoDiffBlock. + std::vector<ADB::M> old_derivs = bhp.derivative(); + bhp = ADB::function(std::move(new_bhp), std::move(old_derivs)); } if (rates_changed) { // Need to reshuffle well rates, from phase running fastest // to wells running fastest. // The transpose() below switches the ordering. const DataBlock wrates = Eigen::Map<const DataBlock>(xw.wellRates().data(), nw, np).transpose(); - const ADB::V new_qs = Eigen::Map<const V>(wrates.data(), nw*np); - well_phase_flow_rate = ADB::function(new_qs, well_phase_flow_rate.derivative()); + ADB::V new_qs = Eigen::Map<const V>(wrates.data(), nw*np); + std::vector<ADB::M> old_derivs = well_phase_flow_rate.derivative(); + well_phase_flow_rate = ADB::function(std::move(new_qs), std::move(old_derivs)); } } @@ -2397,7 +2401,7 @@ namespace detail { fastSparseProduct(dpm_diag, p.derivative()[block], jacs[block]); } return ADB::function(std::move(pm), std::move(jacs)); - } else { + } else { return ADB::constant(V::Constant(n, 1.0), p.blockPattern()); } } diff --git a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp index 485f9ac46..7ceec001e 100644 --- a/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp +++ b/opm/polymer/fullyimplicit/FullyImplicitCompressiblePolymerSolver.cpp @@ -994,7 +994,7 @@ namespace { for (int block = 0; block < num_blocks; ++block) { jacs[block] = dpm_diag * p.derivative()[block]; } - return ADB::function(pm, jacs); + return ADB::function(std::move(pm), std::move(jacs)); } else { return ADB::constant(V::Constant(n, 1.0), p.blockPattern()); } @@ -1021,7 +1021,7 @@ namespace { for (int block = 0; block < num_blocks; ++block) { jacs[block] = dtm_diag * p.derivative()[block]; } - return ADB::function(tm, jacs); + return ADB::function(std::move(tm), std::move(jacs)); } else { return ADB::constant(V::Constant(n, 1.0), p.blockPattern()); } diff --git a/opm/polymer/fullyimplicit/PolymerPropsAd.cpp b/opm/polymer/fullyimplicit/PolymerPropsAd.cpp index ed0123a85..184426a31 100644 --- a/opm/polymer/fullyimplicit/PolymerPropsAd.cpp +++ b/opm/polymer/fullyimplicit/PolymerPropsAd.cpp @@ -117,7 +117,7 @@ namespace Opm { for (int block = 0; block < num_blocks; ++block) { jacs[block] = dim_diag * c.derivative()[block]; } - return ADB::function(inv_mu_w_eff, jacs); + return ADB::function(std::move(inv_mu_w_eff), std::move(jacs)); } @@ -165,7 +165,7 @@ namespace Opm { jacs[block] = dmc_diag * c.derivative()[block]; } - return ADB::function(mc, jacs); + return ADB::function(std::move(mc), std::move(jacs)); } @@ -213,7 +213,7 @@ namespace Opm { jacs[block] = dads_diag * c.derivative()[block]; } - return ADB::function(ads, jacs); + return ADB::function(std::move(ads), std::move(jacs)); }