Mercurial > fem-fenics-eugenio
changeset 111:011ad0c352f7
New function for the evaluation of an object of type function in a given point
* fem_eval: wrapper function for dolfin::eval. The name has to change in future.
author | gedeone-octave <marcovass89@hotmail.it> |
---|---|
date | Sat, 24 Aug 2013 15:27:36 +0200 |
parents | 75780f7dc9f4 |
children | c15e5434a512 |
files | src/Makefile.in src/fem_eval.cc |
diffstat | 2 files changed, 51 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Makefile.in Fri Aug 23 08:26:26 2013 +0200 +++ b/src/Makefile.in Sat Aug 24 15:27:36 2013 +0200 @@ -14,6 +14,7 @@ Plot_2d.oct \ Plot_3d.oct \ SubSpace.oct \ + fem_eval.oct \ LIBS += -ldolfin @@ -92,6 +93,9 @@ SubSpace.oct: SubSpace.cc functionspace.h $(MKOCTFILE) $(CPPFLAGS) -I. SubSpace.cc $(LDFLAGS) $(LIBS) +fem_eval.oct: fem_eval.cc function.h + $(MKOCTFILE) $(CPPFLAGS) -I. fem_eval.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/fem_eval.cc Sat Aug 24 15:27:36 2013 +0200 @@ -0,0 +1,47 @@ +#include "function.h" + +DEFUN_DLD (fem_eval, args, , "-*- texinfo -*-\n\ +@deftypefn {Function File} {[@var{value}]} = \ +fem_eval (@var{function_name}, @var{Coordinate})\n\ +@end deftypefn") +{ + + int nargin = args.length (); + octave_value retval=0; + + if (nargin < 2 || nargin > 2) + print_usage (); + else + { + if (! function_type_loaded) + { + function::register_type (); + function_type_loaded = true; + mlock (); + } + + if (args(0).type_id () == function::static_type_id ()) + { + const function & fspo = + static_cast<const function&> (args(0).get_rep ()); + Array<double> point= args(1).array_value (); + + if (!error_state) + { + const boost::shared_ptr<const dolfin::Function> & f = fspo.get_pfun (); + dim_vector dims; + dims.resize (2); + dims(0) = 1; + dims(1) = f->value_dimension (0); + Array<double> res (dims); + dolfin::Array<double> x(point.length (), point.fortran_vec ()); + dolfin::Array<double> values(res.length (), res.fortran_vec ()); + + f->eval (values, x); + + retval = octave_value (res); + } + } + } + return retval; +}