# HG changeset patch # User gedeone-octave # Date 1378758815 -7200 # Node ID ed03c46b70b207b844a5464664e1accad6e54dea # Parent e53cf3389e03126a8a1269c803b8ce56e9842948 Maint: move file which are not yet ready for the pkg to the obsolete location. diff -r e53cf3389e03 -r ed03c46b70b2 obsolete/fem_get_mesh.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/fem_get_mesh.cc Mon Sep 09 22:33:35 2013 +0200 @@ -0,0 +1,135 @@ +/* + 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 . +*/ + +#include "mesh.h" + +DEFUN_DLD (fem_get_mesh, args, ,"-*- texinfo -*-\n\ +@deftypefn {Function File} {[@var{mesh}]} = \ +fem_get_mesh (@var{fem_mesh}) \n\ +Return a (p, e, t) representation of @var{fem_mesh}\n\ +The @var{mesh_to_read} should be an object created with \ +fem_init_mesh().\n\ +The output @var{mesh} is a PDE-tool like structure\n\ +with matrix fields (p,e,t).\n\ +@seealso{fem_init_mesh}\n\ +@end deftypefn") +{ + int nargin = args.length (); + octave_value retval; + + if (nargin < 1 || nargin > 1) + print_usage (); + else + { + + if (! mesh_type_loaded) + { + mesh::register_type (); + mesh_type_loaded = true; + mlock (); + } + + if (args(0).type_id () == mesh::static_type_id ()) + { + const mesh & msh = static_cast (args(0).get_rep ()); + retval = octave_value (msh.get_pet ()); + } + else + error ("fem_get_mesh: the argument is not a mesh type"); + } + return retval; +} + +octave_scalar_map +mesh::get_pet () const +{ + const dolfin::Mesh & msh (*pmsh); + //p matrix + uint D = msh.topology ().dim (); + std::size_t num_v = msh.num_vertices (); + Matrix p (D, num_v); + std::copy (msh.coordinates ().begin (), + msh.coordinates ().end (), + p.fortran_vec ()); + + // e has 7 rows in 2d, 10 rows in 3d + msh.init (D - 1, D); + std::size_t num_f = msh.num_facets (); + dim_vector dims; + dims.resize (2); + dims(0) = D == 2 ? 7 : 10; + dims(1) = num_f; + Array e (dims, 0); + octave_idx_type *evec = e.fortran_vec (); + uint D2 = D * D; + octave_idx_type l = 0, m = 0; + + dolfin::MeshFunction facet_domains; + if (! msh.domains ().is_empty ()) + if (msh.domains ().num_marked (D-1) != 0) + facet_domains = * (msh.domains ().facet_domains ()); + + for (dolfin::FacetIterator f (msh); ! f.end (); ++f) + { + if ((*f).exterior () == true) + { + l = 0; + for (dolfin::VertexIterator v (*f); ! v.end (); ++v, ++l) + e.xelem (l, m) = (*v).index () + 1; + + if (! facet_domains.empty ()) + e.xelem (D2, m) = facet_domains[*f]; + + ++m; + } + } + + dims(1) = m; + e.resize (dims); + + for (octave_idx_type j = e.rows () - 2; + j < e.numel () - 2; j += e.rows ()) + evec[j] = 1; + + // t matrix + dims(0) = D + 2; + dims(1) = msh.num_cells (); + Array t (dims, 1); + std::vector my_cells = msh.cells (); + std::size_t n = 0; + + dolfin::MeshFunction cell_domains; + if (! msh.domains ().is_empty ()) + if (msh.domains ().num_marked (D) != 0) + cell_domains = * (msh.domains ().cell_domains ()); + + for (octave_idx_type j = 0; j < t.cols (); ++j) + { + for (octave_idx_type i = 0; i < D + 1; ++i, ++n) + t.xelem (i, j) += my_cells[n]; + + if (! cell_domains.empty ()) + t.xelem (D + 1, j) = cell_domains[j]; + } + + octave_scalar_map a; + a.setfield ("p", p); + a.setfield ("e", e); + a.setfield ("t", t); + return a; + +} diff -r e53cf3389e03 -r ed03c46b70b2 obsolete/fem_init_env.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/obsolete/fem_init_env.cc Mon Sep 09 22:33:35 2013 +0200 @@ -0,0 +1,56 @@ +/* + 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 . +*/ + + +#include "mesh.h" +#include "functionspace.h" +#include "boundarycondition.h" +#include "coefficient.h" +#include "function.h" + +DEFUN_DLD (fem_init_env, args, , "-*- texinfo -*-\n\ +@deftypefn {Function File} {[]} = \ +fem_init_env ( ) \n\ +Initialize the environment for fem-fenics\n\ +@end deftypefn") +{ + int nargin = args.length (); + octave_value retval; + + if (nargin < 0 || nargin > 0) + print_usage (); + else + { + mesh::register_type (); + mesh_type_loaded = true; + std::cout << "mesh_type_loaded" << std::endl; + functionspace::register_type (); + functionspace_type_loaded = true; + std::cout << "functionspace_type_loaded" << std::endl; + boundarycondition::register_type (); + boundarycondition_type_loaded = true; + std::cout << "boundarycondition_type_loaded" << std::endl; + coefficient::register_type (); + coefficient_type_loaded = true; + std::cout << "coefficient_type_loaded" << std::endl; + function::register_type (); + function_type_loaded = true; + std::cout << "function_type_loaded" << std::endl; + mlock (); + } + return retval; +} diff -r e53cf3389e03 -r ed03c46b70b2 src/fem_get_mesh.cc --- a/src/fem_get_mesh.cc Mon Sep 09 22:31:57 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -/* - 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 . -*/ - -#include "mesh.h" - -DEFUN_DLD (fem_get_mesh, args, ,"-*- texinfo -*-\n\ -@deftypefn {Function File} {[@var{mesh}]} = \ -fem_get_mesh (@var{fem_mesh}) \n\ -Return a (p, e, t) representation of @var{fem_mesh}\n\ -The @var{mesh_to_read} should be an object created with \ -fem_init_mesh().\n\ -The output @var{mesh} is a PDE-tool like structure\n\ -with matrix fields (p,e,t).\n\ -@seealso{fem_init_mesh}\n\ -@end deftypefn") -{ - int nargin = args.length (); - octave_value retval; - - if (nargin < 1 || nargin > 1) - print_usage (); - else - { - - if (! mesh_type_loaded) - { - mesh::register_type (); - mesh_type_loaded = true; - mlock (); - } - - if (args(0).type_id () == mesh::static_type_id ()) - { - const mesh & msh = static_cast (args(0).get_rep ()); - retval = octave_value (msh.get_pet ()); - } - else - error ("fem_get_mesh: the argument is not a mesh type"); - } - return retval; -} - -octave_scalar_map -mesh::get_pet () const -{ - const dolfin::Mesh & msh (*pmsh); - //p matrix - uint D = msh.topology ().dim (); - std::size_t num_v = msh.num_vertices (); - Matrix p (D, num_v); - std::copy (msh.coordinates ().begin (), - msh.coordinates ().end (), - p.fortran_vec ()); - - // e has 7 rows in 2d, 10 rows in 3d - msh.init (D - 1, D); - std::size_t num_f = msh.num_facets (); - dim_vector dims; - dims.resize (2); - dims(0) = D == 2 ? 7 : 10; - dims(1) = num_f; - Array e (dims, 0); - octave_idx_type *evec = e.fortran_vec (); - uint D2 = D * D; - octave_idx_type l = 0, m = 0; - - dolfin::MeshFunction facet_domains; - if (! msh.domains ().is_empty ()) - if (msh.domains ().num_marked (D-1) != 0) - facet_domains = * (msh.domains ().facet_domains ()); - - for (dolfin::FacetIterator f (msh); ! f.end (); ++f) - { - if ((*f).exterior () == true) - { - l = 0; - for (dolfin::VertexIterator v (*f); ! v.end (); ++v, ++l) - e.xelem (l, m) = (*v).index () + 1; - - if (! facet_domains.empty ()) - e.xelem (D2, m) = facet_domains[*f]; - - ++m; - } - } - - dims(1) = m; - e.resize (dims); - - for (octave_idx_type j = e.rows () - 2; - j < e.numel () - 2; j += e.rows ()) - evec[j] = 1; - - // t matrix - dims(0) = D + 2; - dims(1) = msh.num_cells (); - Array t (dims, 1); - std::vector my_cells = msh.cells (); - std::size_t n = 0; - - dolfin::MeshFunction cell_domains; - if (! msh.domains ().is_empty ()) - if (msh.domains ().num_marked (D) != 0) - cell_domains = * (msh.domains ().cell_domains ()); - - for (octave_idx_type j = 0; j < t.cols (); ++j) - { - for (octave_idx_type i = 0; i < D + 1; ++i, ++n) - t.xelem (i, j) += my_cells[n]; - - if (! cell_domains.empty ()) - t.xelem (D + 1, j) = cell_domains[j]; - } - - octave_scalar_map a; - a.setfield ("p", p); - a.setfield ("e", e); - a.setfield ("t", t); - return a; - -} diff -r e53cf3389e03 -r ed03c46b70b2 src/fem_init_env.cc --- a/src/fem_init_env.cc Mon Sep 09 22:31:57 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - 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 . -*/ - - -#include "mesh.h" -#include "functionspace.h" -#include "boundarycondition.h" -#include "coefficient.h" -#include "function.h" - -DEFUN_DLD (fem_init_env, args, , "-*- texinfo -*-\n\ -@deftypefn {Function File} {[]} = \ -fem_init_env ( ) \n\ -Initialize the environment for fem-fenics\n\ -@end deftypefn") -{ - int nargin = args.length (); - octave_value retval; - - if (nargin < 0 || nargin > 0) - print_usage (); - else - { - mesh::register_type (); - mesh_type_loaded = true; - std::cout << "mesh_type_loaded" << std::endl; - functionspace::register_type (); - functionspace_type_loaded = true; - std::cout << "functionspace_type_loaded" << std::endl; - boundarycondition::register_type (); - boundarycondition_type_loaded = true; - std::cout << "boundarycondition_type_loaded" << std::endl; - coefficient::register_type (); - coefficient_type_loaded = true; - std::cout << "coefficient_type_loaded" << std::endl; - function::register_type (); - function_type_loaded = true; - std::cout << "function_type_loaded" << std::endl; - mlock (); - } - return retval; -}