Mercurial > fem-fenics-eugenio
changeset 106:6b4a77dc734f
New wrapper function for dolfin::SubSpace
* Subspace.cc: DLD function which allows to extract a subspace
* Makefile.in: comile also the new function
author | gedeone-octave <marcovass89@hotmail.it> |
---|---|
date | Tue, 20 Aug 2013 22:23:12 +0200 |
parents | c3cc050b4805 |
children | 0e83f8ce9083 |
files | src/Makefile.in src/SubSpace.cc |
diffstat | 2 files changed, 54 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Makefile.in Tue Aug 20 11:20:47 2013 +0200 +++ b/src/Makefile.in Tue Aug 20 22:23:12 2013 +0200 @@ -13,6 +13,7 @@ assemble_system.oct \ Plot_2d.oct \ Plot_3d.oct \ + SubSpace.oct \ LIBS += -ldolfin @@ -88,6 +89,9 @@ Plot_3d.oct: Plot_3d.cc Plot_3d.h $(MKOCTFILE) $(CPPFLAGS) -I. Plot_3d.cc $(LDFLAGS) $(LIBS) +SubSpace.oct: SubSpace.cc functionspace.h + $(MKOCTFILE) $(CPPFLAGS) -I. SubSpace.cc $(LDFLAGS) $(LIBS) + Plot_3d.h: Plot_3d.ufl $(FFC) -l dolfin Plot_3d.ufl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/SubSpace.cc Tue Aug 20 22:23:12 2013 +0200 @@ -0,0 +1,50 @@ +/* + Copyright (C) 2013 Marco Vassallo + + This program is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any later + version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + details. + + You should have received a copy of the GNU General Public License along with + this program; if not, see <http://www.gnu.org/licenses/>. +*/ +#include "functionspace.h" + +DEFUN_DLD (SubSpace, args, , "initialize a fs from a mesh declared with fem_init_mesh") +{ + int nargin = args.length (); + octave_value retval; + + if (nargin < 2 || nargin > 2) + print_usage (); + else + { + if (! functionspace_type_loaded) + { + functionspace::register_type (); + functionspace_type_loaded = true; + mlock (); + } + + if (args(0).type_id () == functionspace::static_type_id ()) + { + const functionspace & fspo + = static_cast<const functionspace&> (args(0).get_rep ()); + const octave_idx_type idx = args(1).int_value (); + + 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); + } + } + } + return retval; +}