view src/fem_save.cc @ 48:c73bca616ca7

Add texinfo description for the DLD functions
author gedeone-octave <marco.vassallo@outlook.com>
date Mon, 22 Jul 2013 15:13:30 +0200
parents fe29ca22b1ec
children fcfecdd3a9b5
line wrap: on
line source

#include <dolfin.h>
#include "function.h"

DEFUN_DLD (fem_save, args, , "-*- texinfo -*-\n\
@deftypefn {Function File} \
fem_save (@var{Function}, @var{Name}\n\
The input parameters are\n\
@itemize @bullet \n\
@item @var{Function} is the parameter of type function that you want to save\n\
@item @var{Name} is a string for the output name\n\
The output is a file in format .pvd\n\
@seealso{fem_plot, fem_func}\n\
@end deftypefn")
{

  int nargin = args.length ();
  octave_value retval;
  
  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 & uo =
            static_cast<const function&> (args(0).get_rep ());
          std::string str = args(1).string_value ();

          if (!error_state)
            {
              const boost::shared_ptr<const dolfin::Function> & u = uo.get_pfun ();
              str += ".pvd";
              dolfin::File file (str);
              file << (*u);
              retval = 0;
            }
        }
    }
  return retval;
}