Mercurial > fem-fenics-eugenio
comparison inst/private/generate_fs.m @ 155:22de20d78e27
Reduced use of post_install.m
author | gedeone-octave <marcovass89@hotmail.it> |
---|---|
date | Thu, 12 Sep 2013 14:11:38 +0200 |
parents | inst/generate_fs.m@262c9d7bda1c |
children | 5e9b5bbdc56b |
comparison
equal
deleted
inserted
replaced
154:262c9d7bda1c | 155:22de20d78e27 |
---|---|
1 ## Copyright (C) 2013 Marco Vassallo <gedeone-octave@users.sourceforge.net> | |
2 ## | |
3 ## This program is free software; you can redistribute it and/or modify it under | |
4 ## the terms of the GNU General Public License as published by the Free Software | |
5 ## Foundation; either version 3 of the License, or (at your option) any later | |
6 ## version. | |
7 ## | |
8 ## This program is distributed in the hope that it will be useful, but WITHOUT | |
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
11 ## details. | |
12 ## | |
13 ## You should have received a copy of the GNU General Public License along with | |
14 ## this program; if not, see <http://www.gnu.org/licenses/>. | |
15 | |
16 | |
17 ## -*- texinfo -*- | |
18 ## function for internal usage only | |
19 ## @end deftypefn | |
20 function output = generate_fs (ufl_name) | |
21 | |
22 STRING ="\n\ | |
23 #include <fem-fenics/functionspace.h>\n\ | |
24 #include <fem-fenics/mesh.h>\n\ | |
25 #include ""@@UFL_NAME@@.h""\n\ | |
26 \n\ | |
27 DEFUN_DLD (@@UFL_NAME@@_FunctionSpace, args, , ""initialize a fs from a mesh declared with fem_init_mesh"")\n\ | |
28 {\n\ | |
29 int nargin = args.length ();\n\ | |
30 octave_value retval;\n\ | |
31 \n\ | |
32 if (nargin < 1 || nargin > 1)\n\ | |
33 print_usage ();\n\ | |
34 else\n\ | |
35 {\n\ | |
36 \n\ | |
37 if (! mesh_type_loaded)\n\ | |
38 {\n\ | |
39 mesh::register_type ();\n\ | |
40 mesh_type_loaded = true;\n\ | |
41 mlock ();\n\ | |
42 }\n\ | |
43 \n\ | |
44 if (args(0).type_id () == mesh::static_type_id ())\n\ | |
45 {\n\ | |
46 const mesh & msho = static_cast<const mesh&> (args(0).get_rep ());\n\ | |
47 const dolfin::Mesh & mshd = msho.get_msh ();\n\ | |
48 boost::shared_ptr <const dolfin::FunctionSpace> g (new @@UFL_NAME@@::FunctionSpace (mshd));\n\ | |
49 \n\ | |
50 if (! functionspace_type_loaded)\n\ | |
51 {\n\ | |
52 functionspace::register_type ();\n\ | |
53 functionspace_type_loaded = true;\n\ | |
54 mlock ();\n\ | |
55 }\n\ | |
56 \n\ | |
57 retval = new functionspace(g);\n\ | |
58 }\n\ | |
59 }\n\ | |
60 return retval;\n\ | |
61 }"; | |
62 | |
63 STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name); | |
64 | |
65 fid = fopen (sprintf ("%s_FunctionSpace.cc", ufl_name), 'w'); | |
66 if (fid >= 0) | |
67 fputs (fid, STRING); | |
68 output = fclose (fid); | |
69 else | |
70 error ("cannot open file"); | |
71 output = 1; | |
72 endif | |
73 | |
74 endfunction |