← Back to team overview

dolfin team mailing list archive

Re: Fwd: cbc.block with trilinos failing after recent dolfin updates

 

Yep, sorry, forgot the list. Here's a patch for cbc.block which removes the
workaround, can you see if it helps?

-j.


On 18 November 2011 13:43, Martin Sandve Alnæs <martinal@xxxxxxxxx> wrote:

> Forwarding Joachims reply.
>
>
> ---------- Forwarded message ----------
> From: Joachim Berdal Haga <jobh@xxxxxxxxx>
> Date: 18 November 2011 13:39
> Subject: Re: [Dolfin] cbc.block with trilinos failing after recent
> dolfin updates
> To: Martin Sandve Alnæs <martinal@xxxxxxxxx>
>
>
> > What's wrong here? Dolfin or cbc.block bug?
>
> I don't know, but the failing code in cbc.block is a workaround for
> things which have been fixed in DOLFIN for a while. "reference" is not
> supposed to be an existing attribute, it's a new attribute for storing
> a reference to the owning object to avoid it being deleted
> prematurely. Has something changed on the SWIG side?
> -j.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help   : https://help.launchpad.net/ListHelp
>
=== modified file 'block/__init__.py'
--- block/__init__.py	2011-08-09 11:00:44 +0000
+++ block/__init__.py	2011-11-18 12:47:18 +0000
@@ -65,28 +65,8 @@
     dolfin.GenericMatrix.create_vec = vec_pool(create_vec)
 
     # For the Trilinos stuff, it's much nicer if down_cast is a method on the
-    # object. Also do some fixup so that the down-casted object is not deleted
-    # just because the owning object goes out of scope, by creating a hidden
-    # backwards reference. (Python garbage collects circular references as long
-    # as custom __del__ methods are not in use.) NOTE this is fixed now in recent
-    # dolfin, may be simplified.
-    def la_object(self):
-        obj = self.la_object()
-        obj.reference = self
-        return obj
-    def down_cast(self):
-        obj = dolfin.down_cast(self)
-        if not hasattr(obj, 'la_object'):
-            cls = obj.__class__
-            if hasattr(cls, 'vec'):
-                cls.vec, cls.la_object = la_object, cls.vec
-            elif hasattr(cls, 'mat'):
-                cls.mat, cls.la_object = la_object, cls.mat
-            else:
-                raise RuntimeError, 'down_cast on unknown object'
-        return obj
-
-    dolfin.GenericMatrix.down_cast = down_cast
-    dolfin.GenericVector.down_cast = down_cast
+    # object.
+    dolfin.GenericMatrix.down_cast = dolfin.down_cast
+    dolfin.GenericVector.down_cast = dolfin.down_cast
 
 _init()


Follow ups

References