From aff268dbdbe2aaf43fb5052da8e4b23e4ea5d581 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= <atgeirr@sintef.no>
Date: Mon, 16 Mar 2015 16:49:12 +0100
Subject: [PATCH] Adapt to API change for AutoDiffBlock class.

---
 .../FullyImplicitBlackoilPolymerSolver_impl.hpp    | 14 +++++++++-----
 .../FullyImplicitCompressiblePolymerSolver.cpp     |  4 ++--
 opm/polymer/fullyimplicit/PolymerPropsAd.cpp       |  6 +++---
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/opm/polymer/fullyimplicit/FullyImplicitBlackoilPolymerSolver_impl.hpp b/opm/polymer/fullyimplicit/FullyImplicitBlackoilPolymerSolver_impl.hpp
index 28826f5b5..5904a3c48 100644
--- a/opm/polymer/fullyimplicit/FullyImplicitBlackoilPolymerSolver_impl.hpp
+++ b/opm/polymer/fullyimplicit/FullyImplicitBlackoilPolymerSolver_impl.hpp
@@ -1198,15 +1198,19 @@ namespace {
         // 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));
         }
     }
 
@@ -2171,7 +2175,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());
         }
@@ -2199,7 +2203,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/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));
     }