changeset 10:277b60c6618a

New function: create a mesh * fem_init_mesh: create a mesh for the fem-fenics pkg from a (p, e, t) mesh or from an external dolfin .xml mesh
author gedeone-octave <marco.vassallo@outlook.com>
date Fri, 05 Jul 2013 18:29:03 +0200
parents 3bf1ca6397a2
children 6f11638bfbac
files src/fem_init_mesh.cc
diffstat 1 files changed, 62 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fem_init_mesh.cc	Fri Jul 05 18:29:03 2013 +0200
@@ -0,0 +1,62 @@
+/*
+ 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/>.
+*/
+
+#include "mesh.h"
+
+
+DEFUN_DLD (fem_init_mesh, args, , "initialize a mesh from (p, e, t) or file")
+{
+  int nargin = args.length ();
+  octave_value retval = 0;
+
+  if (nargin < 1 || nargin > 1)
+    print_usage ();
+  else
+    {
+      //octave_scalar_map a = args(1).scalar_map_value ();
+      //bool mesh_tl = a.contents ("mesh_tl").bool_value ();
+      bool mesh_tl = true;
+
+      if (!error_state)
+        {
+          if (mesh_tl == false)
+            error("Mesh type not loaded, you should proably use fem_init()");
+          else
+            {
+              if (args(0).is_string () == true)
+                {
+                  std::string filename = args(0).string_value();
+                  retval = new mesh (filename);
+                }
+
+               else
+                 {
+                   octave_scalar_map a = args(0).scalar_map_value ();
+                   Array<double> p = a.contents ("p").matrix_value ();
+                   Array<octave_idx_type> t = a.contents ("t").matrix_value ();
+                   Array<octave_idx_type> e = a.contents ("e").matrix_value ();
+
+                   if (! error_state)
+                     {
+                       retval = new mesh (p, e, t);
+                     }
+                 }
+             }
+        }
+    }
+  return retval;
+}