changeset 14:f329fc94b1a2

Wrapper Class for dolfin::FunctionSpace
author gedeone-octave <marco.vassallo@outlook.com>
date Mon, 08 Jul 2013 21:35:44 +0200
parents 36882e185f02
children b760ffba8f63
files src/functionspace.h
diffstat 1 files changed, 77 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/functionspace.h	Mon Jul 08 21:35:44 2013 +0200
@@ -0,0 +1,77 @@
+/*
+ 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 _FUNCTIONSPACE_OCTAVE_
+#define _FUNCTIONSPACE_OCTAVE_
+
+#include <dolfin.h>
+#include <octave/oct.h>
+
+class functionspace : public dolfin::FunctionSpace, public octave_base_value
+{
+
+ public:
+
+  // Constructors
+
+  /*
+  Default constructor: it is necessary because it is requested by
+  DEFINE_OCTAVE_ALLOCATOR and DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA .
+  dolfin::FunctionSpace doesn't provide a default constructor, and thus
+  we add as private members __msh, __elm, __dfm, which are needed only for
+  creating our own default constructor functionspace()
+  for dolfin::FunctionSpace() we use the protected constructor of the class
+  which needs only a dolfin::Mesh
+  */
+
+  functionspace () :
+  dolfin::FunctionSpace (__msh), octave_base_value (), fsp (__msh, __elm, __dfm)
+  {}
+
+
+  functionspace (const dolfin::FunctionSpace & _fsp)
+  : octave_base_value (), fsp (_fsp), dolfin::FunctionSpace (_fsp) {}
+
+  //a method for printing
+  void print (std::ostream& os, bool pr_as_read_syntax = false) const
+  { os << "fsp : " << fsp.str(true) << std::endl; }
+
+  //destructor
+  ~functionspace(void) { };
+
+  bool is_defined (void) const { return true; }
+
+  //get the information from the private member
+  const dolfin::FunctionSpace & get_fsp (void) const
+  { return fsp; }
+
+  // set the value of the private member
+  void set_fsp (dolfin::FunctionSpace & _fsp)
+  { fsp = _fsp; }
+
+ private:
+
+  dolfin::FunctionSpace fsp;
+  boost::shared_ptr<const dolfin::Mesh> __msh;
+  boost::shared_ptr<dolfin::FiniteElement> __elm;
+  boost::shared_ptr<dolfin::GenericDofMap> __dfm;
+
+  DECLARE_OCTAVE_ALLOCATOR;
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA;
+
+};
+#endif