Mercurial > fem-fenics-eugenio
changeset 22:17bad8351f4d
New class derived from dolfin::Expression
author | gedeone-octave <marco.vassallo@outlook.com> |
---|---|
date | Fri, 12 Jul 2013 13:58:58 +0200 |
parents | 676a42510364 |
children | aaf7644c7f89 |
files | src/expression.h |
diffstat | 1 files changed, 53 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/expression.h Fri Jul 12 13:58:58 2013 +0200 @@ -0,0 +1,53 @@ +/* + 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/>. +*/ + +#ifndef _EXPRESSION_OCTAVE_ +#define _EXPRESSION_OCTAVE_ + +#include <dolfin.h> +#include <octave/oct.h> +#include <octave/oct-map.h> +#include <octave/ov-fcn-handle.h> +#include <octave/ov-fcn.h> +#include <octave/parse.h> +#include <octave/octave.h> + +class expression : public dolfin::Expression +{ + + public: + expression (octave_fcn_handle & _f) : + dolfin::Expression (), f (new octave_fcn_handle (_f)) {} + + ~expression (void) { delete f; } + + void eval (dolfin::Array<double>& values, const dolfin::Array<double>& xy) const + { + double x = xy[0]; + double y = xy[1]; + octave_value_list b; + b.resize (2); + b(0) = x; + b(1) = y; + octave_value_list res = feval (f->function_value (), b); + values[0] = res(0).double_value (); + } + + octave_fcn_handle * f; +}; + +#endif