10635
|
1 ## Copyright (C) 2004-2008,2009 Carlo de Falco, Massimiliano Culpo |
|
2 ## |
|
3 ## This file is part of |
|
4 ## |
|
5 ## FPL - Fem PLotting package for octave |
|
6 ## |
|
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 |
10655
|
9 ## the Free Software Foundation; either version 3 of the License, or |
10635
|
10 ## (at your option) any later version. |
|
11 ## |
|
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. |
|
16 ## |
|
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/>. |
|
19 ## |
|
20 ## |
|
21 ## AUTHORS: |
|
22 ## Carlo de Falco <cdf _AT_ users.sourceforge.net> |
|
23 ## |
|
24 ## Culpo Massimiliano |
|
25 ## Bergische Universitaet Wuppertal |
|
26 ## Fachbereich C - Mathematik und Naturwissenschaften |
|
27 ## Arbeitsgruppe fuer Angewandte MathematD-42119 Wuppertal Gaussstr. 20 |
|
28 ## D-42119 Wuppertal, Germany |
|
29 |
|
30 ## -*- texinfo -*- |
|
31 ## |
|
32 ## @deftypefn {Function File} {} FPL2pdeshowmesh (@var{mesh},@var{color}) |
|
33 ## |
|
34 ## Displays one 2-D triangulations using opendx |
|
35 ## |
|
36 ## Examples: |
|
37 ## @example |
|
38 ## |
|
39 ## FPL2pdeshowmesh(mesh) |
|
40 ## FPL2pdeshowmesh(mesh,"blue") |
|
41 ## |
|
42 ## @end example |
|
43 ## |
|
44 ## @seealso{FPL2ptcshowmesh} |
|
45 ## @end deftypefn |
|
46 |
|
47 function FPL2pdeshowmesh (varargin) |
|
48 |
|
49 if nargin == 1 |
|
50 colorname = "red"; |
|
51 else |
|
52 colorname = varargin{2}; |
|
53 endif |
|
54 |
|
55 dataname = mktemp("/tmp",".dx"); |
|
56 FPL2dxoutputdata(dataname,varargin{1}.p,varargin{1}.t,varargin{1}.p(1,:)','x',0,1,1); |
|
57 |
|
58 scriptname = mktemp("/tmp",".net"); |
|
59 |
|
60 showmesh = file_in_path(path,"FPL2pdeshowmesh.net"); |
|
61 |
|
62 system (["cp " showmesh " " scriptname]); |
|
63 system (["sed -i \'s|FILENAME|" dataname "|g\' " scriptname]); |
|
64 system (["sed -i \'s|COLORNAME|" colorname "|g\' " scriptname]); |
|
65 |
|
66 command = ["dx -noConfirmedQuit -program " scriptname " -execute -image >& /dev/null & "]; |
|
67 system(command); |
|
68 |
|
69 endfunction |
|
70 |
|
71 function filename = mktemp (direct,ext); |
|
72 |
|
73 if (~exist(direct,"dir")) |
|
74 error("trying to save temporary file to non existing directory") |
|
75 end |
|
76 |
|
77 done=false; |
|
78 |
|
79 while ~done |
|
80 filename = [direct,"/FPL.",num2str(floor(rand*1e7)),ext]; |
|
81 if ~exist(filename,"file") |
|
82 done =true; |
|
83 endif |
|
84 endwhile |
|
85 |
|
86 endfunction |
|
87 |
|
88 %!test |
|
89 %! msh.p = [0 0; 1 0; 1 1; 0 1].'; |
|
90 %! msh.t = [1 2 3 1; 1 3 4 1].'; |
|
91 %! msh.e = [1 2 0 0 1 0 1; 2 3 0 0 2 0 1; 3 4 0 0 3 0 1; 4 1 0 0 4 0 1].'; |
|
92 %! FPL2pdeshowmesh (msh, "red"); |
|
93 %! s = input ("do you see a red outlined square divided in two triangles (if you see an empty plot try ctrl-F)? (y/n): " ,"s"); |
|
94 %! assert(s, "y") |