1 ## Copyright (C) 2006,2007,2008,2009,2010 Carlo de Falco, Massimiliano Culpo
3 ## This file is part of:
4 ## FPL - Fem PLotting package for octave
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
8 ## the Free Software Foundation; either version 2 of the License, or
9 ## (at your option) any later version.
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.
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/>.
19 ## author: Carlo de Falco <cdf _AT_ users.sourceforge.net>
20 ## author: Massimiliano Culpo <culpo _AT_ users.sourceforge.net>
23 ## @deftypefn {Function File} {} fpl_dx_write_series (@var{basename}, @
24 ## @var{mesh}, @var{u}, @var{sp}, @var{attr_name}, @var{attr_rank}, @
27 ## Output data series in ASCII Open-DX format.
29 ## @var{basename} is a string containing the base-name of the dx file where the
30 ## data will be saved.
32 ## @var{mesh} is a PDE-tool like mesh, like the ones generated by the
35 ## @var{u} is the series to be saved. It should represent scalar, vector
36 ## or tensor of doubles. @var{sp} is the vector of the sampled points
37 ## (e.g. time points in the case of a time series).
39 ## @var{attr_name} is a descriptive name for the series @var{u}, while
40 ## @var{attr_rank} is the rank of the field items (0 for scalar, 1 for
41 ## vector, etc.) and @var{attr_shape} is the number of components of the
42 ## field items (assumed 1 for scalar).
44 ## @seealso{fpl_dx_write_field}
48 function fpl_dx_write_series(basename,mesh,u,tp,attr_name,attr_rank,attr_shape)
50 ## FIXME: add append capabilities as in fpl_dx_write_field??
53 error("fpl_dx_write_series: wrong number of input");
57 error("fpl_dx_write_series: basename should be a valid string");
58 elseif !( isstruct(mesh) )
59 error("fpl_dx_write_series: mesh should be a valid structure");
61 error("fpl_dx_write_series: u should be a valid matrix");
62 elseif !ischar(attr_name)
63 error("fpl_dx_write_series: attr_name should be a valid string");
64 elseif !isscalar(attr_rank)
65 error("fpl_dx_write_series: attr_rank should be a valid scalar");
66 elseif !isscalar(attr_shape)
67 error("fpl_dx_write_series: attr_shape should be a valid scalar");
68 ##elseif !isscalar(endfile)
69 ##error("fpl_dx_write_series: endfile should be a valid scalar");
72 filename = [basename ".dx"];
77 dim = columns(p); # 2D or 3D
84 error("fpl_dx_write_series: neither 2D triangle nor 3D tetrahedral mesh");
93 elseif ndatas == nelems
96 error("fpl_dx_write_series: neither position nor connection data type")
99 ## Write field items to file
100 idx = (1:attr_shape);
103 fname = sprintf("%s.%d",attr_name,ii);
104 fpl_dx_write_field(basename,mesh,field,fname,attr_rank,attr_shape,0);
109 fid = fopen(filename,"a");
110 fprintf (fid, "object \"%s_series\" class series\n",attr_name);
112 fname = sprintf("%s.%d",attr_name,ii);
113 fprintf (fid,"member %d position %g value \"%s\"\n",ii-1,tp(ii),fname);
115 fprintf (fid, "\nend\n");