diff src/Function.cc @ 253:5e9b5bbdc56b

Support both DOLFIN 1.3.0 and 1.4.0 * src/dolfin_compat.h: use a macro to set the correct shared_ptr (std or boost)
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Tue, 29 Jul 2014 18:05:56 +0200
parents a57001686abb
children 8fe68d94ab76
line wrap: on
line diff
--- a/src/Function.cc	Tue Jul 29 17:11:59 2014 +0200
+++ b/src/Function.cc	Tue Jul 29 18:05:56 2014 +0200
@@ -18,6 +18,7 @@
 #include <dolfin.h>
 #include "functionspace.h"
 #include "function.h"
+#include "dolfin_compat.h"
 
 DEFUN_DLD (Function, args, , "-*- texinfo -*-\n\
 @deftypefn {Function File} {[@var{func}]} = \
@@ -81,7 +82,7 @@
 
           if (!error_state)
             {
-              const boost::shared_ptr<const dolfin::FunctionSpace>
+              const SHARED_PTR <const dolfin::FunctionSpace>
                 & V = fspo.get_pfsp ();
 
               if (V->dim () != myu.length ())
@@ -89,14 +90,18 @@
                        and of the vector must agree");
               else
                 {
+#ifdef LATEST_DOLFIN
+                  dolfin::Vector du (MPI_COMM_WORLD, myu.length ());
+#else
                   dolfin::Vector du(myu.length ());
+#endif
                   for (std::size_t i = 0; i < myu.length (); ++i)
                     du.setitem (i, myu(i));
 
-                  boost::shared_ptr<dolfin::Vector> 
+                  SHARED_PTR <dolfin::Vector> 
                     uu (new dolfin::Vector(du));
 
-                  boost::shared_ptr <const dolfin::Function>
+                  SHARED_PTR <const dolfin::Function>
                     u (new dolfin::Function(V, uu));
 
                   retval = new function (str, u);
@@ -112,7 +117,7 @@
 
           if (!error_state)
             {
-              const boost::shared_ptr<const dolfin::Function>
+              const SHARED_PTR <const dolfin::Function>
                 & f = fspo.get_pfun ();
 
               if (f->value_rank () < 1)
@@ -124,7 +129,7 @@
                     error ("Function: index out of bounds");
                  else
                    {
-                      boost::shared_ptr <const dolfin::Function>
+                      SHARED_PTR <const dolfin::Function>
                         u (new dolfin::Function((*f)[idx - 1]));
 
                       retval = new function (str, u);