annotate inst/private/generate_fs.m @ 268:61830a4f9ab9

Improve formatting
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Thu, 14 Aug 2014 12:26:55 +0200
parents 5e9b5bbdc56b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
152
1dbe146bff03 Update license to gpl v3
gedeone-octave <marcovass89@hotmail.it>
parents: 124
diff changeset
1 ## Copyright (C) 2013 Marco Vassallo <gedeone-octave@users.sourceforge.net>
1dbe146bff03 Update license to gpl v3
gedeone-octave <marcovass89@hotmail.it>
parents: 124
diff changeset
2 ##
124
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
3 ## This program is free software; you can redistribute it and/or modify it under
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
4 ## the terms of the GNU General Public License as published by the Free Software
152
1dbe146bff03 Update license to gpl v3
gedeone-octave <marcovass89@hotmail.it>
parents: 124
diff changeset
5 ## Foundation; either version 3 of the License, or (at your option) any later
124
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
6 ## version.
152
1dbe146bff03 Update license to gpl v3
gedeone-octave <marcovass89@hotmail.it>
parents: 124
diff changeset
7 ##
124
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
11 ## details.
152
1dbe146bff03 Update license to gpl v3
gedeone-octave <marcovass89@hotmail.it>
parents: 124
diff changeset
12 ##
124
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
13 ## You should have received a copy of the GNU General Public License along with
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
15
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
16
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
17 ## -*- texinfo -*-
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
18 ## function for internal usage only
2191111a1cad Maint: add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 82
diff changeset
19 ## @end deftypefn
268
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 253
diff changeset
20
68
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
21 function output = generate_fs (ufl_name)
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
22
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
23 STRING ="\n\
154
262c9d7bda1c Call the header file from the /include directories
gedeone-octave <marcovass89@hotmail.it>
parents: 153
diff changeset
24 #include <fem-fenics/functionspace.h>\n\
262c9d7bda1c Call the header file from the /include directories
gedeone-octave <marcovass89@hotmail.it>
parents: 153
diff changeset
25 #include <fem-fenics/mesh.h>\n\
68
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
26 #include ""@@UFL_NAME@@.h""\n\
253
5e9b5bbdc56b Support both DOLFIN 1.3.0 and 1.4.0
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 155
diff changeset
27 #include <fem-fenics/dolfin_compat.h>\n\
68
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
28 \n\
268
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 253
diff changeset
29 DEFUN_DLD (@@UFL_NAME@@_FunctionSpace, args, ,\
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 253
diff changeset
30 ""initialize a fs from a mesh declared with fem_init_mesh"")\n\
68
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
31 {\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
32 int nargin = args.length ();\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
33 octave_value retval;\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
34 \n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
35 if (nargin < 1 || nargin > 1)\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
36 print_usage ();\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
37 else\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
38 {\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
39 \n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
40 if (! mesh_type_loaded)\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
41 {\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
42 mesh::register_type ();\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
43 mesh_type_loaded = true;\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
44 mlock ();\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
45 }\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
46 \n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
47 if (args(0).type_id () == mesh::static_type_id ())\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
48 {\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
49 const mesh & msho = static_cast<const mesh&> (args(0).get_rep ());\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
50 const dolfin::Mesh & mshd = msho.get_msh ();\n\
268
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 253
diff changeset
51 SHARED_PTR <const dolfin::FunctionSpace>\
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 253
diff changeset
52 g (new @@UFL_NAME@@::FunctionSpace (mshd));\n\
68
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
53 \n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
54 if (! functionspace_type_loaded)\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
55 {\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
56 functionspace::register_type ();\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
57 functionspace_type_loaded = true;\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
58 mlock ();\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
59 }\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
60 \n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
61 retval = new functionspace(g);\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
62 }\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
63 }\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
64 return retval;\n\
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
65 }";
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
66
268
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 253
diff changeset
67 STRING = strrep (STRING, "@@UFL_NAME@@", ufl_name);
68
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
68
268
61830a4f9ab9 Improve formatting
Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
parents: 253
diff changeset
69 fid = fopen (sprintf ("%s_FunctionSpace.cc", ufl_name), "w");
68
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
70 if (fid >= 0)
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
71 fputs (fid, STRING);
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
72 output = fclose (fid);
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
73 else
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
74 error ("cannot open file");
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
75 output = 1;
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
76 endif
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
77
4ef8dbafcdfc New octave script for creation of function on the fly
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
78 endfunction