Subject: [Fenics] dolfinPython wrapper error in dorsal

From: Shiyuan <[email-masked]>
Date: Sun, 18 Nov 2012 14:16:41 -0600

Hi,
   I try to build FEniCS using dorsal on Mac 10.7. but at first python
wrapper fails to build.  The swig interface in dolfinPYTHON_wrap.cxx are
not correct generated and cannot be compiled.  After the following patch is
applied, it can be compiled but the demo programs don't run due to some
SWIG-boost error.

mac0347712n$ python demo_cahn-hilliard.py
Calling FFC just-in-time (JIT) compiler, this may take some time.
Traceback (most recent call last):
  File "demo_cahn-hilliard.py", line 64, in <module>
    V = FunctionSpace(mesh, "Lagrange", 1)
  File
"/Users/sgu/softwares/mpi/FEniCS/lib/python2.7/site-packages/dolfin/functions/functionspace.py",
line 353, in __init__
    FunctionSpaceBase.__init__(self, mesh, element)
  File
"/Users/sgu/softwares/mpi/FEniCS/lib/python2.7/site-packages/dolfin/functions/functionspace.py",
line 80, in __init__
    self._dolfin_element = cpp.FiniteElement(ufc_element)
  File
"/Users/sgu/softwares/mpi/FEniCS/lib/python2.7/site-packages/dolfin/cpp.py",
line 17790, in __init__
    _cpp.FiniteElement_swiginit(self,_cpp.new_FiniteElement(*args))
TypeError: in method 'new_FiniteElement', argument 1 of type
'boost::shared_ptr< ufc::finite_element const >'

 the dolfin-config.cmake, lion.platform, dolfin.package are attached.
---------------------------
--- dolfinPYTHON_wrap.cxx 2012-11-18 00:27:37.000000000 -0600
+++ dolfinPYTHON_wrap_new.cxx 2012-11-18 13:28:49.000000000 -0600
@@ -4901,7 +4901,7 @@
 dolfin::uint SwigDirector_uBLASKrylovMatrix::size(dolfin::uint dim) const {
   dolfin::uint c_result;
   swig::SwigVar_PyObject obj0;
-  obj0 = SWIG_From_unsigned_SS_int(static_cast< unsigned int >());
+  obj0 = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(dim));
   if (!swig_get_self()) {
     Swig::DirectorException::raise("'self' uninitialized, maybe you forgot
to call uBLASKrylovMatrix.__init__.");
   }
@@ -4932,9 +4932,9 @@

 void SwigDirector_uBLASKrylovMatrix::mult(dolfin::uBLASVector const &x,
dolfin::uBLASVector &y) const {
   swig::SwigVar_PyObject obj0;
-  obj0 = SWIG_NewPointerObj(SWIG_as_voidptr(&),
SWIGTYPE_p_dolfin__uBLASVector,  0 );
+  obj0 = SWIG_NewPointerObj(SWIG_as_voidptr(&x),
SWIGTYPE_p_dolfin__uBLASVector,  0 );
   swig::SwigVar_PyObject obj1;
-  obj1 = SWIG_NewPointerObj(SWIG_as_voidptr(&),
SWIGTYPE_p_dolfin__uBLASVector,  0 );
+  obj1 = SWIG_NewPointerObj(SWIG_as_voidptr(&y),
SWIGTYPE_p_dolfin__uBLASVector,  0 );
   if (!swig_get_self()) {
     Swig::DirectorException::raise("'self' uninitialized, maybe you forgot
to call uBLASKrylovMatrix.__init__.");
   }
@@ -4976,7 +4976,7 @@
 std::string SwigDirector_PETScKrylovMatrix::str(bool verbose) const {
   std::string c_result;
   swig::SwigVar_PyObject obj0;
-  obj0 = SWIG_From_bool(static_cast< bool >());
+  obj0 = SWIG_From_bool(static_cast< bool >(verbose));
   if (!swig_get_self()) {
     Swig::DirectorException::raise("'self' uninitialized, maybe you forgot
to call PETScKrylovMatrix.__init__.");
   }
@@ -5008,9 +5008,9 @@

 void SwigDirector_PETScKrylovMatrix::resize(dolfin::uint m, dolfin::uint
n) {
   swig::SwigVar_PyObject obj0;
-  obj0 = SWIG_From_unsigned_SS_int(static_cast< unsigned int >());
+  obj0 = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(m));
   swig::SwigVar_PyObject obj1;
-  obj1 = SWIG_From_unsigned_SS_int(static_cast< unsigned int >());
+  obj1 = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(n));
   if (!swig_get_self()) {
     Swig::DirectorException::raise("'self' uninitialized, maybe you forgot
to call PETScKrylovMatrix.__init__.");
   }
@@ -5238,7 +5238,7 @@
     obj0 = make_1d_numpy_array_double(x.size(), x.data().get(), false);
   }
   swig::SwigVar_PyObject obj1;
-  obj1 = SWIG_From_bool(static_cast< bool >());
+  obj1 = SWIG_From_bool(static_cast< bool >(on_boundary));
   if (!swig_get_self()) {
     Swig::DirectorException::raise("'self' uninitialized, maybe you forgot
to call SubDomain.__init__.");
   }
@@ -5371,7 +5371,7 @@
     obj1 = make_1d_numpy_array_double(x.size(), x.data().get(), false);
   }
   swig::SwigVar_PyObject obj2;
-  obj2 = SWIG_NewPointerObj(SWIG_as_voidptr(&), SWIGTYPE_p_ufc__cell,  0 );
+  obj2 = SWIG_NewPointerObj(SWIG_as_voidptr(&cell), SWIGTYPE_p_ufc__cell,
 0 );
   if (!swig_get_self()) {
     Swig::DirectorException::raise("'self' uninitialized, maybe you forgot
to call Expression.__init__.");
   }

---

From: Johannes Ring <[email-masked]>
Date: Mon, 19 Nov 2012 16:03:05 +0100

On Sun, Nov 18, 2012 at 9:16 PM, Shiyuan <[email-masked]> wrote:
> wrapper fails to build.  The swig interface in dolfinPYTHON_wrap.cxx are not
> correct generated and cannot be compiled.  After the following patch is

This is the same problem as reported in
https://bugs.launchpad.net/dolfin/+bug/799513.

One solution is to downgrade to SWIG 2.0.3. You can do that by letting
Dorsal build SWIG for you. In that case, make sure to rebuild
Trilinos, UFC and DOLFIN. You will need to remove the CMake cache,
that is dorsal_build_dir, for all these project before doing the
rebuild.

Another solution might be to upgrade Xcode, however, I'm not
absolutely sure that this will make it work with SWIG 2.0.8.

Johannes

---

From: Shiyuan <[email-masked]>
Date: Mon, 19 Nov 2012 23:50:28 -0600

> Actually, I was using Dorsal to build SWIG which is  2.0.3.

---

From: Johannes Ring <[email-masked]>
Date: Tue, 20 Nov 2012 15:21:57 +0100

> Actually, I was using Dorsal to build SWIG which is  2.0.3.

OK. So maybe the solution for you is to upgrade Xcode and use SWIG
2.0.8 from MacPorts.

Johannes

---

From: Shiyuan <[email-masked]>
Date: Tue, 20 Nov 2012 09:50:19 -0600

Which version of Xcode is tested on lion for the lion.platfrom in the
development version of dorsal?

---

From: Johannes Ring <[email-masked]>
Date: Wed, 21 Nov 2012 09:39:59 +0100

> development version of dorsal?

On the osx-10.7 buildbot we have Xcode 4.4.1 and this works with SWIG 2.0.8.

Johannes