annotate src/save.cc @ 238:b96f6b12f8ca

Move ufl to m-file in Poisson example
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Tue, 24 Jun 2014 16:43:13 +0200
parents 66071811eef8
children 5e9b5bbdc56b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
117
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
1 /*
151
5fe2a157f4eb Update GPL to v3
gedeone-octave <marcovass89@hotmail.it>
parents: 141
diff changeset
2 Copyright (C) 2013 Marco Vassallo <gedeone-octave@users.sourceforge.net>
117
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
3
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
4 This program is free software; you can redistribute it and/or modify it under
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
5 the terms of the GNU General Public License as published by the Free Software
151
5fe2a157f4eb Update GPL to v3
gedeone-octave <marcovass89@hotmail.it>
parents: 141
diff changeset
6 Foundation; either version 3 of the License, or (at your option) any later
117
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
7 version.
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
8
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
9 This program is distributed in the hope that it will be useful, but WITHOUT
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
12 details.
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
13
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
14 You should have received a copy of the GNU General Public License along with
70322135b25f Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents: 50
diff changeset
15 this program; if not, see <http://www.gnu.org/licenses/>.
155
22de20d78e27 Reduced use of post_install.m
gedeone-octave <marcovass89@hotmail.it>
parents: 151
diff changeset
16 */
47
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
17 #include "function.h"
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
18
128
d3c29e38e5d2 New naming convention adopted and Polymorphism for plot and save.
gedeone-octave <marcovass89@hotmail.it>
parents: 117
diff changeset
19 DEFUN_DLD (save, args, , "-*- texinfo -*-\n\
48
c73bca616ca7 Add texinfo description for the DLD functions
gedeone-octave <marco.vassallo@outlook.com>
parents: 47
diff changeset
20 @deftypefn {Function File} \
141
e53cf3389e03 Maint: improve documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 128
diff changeset
21 fem_save (@var{Function}, @var{Name})\n\
184
66071811eef8 Improve the documentation for the pkg releae.
gedeone-octave <marcovass89@hotmail.it>
parents: 173
diff changeset
22 Save a function in vtu format.\n\
48
c73bca616ca7 Add texinfo description for the DLD functions
gedeone-octave <marco.vassallo@outlook.com>
parents: 47
diff changeset
23 The input parameters are\n\
c73bca616ca7 Add texinfo description for the DLD functions
gedeone-octave <marco.vassallo@outlook.com>
parents: 47
diff changeset
24 @itemize @bullet \n\
141
e53cf3389e03 Maint: improve documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 128
diff changeset
25 @item @var{Function} is the function that you want to save\n\
48
c73bca616ca7 Add texinfo description for the DLD functions
gedeone-octave <marco.vassallo@outlook.com>
parents: 47
diff changeset
26 @item @var{Name} is a string for the output name\n\
50
fcfecdd3a9b5 Maint: improve the documentation
gedeone-octave <marco.vassallo@outlook.com>
parents: 48
diff changeset
27 @end itemize\n\
141
e53cf3389e03 Maint: improve documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 128
diff changeset
28 The output is a file in format .vtu\n\
e53cf3389e03 Maint: improve documentation.
gedeone-octave <marcovass89@hotmail.it>
parents: 128
diff changeset
29 @seealso{plot, Function}\n\
48
c73bca616ca7 Add texinfo description for the DLD functions
gedeone-octave <marco.vassallo@outlook.com>
parents: 47
diff changeset
30 @end deftypefn")
47
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
31 {
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
32
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
33 int nargin = args.length ();
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
34 octave_value retval;
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
35
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
36 if (nargin < 2 || nargin > 2)
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
37 print_usage ();
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
38 else
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
39 {
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
40 if (! function_type_loaded)
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
41 {
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
42 function::register_type ();
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
43 function_type_loaded = true;
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
44 mlock ();
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
45 }
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
46 if (args(0).type_id () == function::static_type_id ())
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
47 {
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
48 const function & uo =
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
49 static_cast<const function&> (args(0).get_rep ());
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
50 std::string str = args(1).string_value ();
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
51
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
52 if (!error_state)
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
53 {
173
9e944b0d0fc8 Some Formatting improvements (?)
gedeone-octave <marcovass89@hotmail.it>
parents: 155
diff changeset
54 const boost::shared_ptr<const dolfin::Function>
9e944b0d0fc8 Some Formatting improvements (?)
gedeone-octave <marcovass89@hotmail.it>
parents: 155
diff changeset
55 & u = uo.get_pfun ();
47
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
56 str += ".pvd";
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
57 dolfin::File file (str);
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
58 file << (*u);
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
59 retval = 0;
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
60 }
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
61 }
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
62 }
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
63 return retval;
fe29ca22b1ec Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff changeset
64 }