← Back to team overview

dolfin team mailing list archive

Re: Extracting sub space with component tuple

 

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