← Back to team overview

dolfin team mailing list archive

Re: Extracting sub space with component tuple

 

On Monday January 16 2012 19:44:23 Marie E. Rognes wrote:
> Diff works, thanks!
> 
> While stumbling around with this, I'm encountering
> some more stuff:
> 
> For instance, with this:
> --
> from dolfin import *
> mesh = UnitSquare(2, 2)
> V = VectorFunctionSpace(mesh, "CG", 2)
> Q = FunctionSpace(mesh, "CG", 1)
> W = V*Q
> 
> W0 = W.sub(0)
> print W0.component()
> --
> 
> I get this:
> 
> <Swig Object of type 'std::vector< dolfin::uint > *' at
> 0x36641e0>swig/python detected a memory leak of type 'std::vector<
> dolfin::uint > *', no destructor found.
> 
> (1) Is the memory leak supposed to be there?

No.

> (2) Could we perhaps also have an out typemap for the std::vector?

Yes, will add out typemap macro for these guys.

Johan

> --
> Marie
> 
> On 01/16/2012 06:36 PM, Johan Hake wrote:
> > Apply this diff and it should work:
> > 
> > -----------------------------------------------
> > 
> > === modified file 'dolfin/swig/std_vector_typemaps.i'
> > --- dolfin/swig/std_vector_typemaps.i   2011-10-25 17:01:18 +0000
> > +++ dolfin/swig/std_vector_typemaps.i   2012-01-16 17:12:09 +0000
> > @@ -17,7 +17,7 @@
> > 
> >   // along with DOLFIN. If not, see<http://www.gnu.org/licenses/>.
> >   //
> >   // First added:  2009-08-31
> > 
> > -// Last changed: 2011-10-09
> > +// Last changed: 2012-01-16
> > 
> >   //=====================================================================
> >   ======== // In this file we declare what types that should be able to
> >   be passed using
> > 
> > a
> > @@ -464,8 +464,9 @@
> > 
> >   ARGOUT_TYPEMAP_STD_VECTOR_OF_PRIMITIVES(dolfin::uint, INT32, columns,
> > 
> > NPY_INT)
> > 
> >   ARGOUT_TYPEMAP_STD_VECTOR_OF_PRIMITIVES(double, DOUBLE, values,
> >   NPY_DOUBLE)
> > 
> > -IN_TYPEMAP_STD_VECTOR_OF_PRIMITIVES(double, DOUBLE, values, NPY_DOUBLE,
> > double, d)
> > -IN_TYPEMAP_STD_VECTOR_OF_PRIMITIVES(dolfin::uint, INT32, columns,
> > NPY_UINT, uint, I)
> > +IN_TYPEMAP_STD_VECTOR_OF_PRIMITIVES(double, DOUBLE, , NPY_DOUBLE,
> > double, d) +IN_TYPEMAP_STD_VECTOR_OF_PRIMITIVES(int, INT32, , NPY_INT,
> > int, i) +IN_TYPEMAP_STD_VECTOR_OF_PRIMITIVES(dolfin::uint, INT32, ,
> > NPY_UINT, uint, I)
> > 
> >   PY_SEQUENCE_OF_SCALARS_TO_VECTOR_OF_PRIMITIVES(dolfin::uint, INT32,
> > 
> > coloring_type, uint, -1)
> > 
> >   PY_SEQUENCE_OF_SCALARS_TO_VECTOR_OF_PRIMITIVES(dolfin::uint, INT32,
> > 
> > value_shape, uint, -1)
> > 
> > ---------------------------------------------------------
> > But the returned SubSpace is not a dolfin.FunctionSpace. Maybe you can
> > add that to the site-packages/dolfin/function/functionspace.py?
> > 
> > Johan
> > 
> > On Monday January 16 2012 17:47:36 Marie E. Rognes wrote:
> >> How do one extract a sub^n-space using a component tuple?
> >> I've tried various versions of this:
> >> 
> >> import numpy
> >> from dolfin import *
> >> mesh = UnitSquare(2, 2)
> >> V = VectorFunctionSpace(mesh, "CG", 2)
> >> Q = FunctionSpace(mesh, "CG", 1)
> >> W = V*Q
> >> component = numpy.array((0, 0))
> >> W.extract_sub_space(component)
> >> 
> >> but generally get this:
> >> 
> >> TypeError: in method 'FunctionSpace_extract_sub_space', argument 2 of
> >> type 'std::vector<  dolfin::uint>  const&'
> >> 
> >> 
> >> --
> >> Marie
> >> 
> >> _______________________________________________
> >> Mailing list: https://launchpad.net/~dolfin
> >> Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
> >> Unsubscribe : https://launchpad.net/~dolfin
> >> More help   : https://help.launchpad.net/ListHelp


Follow ups

References