Mercurial > fem-fenics-eugenio
view src/fem_func.cc @ 46:a64e195d0611
Wrapper class for dolfin::Function
* function.h: definition of the new clas function which derives from
octave_base_value
* fem_func.cc: take as input a functionspace and a vector and creates
an object of type function
* fem_init_env: register also the class function
author | gedeone-octave <marco.vassallo@outlook.com> |
---|---|
date | Mon, 22 Jul 2013 14:56:51 +0200 |
parents | |
children | c73bca616ca7 |
line wrap: on
line source
#include <dolfin.h> #include "functionspace.h" #include "function.h" DEFUN_DLD (fem_func, args, , "fem_func: functionspace V, vector u") { int nargin = args.length (); octave_value retval=0; 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 ()); Array <double> myu = args(1).array_value (); if (!error_state) { const boost::shared_ptr<const dolfin::FunctionSpace> & V = fspo.get_pfsp (); dolfin::Vector du(myu.length ()); for (std::size_t i = 0; i < myu.length (); ++i) du.setitem (i, myu(i)); boost::shared_ptr<dolfin::Vector> uu (new dolfin::Vector(du)); boost::shared_ptr <const dolfin::Function> u (new dolfin::Function(V, uu)); if (! function_type_loaded) { function::register_type (); function_type_loaded = true; mlock (); } retval = new function (u); } } } return retval; }