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 ## @deftypefn {Function File} {} FPL2pdesurf (@var{mesh}, @ |
|
32 ## @var{u} [ @var{property}, @var{value} ...]) |
|
33 ## |
|
34 ## plots the scalar field @var{u} |
|
35 ## defined on the triangulation @var{mesh} using opendx. |
|
36 ## |
|
37 ## options (default value): |
|
38 ## @itemize @minus |
|
39 ## @item data_dep ("positions") defines wether data depends on |
|
40 ## positions or connections |
|
41 ## @item plot_field ("scalar") defines wether to plot the scalar field |
|
42 ## itself or its gradient |
|
43 ## @end itemize |
|
44 ## |
|
45 ## @seealso{MSH2Mgmsh, MSH2Mstructmesh} |
|
46 ## @end deftypefn |
|
47 |
|
48 function FPL2pdesurf(varargin) |
|
49 |
|
50 data_dep = "positions"; |
|
51 plot_field = "scalar"; |
|
52 |
|
53 if nargin == 1 |
|
54 FPL2showmesh(varargin{1}); |
|
55 elseif nargin == 2 |
|
56 mesh = varargin{1}; |
|
57 u = varargin{2}; |
|
58 elseif ( (nargin > 2) && (rem(nargin,2)==0) ) |
|
59 mesh = varargin{1}; |
|
60 u = varargin{2}; |
|
61 for ii=3:2:nargin |
|
62 eval([ varargin{ii} " = """ varargin{ii+1} """;" ]); |
|
63 endfor |
|
64 else |
|
65 keyboard ,error(["wrong number of parameters " num2str (nargin)]) |
|
66 endif |
|
67 |
|
68 dataname = mktemp("/tmp",".dx"); |
|
69 scriptname = mktemp("/tmp",".net"); |
|
70 |
|
71 FPL2dxoutputdata(dataname,mesh.p,mesh.t,u,'u',0,1,1); |
|
72 |
|
73 switch plot_field |
|
74 case {"scalar","scal"} |
|
75 showmesh = file_in_path(path,"FPL2coloredrubbersheet.net"); |
|
76 case {"gradient","grad"} |
|
77 showmesh = file_in_path(path,"FPL2coloredgradient.net"); |
|
78 otherwise |
|
79 error ([ "incorrect value " plot_field " for option plot_field "]) |
|
80 endswitch |
|
81 |
|
82 system (["cp " showmesh " " scriptname]); |
|
83 system (["sed -i \'s|__FILE__DX__|" dataname "|g\' " scriptname]); |
|
84 |
|
85 switch data_dep |
|
86 case {"positions","continuous","interpolate","P1"} |
|
87 system (["sed -i \'s|__DATA_DEPENDENCY__|positions|g\' " scriptname]); |
|
88 case {"connections","discontinuous","P0"} |
|
89 system (["sed -i \'s|__DATA_DEPENDENCY__|positions|g\' " scriptname]); |
|
90 otherwise |
|
91 error ([ "incorrect value " data_dep " for option data_dep "]) |
|
92 endswitch |
|
93 |
|
94 ##command = ["dx -noConfirmedQuit -noImageRWNetFile -program " scriptname " -execute -image >& /dev/null & "]; |
|
95 command = ["dx -noConfirmedQuit -program " scriptname " -execute -image >& /dev/null & "]; |
|
96 |
|
97 system(command); |
|
98 |
|
99 endfunction |
|
100 |
|
101 function filename = mktemp (direct,ext); |
|
102 |
|
103 if (~exist(direct,"dir")) |
|
104 error("trying to save temporary file to non existing directory") |
|
105 endif |
|
106 |
|
107 done=false; |
|
108 |
|
109 while ~done |
|
110 filename = [direct,"/FPL.",num2str(floor(rand*1e7)),ext]; |
|
111 if ~exist(filename,"file") |
|
112 done =true; |
|
113 endif |
|
114 endwhile |
|
115 |
|
116 endfunction |
|
117 |
|
118 %!shared msh |
|
119 %!test |
|
120 %! msh.p = [0 0; 1 0; 1 1; 0 1].'; |
|
121 %! msh.t = [1 2 3 1; 1 3 4 1].'; |
|
122 %! 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].'; |
|
123 %! u = [0 1].'; |
|
124 %! FPL2pdesurf (msh, u, "data_dep", "connections"); |
|
125 %! s = input ("do you see a square divided into two triangles with a diagonal red-to-blue gradient color (if you see an empty plot try ctrl-F)? (y/n): " ,"s"); |
|
126 %! assert(s, "y") |
|
127 %!test |
|
128 %! v = [0 0 1 1].'; |
|
129 %! FPL2pdesurf (msh, v); |
|
130 %! s = input ("do you see a square divided into two triangles with a vertical red-to-blue gradient color (if you see an empty plot try ctrl-F)? (y/n): " ,"s"); |