dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #13177
Re: Setting names of functions as written to file
On Tuesday 21 April 2009 19:35:10 Martin Sandve Alnæs wrote:
> How can I set the name of a Function as it appears in a .pvd file?
> When looking at two fields simultaneously in paraview, they need
> separate names to have separate color ranges.
>
>
> In Python I get this when trying rename:
>
>
> In [16]: f.rename?
> Type: instancemethod
> Base Class: <type 'instancemethod'>
> String Form: <bound method DiscreteFunction.Variable_rename of
> Function(FiniteElement('Lagrange', Cell('triangle', 1), 1), 0)>
> Namespace: Interactive
> Docstring:
> Variable_rename(Variable self, string name, string label)
>
>
> In [17]: f.rename("f", "m")
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
>
> /home/martinal/<ipython console> in <module>()
>
> TypeError: in method 'Variable_rename', argument 1 of type
> 'dolfin::Variable *'
I looked into this, and it turns out that it is a tricky one.
It is caused by Variable not beeing declared as a shared_ptr class in the swig
interface. Doing this would fix this but then we have to declare all other
sub classes of Variable as shared_ptr stored. This is probably not what we
want as there are quite a large number of classes inheriting Variable.
A hack that would fix this, at least the Function class in PyDOLFIN, is to
add:
cpp.Variable.__init__(self)
in the constructed __init__ function in function.py. This will initialise the
correct proxy type for self. Not sure if this has any side effects though.
Johan
>
> No rush, I can of course just change the name in the .pvd file with
> sed for now...
>
> Martin
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev
References