Mercurial > fem-fenics-eugenio
annotate src/fem_init_mesh.cc @ 16:448e01d4411f
Introduce the use of boost::shared_ptr for class members
* mesh.h: private memeber is now boost::shared_ptr<const dolfin::Mesh> instead
of dolfin::Mesh
The class now derives only from octave_base_value and no more from
dolfin::Mesh
* mesh.cc: the constructor now takes care of the boost::shared_ptr < >
* fem_get_mesh.cc, fem_init_mesh: now use boost::shared_ptr < >
author | gedeone-octave <marco.vassallo@outlook.com> |
---|---|
date | Thu, 11 Jul 2013 18:00:26 +0200 |
parents | b7c74c0bdabd |
children | fca8c3d75036 |
rev | line source |
---|---|
10
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
1 /* |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
2 Copyright (C) 2013 Marco Vassallo |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
3 |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
4 This program is free software; you can redistribute it and/or modify it under |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
5 the terms of the GNU General Public License as published by the Free Software |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
6 Foundation; either version 2 of the License, or (at your option) any later |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
7 version. |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
8 |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, but WITHOUT |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
12 details. |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
13 |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License along with |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
15 this program; if not, see <http://www.gnu.org/licenses/>. |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
16 */ |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
17 |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
18 #include "mesh.h" |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
19 |
16
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
20 DEFUN_DLD (fem_init_mesh, args, ,"-*- texinfo -*-\n\ |
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
21 @deftypefn {Function File} {[@var{mesh_out}]} = \ |
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
22 fem_get_mesh (@var{mesh_in}) \n\ |
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
23 The @var{mesh_in} should be either\n\ |
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
24 @itemize @bullet \n\ |
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
25 @item a string containing the name of the file where the mesh is stored\ |
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
26 (compatible formats are the ones which are compatible with Fenics\n\ |
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
27 @item a a PDE-tool like structure with matrix fields (p,e,t)\n\ |
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
28 @end itemize\n\ |
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
29 fem_init_mesh().\n\ |
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
30 The output @var{mesh_out} is a representation of the\n\ |
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
31 @var{mesh_in} which is compatible with fem-fenics\n\ |
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
32 @seealso{fem_get_mesh}\n\ |
448e01d4411f
Introduce the use of boost::shared_ptr for class members
gedeone-octave <marco.vassallo@outlook.com>
parents:
12
diff
changeset
|
33 @end deftypefn") |
10
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
34 { |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
35 int nargin = args.length (); |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
36 octave_value retval = 0; |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
37 |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
38 if (nargin < 1 || nargin > 1) |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
39 print_usage (); |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
40 else |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
41 { |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
42 if (!error_state) |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
43 { |
12
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
44 if (args(0).is_string () == true) |
10
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
45 { |
12
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
46 std::string filename = args(0).string_value (); |
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
47 //if the filename is not valid, dolfin takes care of it |
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
48 retval = new mesh (filename); |
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
49 } |
10
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
50 |
12
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
51 else |
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
52 { |
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
53 octave_scalar_map a = args(0).scalar_map_value (); |
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
54 Array<double> p = a.contents ("p").matrix_value (); |
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
55 Array<octave_idx_type> t = a.contents ("t").matrix_value (); |
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
56 Array<octave_idx_type> e = a.contents ("e").matrix_value (); |
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
57 |
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
58 if (! error_state) |
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
59 { |
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
60 retval = new mesh (p, e, t); |
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
61 } |
10
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
62 else |
12
b7c74c0bdabd
New functions which get a (p,e,t) matrix from a mesh object
gedeone-octave <marco.vassallo@outlook.com>
parents:
10
diff
changeset
|
63 error ("fem_init_mesh: the argument you provide is invalid"); |
10
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
64 } |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
65 } |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
66 } |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
67 return retval; |
277b60c6618a
New function: create a mesh
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
68 } |