From ad3da1d946ea28f7c5eb86dc890c89e69979a8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 19 Mar 2015 11:25:47 +0100 Subject: [PATCH] Re-add copying overload of AutoDiffBlock::function(). --- opm/autodiff/AutoDiffBlock.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/opm/autodiff/AutoDiffBlock.hpp b/opm/autodiff/AutoDiffBlock.hpp index e6feeed14..5ba57b32f 100644 --- a/opm/autodiff/AutoDiffBlock.hpp +++ b/opm/autodiff/AutoDiffBlock.hpp @@ -188,6 +188,8 @@ namespace Opm } /// Create an AutoDiffBlock by directly specifying values and jacobians. + /// This version of function() moves its arguments and is therefore + /// quite efficient, but leaves the argument variables empty (but valid). /// \param[in] val values /// \param[in] jac vector of jacobians static AutoDiffBlock function(V&& val, std::vector&& jac) @@ -195,6 +197,18 @@ namespace Opm return AutoDiffBlock(std::move(val), std::move(jac)); } + /// Create an AutoDiffBlock by directly specifying values and jacobians. + /// This version of function() copies its arguments and is therefore + /// less efficient than the other (moving) overload. + /// \param[in] val values + /// \param[in] jac vector of jacobians + static AutoDiffBlock function(const V& val, const std::vector& jac) + { + V val_copy(val); + std::vector jac_copy(jac); + return AutoDiffBlock(std::move(val_copy), std::move(jac_copy)); + } + /// Construct a set of primary variables, each initialized to /// a given vector. static std::vector variables(const std::vector& initial_values)