1 ## Copyright (C) 2004-2008,2009 Carlo de Falco, Massimiliano Culpo
3 ## This file is part of
5 ## FPL - Fem PLotting package for octave
7 ## FPL is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
12 ## FPL is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ## GNU General Public License for more details.
17 ## You should have received a copy of the GNU General Public License
18 ## along with FPL; If not, see <http://www.gnu.org/licenses/>.
22 ## Carlo de Falco <cdf _AT_ users.sourceforge.net>
25 ## Bergische Universitaet Wuppertal
26 ## Fachbereich C - Mathematik und Naturwissenschaften
27 ## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20
28 ## D-42119 Wuppertal, Germany
31 ## @deftypefn {Function File} {} FPL3dxoutputmesh ( @var{filename}, @
34 ## Outputs data in DX form.
36 ## Variable must be a scalar, vector or tensor of doubles
39 ## @item @var{filename} = name of file to save (type string)
40 ## @item @var{mesh} = PDE-tool like mesh
45 function FPL3dxoutputmesh(filename,mesh)
48 elem = mesh.t(1:4,:)';
50 fid = fopen (filename,"w");
51 nnodes = columns(mesh.p);
52 nelem = columns(mesh.t);
54 fprintf(fid,"object ""pos""\nclass array type float rank 1 shape 3 items %d data follows",nnodes);
57 fprintf(fid," %e",nodes(ii,:));
60 ## In DX format nodes are numbered starting from zero,
61 ## instead we want to number them starting from 1.
62 if (min(min(elem))==1)
64 elseif(min(min(elem))~=0)
65 error("WARNING: check tetrahedra structure");
68 fprintf(fid,"\n\nobject ""con""\nclass array type int rank 1 shape 4 items %d data follows",nelem);
71 fprintf(fid," %d",elem(ii,:));
74 fprintf(fid,"\nattribute ""element type"" string ""tetrahedra""\nattribute ""ref"" string ""positions""\n\n");
76 fprintf(fid,"object ""themesh"" class field\n");
77 fprintf(fid,"component ""positions"" value ""pos""\n");
78 fprintf(fid,"component ""connections"" value ""con""\n");
80 fprintf(fid,"\nend\n");
86 %! msh.p =[ 0 0 1 1 0 0 1 1
89 %! msh.e =[1 5 7 8 5 5 6 8 1 3 5 7
90 %! 2 6 3 3 7 3 2 6 3 2 6 6
91 %! 6 1 8 4 3 1 4 4 2 4 7 8
92 %! 0 0 0 0 0 0 0 0 0 0 0 0
93 %! 0 0 0 0 0 0 0 0 0 0 0 0
94 %! 0 0 0 0 0 0 0 0 0 0 0 0
95 %! 0 0 0 0 0 0 0 0 0 0 0 0
96 %! 0 0 0 0 0 0 0 0 0 0 0 0
97 %! 1 1 1 1 1 1 1 1 1 1 1 1
98 %! 1 1 2 2 3 3 4 4 5 5 6 6];
99 %! msh.t =[ 1 5 5 6 7 8
104 %! testfile = "object ""pos""\nclass array type float rank 1 shape 3 items 8 data follows\n 0.000000e+00 0.000000e+00 0.000000e+00\n 0.000000e+00 1.000000e+00 0.000000e+00\n 1.000000e+00 0.000000e+00 0.000000e+00\n 1.000000e+00 1.000000e+00 0.000000e+00\n 0.000000e+00 0.000000e+00 1.000000e+00\n 0.000000e+00 1.000000e+00 1.000000e+00\n 1.000000e+00 0.000000e+00 1.000000e+00\n 1.000000e+00 1.000000e+00 1.000000e+00\n\nobject ""con""\nclass array type int rank 1 shape 4 items 6 data follows\n 0 2 1 5\n 4 5 6 2\n 4 5 2 0\n 5 2 1 3\n 6 2 5 7\n 7 2 5 3\nattribute ""element type"" string ""tetrahedra""\nattribute ""ref"" string ""positions""\n\nobject ""themesh"" class field\ncomponent ""positions"" value ""pos""\ncomponent ""connections"" value ""con""\n\nend\n";
105 %! FPL3dxoutputmesh ("__FPL3dxoutputmesh__test__.dx",msh);
106 %! fid = fopen("__FPL3dxoutputmesh__test__.dx","r");
109 %! assert (char(s'), testfile);
110 %! delete __FPL3dxoutputmesh__test__.dx