Mercurial > fem-fenics-eugenio
annotate src/save.cc @ 128:d3c29e38e5d2
New naming convention adopted and Polymorphism for plot and save.
* plot_mesh.cc: obtained merging Plot_2d.cc Plot_3d.cc fem_plot.cc
* plot_func.cc: obtined from fem_plot.cc
* fem_save.cc moved to sace.cc
author | gedeone-octave <marcovass89@hotmail.it> |
---|---|
date | Thu, 05 Sep 2013 20:49:36 +0200 |
parents | src/fem_save.cc@70322135b25f |
children | e53cf3389e03 |
rev | line source |
---|---|
117
70322135b25f
Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents:
50
diff
changeset
|
1 /* |
70322135b25f
Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents:
50
diff
changeset
|
2 Copyright (C) 2013 Marco Vassallo |
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 |
70322135b25f
Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents:
50
diff
changeset
|
6 Foundation; either version 2 of the License, or (at your option) any later |
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/>. |
70322135b25f
Maint: Add copyright notice
gedeone-octave <marcovass89@hotmail.it>
parents:
50
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} \ |
c73bca616ca7
Add texinfo description for the DLD functions
gedeone-octave <marco.vassallo@outlook.com>
parents:
47
diff
changeset
|
21 fem_save (@var{Function}, @var{Name}\n\ |
c73bca616ca7
Add texinfo description for the DLD functions
gedeone-octave <marco.vassallo@outlook.com>
parents:
47
diff
changeset
|
22 The input parameters are\n\ |
c73bca616ca7
Add texinfo description for the DLD functions
gedeone-octave <marco.vassallo@outlook.com>
parents:
47
diff
changeset
|
23 @itemize @bullet \n\ |
c73bca616ca7
Add texinfo description for the DLD functions
gedeone-octave <marco.vassallo@outlook.com>
parents:
47
diff
changeset
|
24 @item @var{Function} is the parameter of type function that you want to save\n\ |
c73bca616ca7
Add texinfo description for the DLD functions
gedeone-octave <marco.vassallo@outlook.com>
parents:
47
diff
changeset
|
25 @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
|
26 @end itemize\n\ |
48
c73bca616ca7
Add texinfo description for the DLD functions
gedeone-octave <marco.vassallo@outlook.com>
parents:
47
diff
changeset
|
27 The output is a file in format .pvd\n\ |
c73bca616ca7
Add texinfo description for the DLD functions
gedeone-octave <marco.vassallo@outlook.com>
parents:
47
diff
changeset
|
28 @seealso{fem_plot, fem_func}\n\ |
c73bca616ca7
Add texinfo description for the DLD functions
gedeone-octave <marco.vassallo@outlook.com>
parents:
47
diff
changeset
|
29 @end deftypefn") |
47
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
30 { |
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 int nargin = args.length (); |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
33 octave_value retval; |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
34 |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
35 if (nargin < 2 || nargin > 2) |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
36 print_usage (); |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
37 else |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
38 { |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
39 if (! function_type_loaded) |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
40 { |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
41 function::register_type (); |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
42 function_type_loaded = true; |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
43 mlock (); |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
44 } |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
45 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
|
46 { |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
47 const function & uo = |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
48 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
|
49 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
|
50 |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
51 if (!error_state) |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
52 { |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
53 const boost::shared_ptr<const dolfin::Function> & u = uo.get_pfun (); |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
54 str += ".pvd"; |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
55 dolfin::File file (str); |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
56 file << (*u); |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
57 retval = 0; |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
58 } |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
59 } |
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 return retval; |
fe29ca22b1ec
Functions which plot and save a function object.
gedeone-octave <marco.vassallo@outlook.com>
parents:
diff
changeset
|
62 } |