From bdc88e8ed46b3bc029ffcc28ff393431380e74df Mon Sep 17 00:00:00 2001
From: Jonathan Youett <youett@math.fu-berlin.de>
Date: Wed, 6 Sep 2017 14:52:19 +0200
Subject: [PATCH] Add setter for obstacle field, and store it internally as
 shared_ptr

---
 dune/solvers/solvers/quadraticipopt.hh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/dune/solvers/solvers/quadraticipopt.hh b/dune/solvers/solvers/quadraticipopt.hh
index 301bbc4c..6dd96e70 100644
--- a/dune/solvers/solvers/quadraticipopt.hh
+++ b/dune/solvers/solvers/quadraticipopt.hh
@@ -21,6 +21,7 @@
 
 #include <dune/solvers/common/boxconstraint.hh>
 #include <dune/solvers/common/canignore.hh>
+#include <dune/solvers/common/wrapownshare.hh>
 #include <dune/solvers/solvers/linearsolver.hh>
 
 #include "IpTNLP.hpp"
@@ -697,6 +698,12 @@ public:
         constraintObstacles_ = Dune::stackobject_to_shared_ptr(obstacles);
     }
 
+    //! Set box-constraints for the coordinates
+    template <class ObstacleVector>
+    void setObstacles(ObstacleVector&& obstacles) {
+        obstacles_ = wrap_own_share<std::vector<BoxConstraint<field_type, blocksize> > >(std::forward<ObstacleVector>(obstacles));
+    }
+
     virtual void solve();
 
     ///////////////////////////////////////////////////////
@@ -720,7 +727,7 @@ public:
 
     //! Vector containing the bound constraints of the variables
     // Can stay unset when no bound constraints exist
-    std::vector<BoxConstraint<field_type,blocksize> >* obstacles_;
+    std::shared_ptr<std::vector<BoxConstraint<field_type,blocksize> > > obstacles_;
 
     //! The type of the linear solver to be used within IpOpt, default depends on the system where IpOpt is built
     std::string linearSolverType_;
-- 
GitLab