Mercurial > fem-fenics-eugenio
view src/MeshFunction.cc @ 261:f22588ae37af
Improve template meshfunction implementation
* inst/import_meshfunction_type.m: provide to the auxiliary functions a type name and
a valid identifier
* inst/private/generate_mf_*.m: add space before closing angle bracket to avoid parse
errors
author | Eugenio Gianniti <eugenio.gianniti@mail.polimi.it> |
---|---|
date | Thu, 07 Aug 2014 11:13:54 +0200 |
parents | 598c5e9e0a9e |
children | a61fc34334ca |
line wrap: on
line source
/* Copyright (C) 2014 Eugenio Gianniti <eugenio.gianniti@mail.polimi.it> 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 3 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 <dolfin.h> #include "mesh.h" #include "meshfunction.h" #include "dolfin_compat.h" DEFUN_DLD (MeshFunction, args, nargout, "-*- texinfo -*-\n\ @deftypefn {Function File} {[@var{meshfunc}]} = \ MeshFunction (@var{Mesh}, @var{filename})\n\ Initialize a meshfunction with the values contained in a XDMF file.\n\ The output @var{meshfunc} is an object which contains a representation of the \ meshfunction in @var{filename} which can be used to mark subdomains or \ facets where Dirichlet boundary conditions are to be applied.\n\ @seealso{DirichletBC, save}\n\ @end deftypefn") { int nargin = args.length (); octave_value retval; if (nargin < 2 || nargin > 2 || nargout > 1) print_usage (); else { if (! mesh_type_loaded) { mesh::register_type (); mesh_type_loaded = true; mlock (); } if (! meshfunction_type_loaded) { meshfunction::register_type (); meshfunction_type_loaded = true; mlock (); } if (args(0).type_id () == mesh::static_type_id () && args(1).is_string ()) { std::string filename = args(1).string_value (); mesh const & msh_arg = static_cast<mesh const &> (args(0).get_rep ()); if (!error_state) { SHARED_PTR <dolfin::Mesh const> const & pmsh = msh_arg.get_pmsh (); filename += ".xdmf"; try { retval = new meshfunction (pmsh, filename); } catch (std::runtime_error &) { error ("error reading file"); } } } else error ("invalid input arguments"); } return retval; }