8280
|
1 ## Copyright (C) 2011 Carlo de Falco |
|
2 ## |
|
3 ## This file is part of: |
|
4 ## FPL - Fem PLotting package for octave |
|
5 ## |
|
6 ## FPL is free software; you can redistribute it and/or modify |
|
7 ## it under the terms of the GNU General Public License as published by |
10655
|
8 ## the Free Software Foundation; either version 3 of the License, or |
8280
|
9 ## (at your option) any later version. |
|
10 ## |
|
11 ## FPL is distributed in the hope that it will be useful, |
|
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 ## GNU General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
|
17 ## along with FPL; If not, see <http://www.gnu.org/licenses/>. |
|
18 ## |
|
19 ## author: Carlo de Falco <cdf _AT_ users.sourceforge.net> |
|
20 |
|
21 ## -*- texinfo -*- |
|
22 ## @deftypefn {Function File} {} fpl_vtk_assemble_series (@var{collection}, @var{basenanme}, @var{format}, @var{idx}, @var{time}) |
|
23 ## |
|
24 ## Assemble a ParaView collection file (pvd) from a set of files representing data at different time-steps. |
|
25 ## |
|
26 ## @var{collection} is a string containing the base-name of the pvd file |
|
27 ## where the data will be saved. |
|
28 ## |
|
29 ## @var{basename}, @var{format}, @var{idx} are two strings and a set of integers, the name of the i-th file in the collection |
|
30 ## will be computed as @code{sprintf ([basename, format, ".vtu"], idx(i))}. |
|
31 ## |
|
32 ## @var{time} is the set of time-steps to which data correspond |
|
33 ## |
|
34 ## @seealso{fpl_vtk_write_field, fpl_dx_write_series} |
|
35 ## |
|
36 ## @end deftypefn |
|
37 |
|
38 |
12671
|
39 function fpl_vtk_assemble_series (collection, basename, format, idx, time) |
8280
|
40 |
12671
|
41 ntpoints = numel (time); |
8280
|
42 fid = fopen (strcat (collection, ".pvd"), "w"); |
|
43 |
|
44 ## Header |
|
45 fprintf (fid, "<?xml version=""1.0""?>\n"); |
|
46 fprintf (fid, "<VTKFile type=""Collection"" "); |
|
47 fprintf (fid, " version=""0.1"">\n"); |
|
48 fprintf (fid, "<Collection>\n"); |
|
49 |
|
50 ## Series |
|
51 for ii = 1:ntpoints |
|
52 fprintf (fid, "<DataSet timestep=""%#17.17g"" group=""%s"" ", time(ii), basename); |
|
53 fprintf (fid, strcat ("file=""%s.", format, ".vtu""/>\n"), basename, idx(ii)); |
|
54 endfor |
|
55 |
|
56 ## Footer |
|
57 fprintf (fid, "</Collection>\n"); |
|
58 fprintf (fid, "</VTKFile>\n"); |
|
59 fclose (fid); |
|
60 |
12671
|
61 endfunction |