Mercurial > fem-fenics-eugenio
changeset 118:ee608d1bffca
Index start from 1 following Octave convention.
author | gedeone-octave <marcovass89@hotmail.it> |
---|---|
date | Sun, 01 Sep 2013 22:47:21 +0200 |
parents | 70322135b25f |
children | 4b8b705e22a7 |
files | src/SubSpace.cc |
diffstat | 1 files changed, 22 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/SubSpace.cc Tue Aug 27 22:58:58 2013 +0200 +++ b/src/SubSpace.cc Sun Sep 01 22:47:21 2013 +0200 @@ -16,7 +16,17 @@ */ #include "functionspace.h" -DEFUN_DLD (SubSpace, args, , "initialize a fs from a mesh declared with fem_init_mesh") +DEFUN_DLD (SubSpace, args, , "-*- texinfo -*-\n\ +@deftypefn {Function File} {[@var{V1}]} = \ +SubSpace (@var{Space V}, @var{index}(Optional)) \n\ +The input arguments are\n\ +@itemize @bullet\n\ +@item @var{Space V} which is a mixed FunctionalSpace\n\ +@item @var{index} represents the subSpace which you want to extract; index\ +should be a positive integer.\n\ +@enditemize \n\ +The output @var{V0} is the SubSpace you need\n\ +@end deftypefn") { int nargin = args.length (); octave_value retval; @@ -41,8 +51,17 @@ if (! error_state) { const dolfin::FunctionSpace & V = fspo.get_fsp (); - boost::shared_ptr <const dolfin::FunctionSpace> g (new dolfin::SubSpace (V, idx)); - retval = new functionspace(g); + + if (idx < 1 || idx > V.dim ()) + error ("SubSpace: index out of bounds"); + + else + { + std::cout << "Extracting subspace..." << std::endl; + boost::shared_ptr <const dolfin::FunctionSpace> g (new dolfin::SubSpace (V, idx - 1)); + retval = new functionspace (g); + } + } } }