1 |
%GENBEL4 Build a boundary element file (.bel) for QUODDY. |
---|
2 |
% |
---|
3 |
% GENBEL4 is a MATLAB5-compatible mouse-driven GUI |
---|
4 |
% tool to build a .bel file, specifying boundary |
---|
5 |
% condition codes by clicking on node numbers and |
---|
6 |
% boundary types. |
---|
7 |
% |
---|
8 |
% Currrently, GENBE4L can create a new .bel |
---|
9 |
% from scratch, given only the .nod and .ele |
---|
10 |
% files for a domain, or it can read an existing |
---|
11 |
% one and edit the current codes. |
---|
12 |
% |
---|
13 |
% GENBEL4 can also output a "node code" list for input |
---|
14 |
% into a .nei file. At this time, corner nodes cannot |
---|
15 |
% be determined and must still be specified external to |
---|
16 |
% MATLAB. |
---|
17 |
% |
---|
18 |
% There is an "Info" line at the bottom of the |
---|
19 |
% figure which prompts the user for the next step. |
---|
20 |
% The "HELP" button provides more complete instructions. |
---|
21 |
% |
---|
22 |
% CALL as: >> genbel4 |
---|
23 |
% |
---|
24 |
% GENBEL4 was written by: |
---|
25 |
% Brian O. Blanton |
---|
26 |
% Department of Marine Sciences |
---|
27 |
% Ocean Processes Numerical Modeling Laboratory |
---|
28 |
% 15-1A Venable Hall |
---|
29 |
% CB# 3300 |
---|
30 |
% Uni. of North Carolina |
---|
31 |
% Chapel Hill, NC |
---|
32 |
% 27599-3300 |
---|
33 |
% |
---|
34 |
% 919-962-4466 |
---|
35 |
% blanton@marine.unc.edu |
---|
36 |
% |
---|
37 |
% Version 3.0 (M5.0.0) Summer 1997 |
---|
38 |
% |
---|
39 |
function retval=genbel4(command,option) |
---|
40 |
colordef none |
---|
41 |
|
---|
42 |
% make sure this is atleast MATLAB version5.0.0 |
---|
43 |
% |
---|
44 |
vers=version; |
---|
45 |
if vers(1)<5 |
---|
46 |
disp('??? Error using ==>> GENBEL4 '); |
---|
47 |
disp('This version of GENBEL4 REQUIRES!! MATLAB version 5.0.0 or later.'); |
---|
48 |
disp('Sorry, but this is terminal.'); |
---|
49 |
return |
---|
50 |
end |
---|
51 |
if nargin==0 |
---|
52 |
command='initialize'; |
---|
53 |
option='no opt'; |
---|
54 |
end |
---|
55 |
if strcmp(command,'debug') |
---|
56 |
command='initialize'; |
---|
57 |
option='debug'; |
---|
58 |
end |
---|
59 |
if ~exist('option'),option='no_opt';,end |
---|
60 |
|
---|
61 |
GBfig=findobj(0,'Type','figure','Tag','GBMainFig'); |
---|
62 |
GBaxes=findobj(0,'Type','axes','Tag','GBMainAx'); |
---|
63 |
GBInfoLine=findobj(GBfig,'Type','uicontrol','Tag','GBInfoLine'); |
---|
64 |
|
---|
65 |
global GB_GRID GB_BND |
---|
66 |
|
---|
67 |
% If a grid has been defined, extract it. |
---|
68 |
% |
---|
69 |
if ~isempty(GBfig) |
---|
70 |
if GB_GRID |
---|
71 |
griddata=get(GBfig,'UserData'); |
---|
72 |
nn=griddata(1,6); |
---|
73 |
x=griddata(1:nn,1); |
---|
74 |
y=griddata(1:nn,2); |
---|
75 |
ne=griddata(3,6); |
---|
76 |
e=griddata(1:ne,3:5); |
---|
77 |
end |
---|
78 |
if GB_BND |
---|
79 |
nbnd=griddata(2,6); |
---|
80 |
bnd=griddata(1:nbnd,7:8); |
---|
81 |
end |
---|
82 |
else |
---|
83 |
GB_GRID=0; |
---|
84 |
GB_BND=0; |
---|
85 |
end |
---|
86 |
|
---|
87 |
|
---|
88 |
if strcmp(command,'initialize') %%% INITIALIZATION CALLS |
---|
89 |
%%% |
---|
90 |
%%% INITIALIZATION CALLS |
---|
91 |
%%% |
---|
92 |
GB_GRID=0; |
---|
93 |
GB_BND=0; |
---|
94 |
genbel4('SetUpFig'); |
---|
95 |
if strcmp(option,'debug') |
---|
96 |
genbel4('LoadGrid','debug'); |
---|
97 |
end |
---|
98 |
|
---|
99 |
elseif strcmp(command,'LoadGrid') %%% LOAD A .nod & .ele DOMAIN |
---|
100 |
%%% |
---|
101 |
%%% LOAD A .nod & .ele DOMAIN |
---|
102 |
%%% |
---|
103 |
% Wipe existing grid, if it exists. |
---|
104 |
% |
---|
105 |
set(GBfig,'UserData',[]); % Grid data |
---|
106 |
set(GBaxes,'UserData',[]); % Bel list |
---|
107 |
cla |
---|
108 |
axis('auto') |
---|
109 |
|
---|
110 |
oldpt=get(GBfig,'Pointer'); |
---|
111 |
set(GBfig,'Pointer','watch'); |
---|
112 |
|
---|
113 |
if ~strcmp(option,'debug') |
---|
114 |
% get node filename from user |
---|
115 |
suffix='xxxx'; |
---|
116 |
while ~strcmp(suffix,'.nod') |
---|
117 |
filefilt=[pwd '/*.nod']; |
---|
118 |
[filename, pathname] = uigetfile(filefilt, 'Click on .nod filename'); |
---|
119 |
if filename==0 |
---|
120 |
set(GBfig,'Pointer',oldpt); |
---|
121 |
return |
---|
122 |
end |
---|
123 |
gname=filename(1:length(filename)-4); |
---|
124 |
suffix=filename(length(filename)-3:length(filename)); |
---|
125 |
end |
---|
126 |
nodename=[pathname filename]; |
---|
127 |
loadcom=['load ' nodename]; |
---|
128 |
infostring=[' Loading ' nodename ' ...']; |
---|
129 |
set(GBInfoLine,'String',infostring); |
---|
130 |
drawnow |
---|
131 |
eval(loadcom) |
---|
132 |
nodes=eval(filename(1:length(filename)-4)); |
---|
133 |
x=nodes(:,2);x=x(:); |
---|
134 |
y=nodes(:,3);y=y(:); |
---|
135 |
|
---|
136 |
% get element filename from user |
---|
137 |
suffix='xxxx'; |
---|
138 |
while ~strcmp(suffix,'.ele') |
---|
139 |
filefilt=[pathname '/*.ele']; |
---|
140 |
[filename, pathname] = uigetfile(filefilt, 'Click on .ele filename'); |
---|
141 |
if filename==0 |
---|
142 |
set(GBfig,'Pointer',oldpt); |
---|
143 |
return |
---|
144 |
end |
---|
145 |
checkname=filename(1:length(filename)-4); |
---|
146 |
suffix=filename(length(filename)-3:length(filename)); |
---|
147 |
end |
---|
148 |
if ~strcmp(gname,checkname) |
---|
149 |
disp('Domain names in .nod & .ele files do not match!'); |
---|
150 |
res=[]; |
---|
151 |
while ~strcmp(lower(res),'y') & ~strcmp(lower(res),'n') |
---|
152 |
res=input('Continue [y/N] ? ','s'); |
---|
153 |
end |
---|
154 |
if strcmp(lower(res),'n') |
---|
155 |
return |
---|
156 |
else |
---|
157 |
disp('Unless the .ele & .nod files are really from'); |
---|
158 |
disp('the same domain, GENBEL is going to bomb.') |
---|
159 |
disp('Hit <RETURN> to continue.') |
---|
160 |
pause |
---|
161 |
end |
---|
162 |
end |
---|
163 |
|
---|
164 |
elename=[pathname filename]; |
---|
165 |
loadcom=['load ' elename]; |
---|
166 |
infostring=[' Loading ' elename ' ...']; |
---|
167 |
set(GBInfoLine,'String',infostring); |
---|
168 |
drawnow |
---|
169 |
eval(loadcom) |
---|
170 |
e=eval(filename(1:length(filename)-4)); |
---|
171 |
e=e(:,2:4); |
---|
172 |
else |
---|
173 |
if ~isdir('/homes/blanton/matlab/development') |
---|
174 |
disp('Debug directory /homes/blanton/matlab/development'); |
---|
175 |
disp('does not exist. Debug mode can only run here'); |
---|
176 |
disp('/homes/blanton/matlab/development'); |
---|
177 |
delete(GBfig); |
---|
178 |
return |
---|
179 |
end |
---|
180 |
cwd=pwd; |
---|
181 |
if ~strcmp(cwd,'/homes/blanton/matlab/development')&... |
---|
182 |
~strcmp(cwd,'/home5/blanton/matlab/development') |
---|
183 |
disp('Not in Debug directory /homes/blanton/matlab/development'); |
---|
184 |
delete(GBfig); |
---|
185 |
return |
---|
186 |
end |
---|
187 |
|
---|
188 |
load lm.nod |
---|
189 |
x=lm(:,2);x=x(:); |
---|
190 |
y=lm(:,3);y=y(:); |
---|
191 |
load lm.ele |
---|
192 |
e=lm(:,2:4); |
---|
193 |
|
---|
194 |
GBLoadBelBut=findobj(GBfig,'Type','uicontrol','Tag','GBLoadBelBut'); |
---|
195 |
GBHashBndBut=findobj(GBfig,'Type','uicontrol','Tag','GBHashBndBut'); |
---|
196 |
GBOutputBelBut=findobj(GBfig,'Type','uicontrol','Tag','GBOutputBelBut'); |
---|
197 |
set([GBLoadBelBut GBHashBndBut GBOutputBelBut],'Enable','on'); |
---|
198 |
end |
---|
199 |
|
---|
200 |
% Store grid coordinates in figure UserData |
---|
201 |
% |
---|
202 |
alloc_len=(max(length(e),length(x))); |
---|
203 |
temp=NaN*ones(alloc_len,7); |
---|
204 |
temp(1:length(e),3:5)=e; |
---|
205 |
temp(1:length(x),1)=x; |
---|
206 |
temp(1:length(x),2)=y; |
---|
207 |
temp(1,6)=length(x); |
---|
208 |
temp(3,6)=length(e); |
---|
209 |
set(GBfig,'UserData',temp); |
---|
210 |
set(GBfig,'Pointer',oldpt); |
---|
211 |
GB_GRID=1; |
---|
212 |
|
---|
213 |
GBLoadBelBut=findobj(GBfig,'Type','uicontrol','Tag','GBLoadBelBut'); |
---|
214 |
GBHashBndBut=findobj(GBfig,'Type','uicontrol','Tag','GBHashBndBut'); |
---|
215 |
set([GBLoadBelBut GBHashBndBut],'Enable','on'); |
---|
216 |
set(GBInfoLine,'String',' "Load Bel" (existing) or "New Bnd" (new bel)') |
---|
217 |
|
---|
218 |
elseif strcmp(command,'LoadBel') %%% LOAD AN EXISTING .bel FILE |
---|
219 |
%%% |
---|
220 |
%%% LOAD AN EXISTING .bel FILE |
---|
221 |
%%% |
---|
222 |
filefilt=[pwd '/*.bel']; |
---|
223 |
[fname,fpath]=uigetfile(filefilt,'Which .bel ?'); |
---|
224 |
if fname==0,return,end |
---|
225 |
|
---|
226 |
% get filetype from tail of fname |
---|
227 |
ftype=fname(length(fname)-2:length(fname)); |
---|
228 |
|
---|
229 |
% make sure this is an allowed filetype |
---|
230 |
if ~strcmp(ftype,'bel') |
---|
231 |
disp('??? Error using ==>> GENBEL') |
---|
232 |
disp(['GENBEL cannot accept ' ftype ' filetype']) |
---|
233 |
return |
---|
234 |
end |
---|
235 |
|
---|
236 |
% Remove bellist from main axes 'UserData'. |
---|
237 |
% |
---|
238 |
set(GBaxes,'UserData',[]); |
---|
239 |
|
---|
240 |
% open fname |
---|
241 |
% |
---|
242 |
[pfid,message]=fopen([fpath fname]); |
---|
243 |
if pfid==-1 |
---|
244 |
error([fpath fname,' not found. ',message]); |
---|
245 |
end |
---|
246 |
|
---|
247 |
% In all filetypes there is always a gridname and description line |
---|
248 |
% as lines #1 and #2 of the file. |
---|
249 |
% read grid name from top of file; header line #1 |
---|
250 |
% |
---|
251 |
gridname=fgets(pfid); |
---|
252 |
gridname=blank(gridname); |
---|
253 |
% read description line from top of file; header line #2 |
---|
254 |
descline=fgets(pfid); |
---|
255 |
% read data segment |
---|
256 |
bellist=fscanf(pfid,'%d %f %f %f %f',[5 inf])'; |
---|
257 |
fclose(pfid); |
---|
258 |
|
---|
259 |
% Need to set nbnd and bnd list in the main griddata array stored in the GBfig UserData |
---|
260 |
% |
---|
261 |
temp=get(GBfig,'UserData'); |
---|
262 |
nbnd=length(bellist); |
---|
263 |
temp(2,6)=nbnd; |
---|
264 |
temp(1:nbnd,7:8)=bellist(:,2:3); |
---|
265 |
set(GBfig,'UserData',temp); |
---|
266 |
|
---|
267 |
set(GBaxes,'UserData',bellist); |
---|
268 |
genbel4('PlotBnd'); |
---|
269 |
GBOutputBelBut=findobj(GBfig,'Type','uicontrol','Tag','GBOutputBelBut'); |
---|
270 |
set(GBOutputBelBut,'Enable','on'); |
---|
271 |
|
---|
272 |
set(GBInfoLine,'String',' Enter Starting and Ending NN to connect'); |
---|
273 |
GB_BND=1; |
---|
274 |
|
---|
275 |
elseif strcmp(command,'SetAxis') %%% AXIS EQUAL |
---|
276 |
%%% |
---|
277 |
%%% AXIS EQUAL |
---|
278 |
%%% |
---|
279 |
if GB_GRID==0 |
---|
280 |
set(GBInfoLine,'String',' Grid not Loaded yet. Use "Load Grid".'); |
---|
281 |
return |
---|
282 |
elseif GB_BND==0 |
---|
283 |
set(GBInfoLine,'String',' Boundary NOT parsed or .bel NOT loaded.'); |
---|
284 |
return |
---|
285 |
end |
---|
286 |
axis('equal') |
---|
287 |
xrange=max(x)-min(x); |
---|
288 |
yrange=max(y)-min(y); |
---|
289 |
RenLim(1:2)=get(GBaxes,'XLim'); |
---|
290 |
RenLim(3:4)=get(GBaxes,'YLim'); |
---|
291 |
newxmin=RenLim(1)-xrange/20; |
---|
292 |
newxmax=RenLim(2)+xrange/20; |
---|
293 |
newymin=RenLim(3)-yrange/20; |
---|
294 |
newymax=RenLim(4)+yrange/20; |
---|
295 |
axis([newxmin newxmax newymin newymax]) |
---|
296 |
|
---|
297 |
elseif strcmp(command,'Def_buttons') %%% DEFINE MOUSE BUTTON FUNCTIONS |
---|
298 |
%%% |
---|
299 |
%%% DEFINE MOUSE BUTTON FUNCTIONS |
---|
300 |
%%% |
---|
301 |
set(GBfig,'WindowButtonDownFcn','genbel4(''Proc_mouse_event'')') |
---|
302 |
|
---|
303 |
elseif strcmp(command,'Proc_mouse_event') %%% PROCESS MOUSE BUTTON EVENTS |
---|
304 |
%%% |
---|
305 |
%%% PROCESS MOUSE BUTTON EVENTS |
---|
306 |
%%% |
---|
307 |
seltype=get(GBfig,'SelectionType'); |
---|
308 |
|
---|
309 |
if strcmp(seltype,'open') |
---|
310 |
GBStartingNN=findobj(GBfig,'Type','uicontrol','Tag','GBStartingNN'); |
---|
311 |
GBEndingNN=findobj(GBfig,'Type','uicontrol','Tag','GBEndingNN'); |
---|
312 |
set(GBStartingNN,'String','<enter>') |
---|
313 |
set(GBEndingNN,'String','<enter>') |
---|
314 |
end |
---|
315 |
|
---|
316 |
objtag=get(gco,'Tag'); |
---|
317 |
if ~strcmp(objtag,'Bnd Node #'),return,end |
---|
318 |
nodenum=get(gco,'UserData'); |
---|
319 |
|
---|
320 |
if strcmp(seltype,'normal') |
---|
321 |
GBStartingNN=findobj(GBfig,'Type','uicontrol','Tag','GBStartingNN'); |
---|
322 |
set(GBStartingNN,'String',nodenum); |
---|
323 |
GBEndingNN=findobj(GBfig,'Type','uicontrol','Tag','GBEndingNN'); |
---|
324 |
set(GBEndingNN,'String','<enter>'); |
---|
325 |
elseif strcmp(seltype,'extend') |
---|
326 |
GBEndingNN=findobj(GBfig,'Type','uicontrol','Tag','GBEndingNN'); |
---|
327 |
set(GBEndingNN,'String',nodenum); |
---|
328 |
genbel4('Check2') |
---|
329 |
end |
---|
330 |
|
---|
331 |
elseif strcmp(command,'ClearCodes') %%% CLEAR CURRENT BOUNDARY CODES |
---|
332 |
%%% |
---|
333 |
%%% CLEAR CURRENT BOUNDARY CODES |
---|
334 |
%%% |
---|
335 |
if GB_GRID==0 |
---|
336 |
set(GBInfoLine,'String',' Grid not Loaded yet. Use "Load Grid".'); |
---|
337 |
return |
---|
338 |
elseif GB_BND==0 |
---|
339 |
set(GBInfoLine,'String',' Boundary NOT parsed or .bel NOT loaded.'); |
---|
340 |
return |
---|
341 |
end |
---|
342 |
bellist=get(GBaxes,'UserData'); |
---|
343 |
bellist(:,5)=zeros(size(bellist(:,5))); |
---|
344 |
set(GBaxes,'UserData',bellist); |
---|
345 |
genbel4('PlotBnd') |
---|
346 |
btb(1)=findobj(GBfig,'Type','uicontrol','Tag','GBLandBut'); |
---|
347 |
btb(2)=findobj(GBfig,'Type','uicontrol','Tag','GBIslandBut'); |
---|
348 |
btb(3)=findobj(GBfig,'Type','uicontrol','Tag','GBNon-0NormBut'); |
---|
349 |
btb(4)=findobj(GBfig,'Type','uicontrol','Tag','GBGeosT.OutBut'); |
---|
350 |
btb(5)=findobj(GBfig,'Type','uicontrol','Tag','GBElevationBut'); |
---|
351 |
set(btb,'Value',0) |
---|
352 |
GBOutPutBelFig=findobj(0,'Type','figure','Tag','GBOutPutBelFig'); |
---|
353 |
delete(GBOutPutBelFig); |
---|
354 |
|
---|
355 |
elseif strcmp(command,'WhichBndType') %%% DETERMINE BND TYPE SELECTION |
---|
356 |
%%% |
---|
357 |
%%% DETERMINE BND TYPE SELECTION |
---|
358 |
%%% |
---|
359 |
btb(1)=findobj(GBfig,'Type','uicontrol','Tag','GBLandBut'); |
---|
360 |
btb(2)=findobj(GBfig,'Type','uicontrol','Tag','GBIslandBut'); |
---|
361 |
btb(3)=findobj(GBfig,'Type','uicontrol','Tag','GBNon-0NormBut'); |
---|
362 |
btb(4)=findobj(GBfig,'Type','uicontrol','Tag','GBGeosT.OutBut'); |
---|
363 |
btb(5)=findobj(GBfig,'Type','uicontrol','Tag','GBElevationBut'); |
---|
364 |
val(1)=get(btb(1),'Value'); |
---|
365 |
val(2)=get(btb(2),'Value'); |
---|
366 |
val(3)=get(btb(3),'Value'); |
---|
367 |
val(4)=get(btb(4),'Value'); |
---|
368 |
val(5)=get(btb(5),'Value'); |
---|
369 |
bndtype=find(val==1); |
---|
370 |
if isempty(bndtype) |
---|
371 |
retval=0; |
---|
372 |
else |
---|
373 |
retval=bndtype; |
---|
374 |
end |
---|
375 |
|
---|
376 |
elseif strcmp(command,'Check1') %%% CHECK AFTER START_NN INPUT |
---|
377 |
%%% |
---|
378 |
%%% CHECK AFTER START_NN INPUT |
---|
379 |
%%% |
---|
380 |
GBStartingNN=findobj(GBfig,'Type','uicontrol','Tag','GBStartingNN'); |
---|
381 |
if GB_GRID==0 |
---|
382 |
set(GBInfoLine,'String',' Grid not Loaded yet. Use "Load Grid".'); |
---|
383 |
set(GBStartingNN,'String','<enter>'); |
---|
384 |
elseif GB_BND==0 |
---|
385 |
set(GBInfoLine,'String',' Boundary NOT parsed or .bel NOT loaded.'); |
---|
386 |
set(GBStartingNN,'String','<enter>'); |
---|
387 |
else |
---|
388 |
GBEndingNN=findobj(GBfig,'Type','uicontrol','Tag','GBEndingNN'); |
---|
389 |
set(GBEndingNN,'String','<enter>'); |
---|
390 |
set(GBInfoLine,'String',' Make sure an ending nn and bnd type has been selected') |
---|
391 |
end |
---|
392 |
|
---|
393 |
elseif strcmp(command,'Check2') %%% CHECK AFTER END_NN INPUT |
---|
394 |
%%% |
---|
395 |
%%% CHECK AFTER END_NN INPUT |
---|
396 |
%%% |
---|
397 |
GBEndingNN=findobj(GBfig,'Type','uicontrol','Tag','GBEndingNN'); |
---|
398 |
if GB_GRID==0 |
---|
399 |
set(GBInfoLine,'String',' Grid not Loaded yet. Use "Load Grid".'); |
---|
400 |
set(GBEndingNN,'String','<enter>'); |
---|
401 |
return |
---|
402 |
elseif GB_BND==0 |
---|
403 |
set(GBInfoLine,'String',' Boundary NOT parsed or .bel NOT loaded.'); |
---|
404 |
set(GBEndingNN,'String','<enter>'); |
---|
405 |
return |
---|
406 |
end |
---|
407 |
|
---|
408 |
% Make sure starting and ending nodes have been defined |
---|
409 |
% |
---|
410 |
GBStartingNN=findobj(GBfig,'Type','uicontrol','Tag','GBStartingNN'); |
---|
411 |
GBEndingNN=findobj(GBfig,'Type','uicontrol','Tag','GBEndingNN'); |
---|
412 |
startingnn=get(GBStartingNN,'String'); |
---|
413 |
endingnn=get(GBEndingNN,'String'); |
---|
414 |
if strcmp(startingnn,'<enter>') |
---|
415 |
set(GBInfoLine,'String',' Starting node number NOT entered.') |
---|
416 |
return |
---|
417 |
end |
---|
418 |
if strcmp(endingnn,'<enter>') |
---|
419 |
set(GBInfoLine,'String',' Ending node number NOT entered.') |
---|
420 |
return |
---|
421 |
end |
---|
422 |
strnn=eval(startingnn); |
---|
423 |
endnn=eval(endingnn); |
---|
424 |
line([x(strnn) x(endnn)],[y(strnn) y(endnn)],'Marker','*',... |
---|
425 |
'MarkerSize',25,'color','m','Tag','GBNodeMark'); |
---|
426 |
|
---|
427 |
% Make sure a boundary type has been selected. |
---|
428 |
% |
---|
429 |
bndtype=genbel4('WhichBndType'); |
---|
430 |
if bndtype==0 |
---|
431 |
set(GBInfoLine,'String',' Boundary Type NOT selected.') |
---|
432 |
return |
---|
433 |
end |
---|
434 |
|
---|
435 |
GBConnectBut=findobj(GBfig,'Type','uicontrol','Tag','GBConnectBut'); |
---|
436 |
set(GBConnectBut,'BackGroundColor','g','Enable','on'); |
---|
437 |
|
---|
438 |
set(GBInfoLine,'String',' Ready to "Connect".') |
---|
439 |
|
---|
440 |
elseif strcmp(command,'Pan') %%% PAN FUNCTION |
---|
441 |
%%% |
---|
442 |
%%% PAN FUNCTION |
---|
443 |
%%% |
---|
444 |
GBPanBut=findobj(GBfig,'type','uicontrol','Tag','GBPanBut'); |
---|
445 |
GBZoomBut=findobj(GBfig,'type','uicontrol','Tag','GBZoomBut'); |
---|
446 |
if GB_GRID==0 |
---|
447 |
set(GBInfoLine,'String',' Grid not Loaded yet. Use "Load Grid".'); |
---|
448 |
set(GBPanBut,'String','PAN OFF','Value',0); |
---|
449 |
set(GBZoomBut,'String','ZOOM OFF','Value',0); |
---|
450 |
elseif GB_BND==0 |
---|
451 |
set(GBInfoLine,'String',' Boundary NOT parsed or .bel NOT loaded.'); |
---|
452 |
set(GBPanBut,'String','PAN OFF','Value',0); |
---|
453 |
set(GBZoomBut,'String','ZOOM OFF','Value',0); |
---|
454 |
end |
---|
455 |
|
---|
456 |
% First check the state of ZOOM; turn off if "ON" |
---|
457 |
% |
---|
458 |
state=get(GBZoomBut,'String'); |
---|
459 |
if strcmp(state,'ZOOM ON') |
---|
460 |
zoom off |
---|
461 |
set(GBZoomBut,'String','ZOOM OFF','Value',0); |
---|
462 |
end |
---|
463 |
set(GBPanBut,'String','PAN ON'); |
---|
464 |
pan |
---|
465 |
set(GBPanBut,'String','PAN OFF','Value',0); |
---|
466 |
genbel4('Def_buttons'); |
---|
467 |
|
---|
468 |
elseif strcmp(command,'Zoom') %%% ZOOM IN/OUT FUNCTION |
---|
469 |
%%% |
---|
470 |
%%% ZOOM IN/OUT FUNCTION |
---|
471 |
%%% |
---|
472 |
GBZoomBut=findobj(GBfig,'type','uicontrol','Tag','GBZoomBut'); |
---|
473 |
if GB_GRID==0 |
---|
474 |
set(GBInfoLine,'String',' Grid not Loaded yet. Use "Load Grid".'); |
---|
475 |
set(GBZoomBut,'String','ZOOM OFF'); |
---|
476 |
genbel4('Def_buttons'); |
---|
477 |
return |
---|
478 |
elseif GB_BND==0 |
---|
479 |
set(GBInfoLine,'String',' Boundary NOT parsed or .bel NOT loaded.'); |
---|
480 |
set(GBZoomBut,'String','ZOOM OFF'); |
---|
481 |
genbel4('Def_buttons'); |
---|
482 |
return |
---|
483 |
end |
---|
484 |
|
---|
485 |
state=get(GBZoomBut,'String'); |
---|
486 |
if strcmp(state,'ZOOM OFF') |
---|
487 |
zoom on |
---|
488 |
set(GBZoomBut,'String','ZOOM ON'); |
---|
489 |
else |
---|
490 |
zoom off |
---|
491 |
set(GBZoomBut,'String','ZOOM OFF'); |
---|
492 |
genbel4('Def_buttons'); |
---|
493 |
end |
---|
494 |
|
---|
495 |
elseif strcmp(command,'Numbnd') %%% NUMBER BOUNDARY NODES |
---|
496 |
%%% |
---|
497 |
%%% NUMBER BOUNDARY NODES |
---|
498 |
%%% |
---|
499 |
if GB_GRID==0 |
---|
500 |
set(GBInfoLine,'String',' Grid not Loaded yet. Use "Load Grid".'); |
---|
501 |
return |
---|
502 |
elseif GB_BND==0 |
---|
503 |
set(GBInfoLine,'String',' Boundary NOT parsed or .bel NOT loaded.'); |
---|
504 |
return |
---|
505 |
end |
---|
506 |
|
---|
507 |
% Delete previous node number text objs |
---|
508 |
% |
---|
509 |
texts=findobj(GBaxes,'Type','text','Tag','Bnd Node #'); |
---|
510 |
|
---|
511 |
X=get(GBaxes,'XLim'); |
---|
512 |
Y=get(GBaxes,'YLim'); |
---|
513 |
|
---|
514 |
ns=bnd(:,1); |
---|
515 |
ne=bnd(:,2); |
---|
516 |
x=x(ns); |
---|
517 |
y=y(ns); |
---|
518 |
nlist=bnd(:,1); |
---|
519 |
|
---|
520 |
% get indices of nodes within viewing window defined by X,Y |
---|
521 |
filt=find(x>=X(1)&x<=X(2)&y>=Y(1)&y<=Y(2)); |
---|
522 |
|
---|
523 |
% label only those nodes that lie within viewing window. |
---|
524 |
% line(x(filt),y(filt),'Marker','o','Color','w','Tag','Bnd Node #') |
---|
525 |
for i=1:length(filt) |
---|
526 |
h(i)=text(x(filt(i)),y(filt(i)),1,int2str(nlist(filt(i))),... |
---|
527 |
'FontSize',10,... |
---|
528 |
'HorizontalAlignment','center',... |
---|
529 |
'VerticalAlignment','middle',... |
---|
530 |
'Color','w',... |
---|
531 |
'UserData',int2str(nlist(filt(i))),... |
---|
532 |
'Tag','Bnd Node #'); |
---|
533 |
end |
---|
534 |
|
---|
535 |
elseif strcmp(command,'ClearNums') %%% CLEAR BOUNDARY NUMBER TEXT AND MARKERS |
---|
536 |
%%% |
---|
537 |
%%% CLEAR BOUNDARY NUMBER TEXT AND MARKERS |
---|
538 |
%%% |
---|
539 |
if GB_GRID==0 |
---|
540 |
set(GBInfoLine,'String',' Grid not Loaded yet. Use "Load Grid".'); |
---|
541 |
return |
---|
542 |
elseif GB_BND==0 |
---|
543 |
set(GBInfoLine,'String',' Boundary NOT parsed or .bel NOT loaded.'); |
---|
544 |
return |
---|
545 |
end |
---|
546 |
delete(findobj(GBaxes,'Type','text','Tag','Bnd Node #')); |
---|
547 |
delete(findobj(GBaxes,'Type','line','Tag','Bnd Node #')); |
---|
548 |
delete(findobj(GBaxes,'Type','line','Tag','GBNodeMark')); |
---|
549 |
|
---|
550 |
elseif strcmp(command,'KillGenbel') %%% SHUTDOWN GENBEL |
---|
551 |
%%% |
---|
552 |
%%% SHUTDOWN GENBEL |
---|
553 |
%%% |
---|
554 |
clear global AR |
---|
555 |
delete(GBfig); |
---|
556 |
GBOutPutBelFig=findobj(0,'Type','figure','Tag','GBOutPutBelFig'); |
---|
557 |
delete(GBOutPutBelFig); |
---|
558 |
GB_GRID=0; |
---|
559 |
GB_BND=0; |
---|
560 |
|
---|
561 |
elseif strcmp(command,'OutPutBel') %%% OUTPUT CURRENT .bel FILE |
---|
562 |
%%% |
---|
563 |
%%% OUTPUT CURRENT .bel FILE |
---|
564 |
%%% |
---|
565 |
bellist=get(GBaxes,'UserData'); |
---|
566 |
codes=bellist(:,5); |
---|
567 |
|
---|
568 |
if strcmp(option,'SetUp') |
---|
569 |
|
---|
570 |
GBOutPutBelFig = figure('Position',[150 350 500 120],... |
---|
571 |
'NumberTitle','off',... |
---|
572 |
'Name','Output Current .bel List',... |
---|
573 |
'HandleVisibility','on',... |
---|
574 |
'Tag','GBOutPutBelFig'); |
---|
575 |
|
---|
576 |
GBOutPutBelAxes=axes('Units','normalized',... |
---|
577 |
'Position',[0 0 1 1],... |
---|
578 |
'Visible','off'); |
---|
579 |
|
---|
580 |
|
---|
581 |
no_codes=find(codes==0); |
---|
582 |
if ~isempty(no_codes) |
---|
583 |
axes(GBOutPutBelAxes); |
---|
584 |
text('Position',[.05 .8],'HorizontalAlignment','Left',... |
---|
585 |
'String','There are boundary segments with no codes assigned.'); |
---|
586 |
text('Position',[.05 .55],'HorizontalAlignment','Left',... |
---|
587 |
'String','Do you want GENBEL to assume island codes ?'); |
---|
588 |
res=[]; |
---|
589 |
BUTTONS(1)=uicontrol(GBOutPutBelFig,'Style','push',... |
---|
590 |
'Units','normalized',... |
---|
591 |
'Position',[.1 .1 .2 .2],... |
---|
592 |
'String','YES',... |
---|
593 |
'Tag','GBYesBut'); |
---|
594 |
BUTTONS(2)=uicontrol(GBOutPutBelFig,'Style','push',... |
---|
595 |
'Units','normalized',... |
---|
596 |
'Position',[.4 .1 .2 .2],... |
---|
597 |
'String','NO',... |
---|
598 |
'Tag','GBNoBut'); |
---|
599 |
for i=1:2 |
---|
600 |
set(BUTTONS(i),'UserData',BUTTONS(:,[1:(i-1),(i+1):2])) |
---|
601 |
end |
---|
602 |
CALLBACK=['me=get(gcf,''CurrentObject'');',... |
---|
603 |
'if(get(me,''Value'')==1),',... |
---|
604 |
'set(get(me,''UserData''),''Value'',0),',... |
---|
605 |
'else,',... |
---|
606 |
'set(me,''Value'',1),',... |
---|
607 |
'end']; |
---|
608 |
set(BUTTONS,'CallBack',CALLBACK); |
---|
609 |
|
---|
610 |
BUTTONS(3)=uicontrol(GBOutPutBelFig,'Style','push',... |
---|
611 |
'Units','normalized',... |
---|
612 |
'Position',[.7 .1 .2 .2],... |
---|
613 |
'String','CANCEL',... |
---|
614 |
'Tag','GBOutPutCancel'); |
---|
615 |
drawnow |
---|
616 |
go=0; |
---|
617 |
while ~go |
---|
618 |
waitforbuttonpress; |
---|
619 |
drawnow |
---|
620 |
if (get(gcf,'CurrentObject')==BUTTONS(1)),res='y';go=1;,end |
---|
621 |
if (get(gcf,'CurrentObject')==BUTTONS(2)),res='n';go=1;,end |
---|
622 |
if (get(gcf,'CurrentObject')==BUTTONS(3)),res='c';go=1;,end |
---|
623 |
if strcmp(res,'c') |
---|
624 |
delete(get(get(gcf,'CurrentObject'),'Parent')) |
---|
625 |
return |
---|
626 |
end |
---|
627 |
end |
---|
628 |
if strcmp(lower(res),'n') |
---|
629 |
axes(GBOutPutBelAxes);deltext |
---|
630 |
text('Position',[.05 .8],'HorizontalAlignment','Left',... |
---|
631 |
'String','Do you STILL want to save [Y/n] ? '); |
---|
632 |
res=[]; |
---|
633 |
go=0; |
---|
634 |
while ~go |
---|
635 |
waitforbuttonpress; |
---|
636 |
drawnow |
---|
637 |
if (get(gcf,'CurrentObject')==BUTTONS(1)),res='y';go=1;,end |
---|
638 |
if (get(gcf,'CurrentObject')==BUTTONS(2)),res='n';go=1;,end |
---|
639 |
if (get(gcf,'CurrentObject')==BUTTONS(3)),res='c';go=1;,end |
---|
640 |
if strcmp(res,'c') |
---|
641 |
delete(get(get(gcf,'CurrentObject'),'Parent')) |
---|
642 |
return |
---|
643 |
end |
---|
644 |
end |
---|
645 |
if strcmp(res,'n') |
---|
646 |
axes(GBOutPutBelAxes);deltext |
---|
647 |
text('Position',[.05 .80],'HorizontalAlignment','Left',... |
---|
648 |
'String','NO SAVE!!'); |
---|
649 |
text('Position',[.05 .55],'HorizontalAlignment','Left',... |
---|
650 |
'String','The boundary segments needing attention are in white.'); |
---|
651 |
delete(BUTTONS); |
---|
652 |
CANCEL=uicontrol(GBOutPutBelFig,'Style','push',... |
---|
653 |
'Units','normalized',... |
---|
654 |
'Position',[.4 .1 .2 .2],... |
---|
655 |
'String','CANCEL',... |
---|
656 |
'Tag','GBOutPutCancel'); |
---|
657 |
CALLBACK=['me=get(gcf,''CurrentObject'');',... |
---|
658 |
'if(strcmp(get(me,''Tag''),''GBOutPutCancel'')),',... |
---|
659 |
'delete(get(me,''Parent''));,end']; |
---|
660 |
set(CANCEL,'CallBack',CALLBACK); |
---|
661 |
return; |
---|
662 |
end |
---|
663 |
else |
---|
664 |
bellist(no_codes,5)=2*ones(size(no_codes)); |
---|
665 |
genbel4('PlotBnd') |
---|
666 |
end |
---|
667 |
end |
---|
668 |
set(GBaxes,'UserData',bellist); |
---|
669 |
|
---|
670 |
figure(GBOutPutBelFig);clf |
---|
671 |
|
---|
672 |
uicontrol('Parent',GBOutPutBelFig,... |
---|
673 |
'BackgroundColor',[0;0;0],... |
---|
674 |
'ForegroundColor',[1;1;1],... |
---|
675 |
'Style','text',... |
---|
676 |
'String','Enter Domain Name : ',... |
---|
677 |
'Units','normalized',... |
---|
678 |
'Position',[.025 .7 .3 .15],... |
---|
679 |
'HorizontalAlignment','left'); |
---|
680 |
gnameUI=uicontrol('Parent',GBOutPutBelFig,... |
---|
681 |
'ForegroundColor',[1;0;0],... |
---|
682 |
'Style','edit',... |
---|
683 |
'String','<gridname>',... |
---|
684 |
'Units','normalized',... |
---|
685 |
'Position',[.35 .7 .25 .15],... |
---|
686 |
'Tag','GBOPgnameUI'); |
---|
687 |
uicontrol('Parent',GBOutPutBelFig,... |
---|
688 |
'BackgroundColor',[0;0;0],... |
---|
689 |
'ForegroundColor',[1;1;1],... |
---|
690 |
'Style','text',... |
---|
691 |
'String','Enter Comment Line : ',... |
---|
692 |
'Units','normalized',... |
---|
693 |
'Position',[.025 .4 .3 .15],... |
---|
694 |
'HorizontalAlignment','left'); |
---|
695 |
commentUI=uicontrol('Parent',GBOutPutBelFig,... |
---|
696 |
'ForegroundColor',[1;0;0],... |
---|
697 |
'Style','edit',... |
---|
698 |
'String','<Comment Line>',... |
---|
699 |
'Units','normalized',... |
---|
700 |
'Position',[.35 .4 .55 .15],... |
---|
701 |
'Tag','GBOPcommentUI'); |
---|
702 |
uicontrol('Parent',GBOutPutBelFig,... |
---|
703 |
'BackgroundColor',[0;0;0],... |
---|
704 |
'ForegroundColor',[1;1;1],... |
---|
705 |
'Style','text',... |
---|
706 |
'String','Enter .bel Filename : ',... |
---|
707 |
'Units','normalized',... |
---|
708 |
'Position',[.025 .1 .3 .15],... |
---|
709 |
'HorizontalAlignment','left'); |
---|
710 |
fnameUI=uicontrol('Parent',GBOutPutBelFig,... |
---|
711 |
'ForegroundColor',[1;0;0],... |
---|
712 |
'Style','edit',... |
---|
713 |
'String','temp.bel',... |
---|
714 |
'Units','normalized',... |
---|
715 |
'Position',[.35 .1 .3 .15],... |
---|
716 |
'CallBack','genbel4(''OutPutBel'',''write'')',... |
---|
717 |
'Tag','GBOPfnameUI'); |
---|
718 |
uicontrol('Parent',GBOutPutBelFig,... |
---|
719 |
'ForegroundColor',[0 1 0],... |
---|
720 |
'Style','push',... |
---|
721 |
'String','SUBMIT',... |
---|
722 |
'Units','normalized',... |
---|
723 |
'Position',[.77 .1 .19 .15],... |
---|
724 |
'CallBack','genbel4(''OutPutBel'',''writebcs'')'); |
---|
725 |
temp=uicontrol('Parent',GBOutPutBelFig,... |
---|
726 |
'ForegroundColor',[1 0 0],... |
---|
727 |
'Style','push',... |
---|
728 |
'String','CANCEL',... |
---|
729 |
'Units','normalized',... |
---|
730 |
'Position',[.77 .7 .19 .15],... |
---|
731 |
'Tag','GBOutPutCancel'); |
---|
732 |
CALLBACK=['me=get(gcf,''CurrentObject'');',... |
---|
733 |
'if(strcmp(get(me,''Tag''),''GBOutPutCancel'')),',... |
---|
734 |
'delete(get(me,''Parent''));,end']; |
---|
735 |
set(temp,'CallBack',CALLBACK); |
---|
736 |
uicontrol('Parent',GBOutPutBelFig,... |
---|
737 |
'ForegroundColor',[1 1 0],... |
---|
738 |
'Style','push',... |
---|
739 |
'String','Quoddy',... |
---|
740 |
'Units','normalized',... |
---|
741 |
'Position',[.61 .7 .15 .15],... |
---|
742 |
'Tag','GBOutPutModType',... |
---|
743 |
'Callback','genbel4(''OutPutBel'',''modtype'')',... |
---|
744 |
'UserData','Quoddy'); |
---|
745 |
|
---|
746 |
elseif strcmp(option,'writebcs') |
---|
747 |
|
---|
748 |
GBOutPutBelFig=findobj(0,'Type','figure','Tag','GBOutPutBelFig'); |
---|
749 |
|
---|
750 |
% Determine model output type |
---|
751 |
|
---|
752 |
GBOutPutModType=findobj(GBOutPutBelFig,'Type','uicontrol','Tag','GBOutPutModType'); |
---|
753 |
modtype=get(GBOutPutModType,'UserData'); |
---|
754 |
|
---|
755 |
GBOPgnameUI=findobj(GBOutPutBelFig,'Type','uicontrol','Tag','GBOPgnameUI'); |
---|
756 |
gname=get(GBOPgnameUI,'String'); |
---|
757 |
GBOPcommentUI=findobj(GBOutPutBelFig,'Type','uicontrol','Tag','GBOPcommentUI'); |
---|
758 |
comment=get(GBOPcommentUI,'String'); |
---|
759 |
GBOPfnameUI=findobj(GBOutPutBelFig,'Type','uicontrol','Tag','GBOPfnameUI'); |
---|
760 |
fname=get(GBOPfnameUI,'String'); |
---|
761 |
|
---|
762 |
fid=fopen(fname,'w'); |
---|
763 |
|
---|
764 |
% Output segment for Fundy model |
---|
765 |
if strcmp(modtype,'Fundy') |
---|
766 |
bcs=zeros(size(x)); |
---|
767 |
bcs(bellist(:,2))=bellist(:,5); |
---|
768 |
for i=1:length(x) |
---|
769 |
fprintf(fid,'%1d\n',bcs(i)); |
---|
770 |
end |
---|
771 |
else |
---|
772 |
set(GBInfoLine,'String',' Sorting final .bel list by code...') |
---|
773 |
% Order boundary list, exterior, then islands |
---|
774 |
% Find western-most node number with non-island code |
---|
775 |
|
---|
776 |
newbellist=NaN*ones(size(bellist)); |
---|
777 |
tempbellist=bellist; % temp list to delete from |
---|
778 |
iland=find(bellist(:,5)~=2); % get all non-island nodes |
---|
779 |
ns=bnd(:,1); |
---|
780 |
ne=bnd(:,2); |
---|
781 |
ie=[ns(:);ne(:)]; |
---|
782 |
x=x(ie); |
---|
783 |
[minx,iminx]=min(x); |
---|
784 |
iminx=iminx(1); % just in case there's more than one. |
---|
785 |
count=1; |
---|
786 |
newbellist(count,:)=tempbellist(iminx,:); |
---|
787 |
tempbellist(iminx,:)=[]; |
---|
788 |
for i=1:length(iland)-1 |
---|
789 |
idx=find(tempbellist(:,2)==newbellist(count,3)); % Gather up the 1 exterior bndy |
---|
790 |
count=count+1; |
---|
791 |
newbellist(count,:)=tempbellist(idx,:); |
---|
792 |
tempbellist(idx,:)=[]; |
---|
793 |
end |
---|
794 |
|
---|
795 |
if count<length(bellist) % No islands to find. |
---|
796 |
% The remaining lines in tempbellist are island codes |
---|
797 |
itest=find(tempbellist(:,5)~=2); |
---|
798 |
if ~isempty(itest) |
---|
799 |
error('nonland code found in land bel section; fatal') |
---|
800 |
end |
---|
801 |
idx=1; |
---|
802 |
istart=tempbellist(idx,3); % Beginning of first island |
---|
803 |
% insert first island code into new bel list, and delete it from tempbellist. |
---|
804 |
count=count+1; |
---|
805 |
newbellist(count,:)=tempbellist(idx,:); |
---|
806 |
tempbellist(idx,:)=[]; |
---|
807 |
while length(tempbellist) % AS long as there are still nodes |
---|
808 |
itemp=find(tempbellist(:,2)==istart); % tempbellist |
---|
809 |
if ~isempty(itemp) |
---|
810 |
count=count+1; |
---|
811 |
newbellist(count,:)=tempbellist(itemp,:); |
---|
812 |
tempbellist(itemp,:)=[]; |
---|
813 |
istart=newbellist(count,3); |
---|
814 |
else |
---|
815 |
if count ==length(bellist) % We've accounted for all the bel nodes |
---|
816 |
break |
---|
817 |
end |
---|
818 |
istart=tempbellist(1,3); % Else, set the new first island node. |
---|
819 |
end |
---|
820 |
end |
---|
821 |
end |
---|
822 |
|
---|
823 |
bellist=newbellist; |
---|
824 |
fprintf(fid,'%s\n',gname); |
---|
825 |
fprintf(fid,'%s\n',comment); |
---|
826 |
for i=1:length(bellist(:,1)) |
---|
827 |
fprintf(fid,'%d %d %d %1d %1d\n',... |
---|
828 |
bellist(i,1),bellist(i,2),... |
---|
829 |
bellist(i,3),bellist(i,4),... |
---|
830 |
bellist(i,5)); |
---|
831 |
end |
---|
832 |
end |
---|
833 |
fclose(fid); |
---|
834 |
set(GBInfoLine,'String',' Done!!') |
---|
835 |
|
---|
836 |
delete(GBOutPutBelFig); |
---|
837 |
elseif strcmp(option,'modtype') |
---|
838 |
GBOutPutBelFig=findobj(0,'Type','figure','Tag','GBOutPutBelFig'); |
---|
839 |
GBOutPutModType=findobj(GBOutPutBelFig,'Type','uicontrol','Tag','GBOutPutModType'); |
---|
840 |
modtype=get(GBOutPutModType,'UserData'); |
---|
841 |
if strcmp(modtype,'Quoddy') |
---|
842 |
set(GBOutPutModType,'String','Fundy') |
---|
843 |
set(GBOutPutModType,'UserData','Fundy') |
---|
844 |
else |
---|
845 |
set(GBOutPutModType,'String','Quoddy') |
---|
846 |
set(GBOutPutModType,'UserData','Quoddy') |
---|
847 |
end |
---|
848 |
end |
---|
849 |
|
---|
850 |
elseif strcmp(command,'Connect') %%% CONNECT CURRENT BND END-POINTS |
---|
851 |
%%% |
---|
852 |
%%% CONNECT CURRENT BND END-POINTS |
---|
853 |
%%% |
---|
854 |
|
---|
855 |
% Make sure starting and ending nodes have been defined |
---|
856 |
% |
---|
857 |
GBStartingNN=findobj(GBfig,'Type','uicontrol','Tag','GBStartingNN'); |
---|
858 |
GBEndingNN=findobj(GBfig,'Type','uicontrol','Tag','GBEndingNN'); |
---|
859 |
startingnn=get(GBStartingNN,'String'); |
---|
860 |
endingnn=get(GBEndingNN,'String'); |
---|
861 |
if strcmp(startingnn,'<enter>')|strcmp(endingnn,'<enter>'),return,end |
---|
862 |
strnn=eval(startingnn); |
---|
863 |
endnn=eval(endingnn); |
---|
864 |
|
---|
865 |
% Make sure chosen numbers are in the boundary list; |
---|
866 |
% |
---|
867 |
if ~(find(bnd(:,1)==strnn)) |
---|
868 |
disp('Starting number not found in BND list') |
---|
869 |
end |
---|
870 |
if ~(find(bnd(:,1)==endnn)) |
---|
871 |
disp('Ending number not found in BND list') |
---|
872 |
end |
---|
873 |
|
---|
874 |
code_string=str2mat('land',... |
---|
875 |
'nonzero_norm_vel',... |
---|
876 |
'geostrophic_outflow',... |
---|
877 |
'elevation'); |
---|
878 |
code_color=['w','r','b','y','c','g']; |
---|
879 |
|
---|
880 |
% Determine boundary type selected |
---|
881 |
% |
---|
882 |
bndtype=genbel4('WhichBndType'); |
---|
883 |
if bndtype==0 |
---|
884 |
disp(' '); |
---|
885 |
disp('No boundary type selected.') |
---|
886 |
disp(' '); |
---|
887 |
return |
---|
888 |
end |
---|
889 |
|
---|
890 |
% Get bellist from main axes 'UserData'; replace when done. |
---|
891 |
% |
---|
892 |
bellist=get(GBaxes,'UserData'); |
---|
893 |
|
---|
894 |
% Connect the Dots (Starting NN to Ending NN CCW!!) |
---|
895 |
% Since the boundary is connected in CCW order, the list of boundary |
---|
896 |
% segments must be oriented with the interior of the domain to the |
---|
897 |
% left-hand side of the segment. This is what 'HashBnd' does. |
---|
898 |
% |
---|
899 |
connected=0; |
---|
900 |
nextnn=strnn; |
---|
901 |
oldpt=get(GBfig,'Pointer'); |
---|
902 |
set(GBfig,'Pointer','watch'); |
---|
903 |
set(GBInfoLine,'String',' Connecting Start to End NN, CCW ...'); |
---|
904 |
drawnow |
---|
905 |
plt_list=[]; |
---|
906 |
code_lst=[]; |
---|
907 |
while ~connected |
---|
908 |
connr=bnd(find(bnd(:,1)==nextnn),2); |
---|
909 |
plt_list=[plt_list |
---|
910 |
x(nextnn) x(connr) y(nextnn) y(connr)]; |
---|
911 |
% Insert new code into bellist |
---|
912 |
idx=find(bnd(:,1)==nextnn); |
---|
913 |
code_lst=[code_lst |
---|
914 |
idx]; |
---|
915 |
if connr==endnn |
---|
916 |
connected=1; |
---|
917 |
end |
---|
918 |
nextnn=connr; |
---|
919 |
end |
---|
920 |
|
---|
921 |
% Plot boundary segment in its corresponding color and |
---|
922 |
% edit bellist accordingly. |
---|
923 |
% |
---|
924 |
line([plt_list(:,1) plt_list(:,2)],[plt_list(:,3) plt_list(:,4)],... |
---|
925 |
'LineStyle','-',... |
---|
926 |
'Color',code_color(bndtype+1)); |
---|
927 |
bellist(code_lst,5)=bndtype*ones(size(code_lst)); |
---|
928 |
set(GBfig,'Pointer',oldpt) |
---|
929 |
|
---|
930 |
% Replace bellist |
---|
931 |
% |
---|
932 |
set(GBaxes,'UserData',bellist); |
---|
933 |
|
---|
934 |
% Reset connecting mode |
---|
935 |
% |
---|
936 |
genbel4('ClearNums'); |
---|
937 |
GBConnectBut=findobj(GBfig,'Type','uicontrol','Tag','GBConnectBut'); |
---|
938 |
set(GBConnectBut,'BackGroundColor','r','Enable','off'); |
---|
939 |
|
---|
940 |
% Set Boundary Type buttons to 0 |
---|
941 |
% |
---|
942 |
btb(1)=findobj(GBfig,'Type','uicontrol','Tag','GBLandBut'); |
---|
943 |
btb(2)=findobj(GBfig,'Type','uicontrol','Tag','GBIslandBut'); |
---|
944 |
btb(3)=findobj(GBfig,'Type','uicontrol','Tag','GBNon-0NormBut'); |
---|
945 |
btb(4)=findobj(GBfig,'Type','uicontrol','Tag','GBGeosT.OutBut'); |
---|
946 |
btb(5)=findobj(GBfig,'Type','uicontrol','Tag','GBElevationBut'); |
---|
947 |
set(btb,'Value',0) |
---|
948 |
|
---|
949 |
set(GBInfoLine,'String',' Enter Starting and Ending NN to connect') |
---|
950 |
|
---|
951 |
elseif strcmp(command,'PlotBnd') %%% PLOT BND IN COLORS ACC. BND TYPE |
---|
952 |
%%% |
---|
953 |
%%% PLOT BND IN COLORS ACCORDING TO BND TYPE |
---|
954 |
%%% |
---|
955 |
griddata=get(GBfig,'UserData'); |
---|
956 |
nbnd=griddata(2,6); |
---|
957 |
bnd=griddata(1:nbnd,7:8); |
---|
958 |
|
---|
959 |
bellist=get(GBaxes,'UserData'); |
---|
960 |
codes=bellist(:,5); |
---|
961 |
|
---|
962 |
% no code assigned |
---|
963 |
type0=find(codes==0); |
---|
964 |
% land |
---|
965 |
type1=find(codes==1); |
---|
966 |
%islands |
---|
967 |
type2=find(codes==2); |
---|
968 |
% non0norm |
---|
969 |
type3=find(codes==3); |
---|
970 |
% geostout |
---|
971 |
type4=find(codes==4); |
---|
972 |
% elevation |
---|
973 |
type5=find(codes==5); |
---|
974 |
|
---|
975 |
code_color=['w','r','b','y','c','g']; |
---|
976 |
|
---|
977 |
% Delete Previous Boundary line objects |
---|
978 |
% |
---|
979 |
delete(findobj(GBaxes,'Type','line','Tag','boundary')); |
---|
980 |
|
---|
981 |
% loop over boundary types and plot by color |
---|
982 |
for i=0:5 |
---|
983 |
subseq=eval(['type' int2str(i)]); |
---|
984 |
if ~isempty(subseq) |
---|
985 |
ns=bnd(subseq,1); |
---|
986 |
ne=bnd(subseq,2); |
---|
987 |
X=[x(ns) x(ne) NaN*ones(size(ns))]'; |
---|
988 |
Y=[y(ns) y(ne) NaN*ones(size(ns))]'; |
---|
989 |
X=X(:); |
---|
990 |
Y=Y(:); |
---|
991 |
|
---|
992 |
hboun=line(X,Y,... |
---|
993 |
'Color',code_color(i+1),... |
---|
994 |
'Linestyle','-',... |
---|
995 |
'LineWidth',0.5,... |
---|
996 |
'MarkerSize',6,... |
---|
997 |
'Tag','boundary'); |
---|
998 |
|
---|
999 |
end |
---|
1000 |
end |
---|
1001 |
elseif strcmp(command,'SetUpFig') %%% SET UP GENBEL FIGURE AND GUI |
---|
1002 |
%%% |
---|
1003 |
%%% SET UP GENBEL FIGURE AND GUI |
---|
1004 |
%%% |
---|
1005 |
|
---|
1006 |
% Clobber existing GENBEL figure |
---|
1007 |
% |
---|
1008 |
if ~isempty(GBfig),close(GBfig),end |
---|
1009 |
|
---|
1010 |
% Set up operations GUI Menus |
---|
1011 |
% |
---|
1012 |
GBfig=figure('Tag','GBMainFig',... |
---|
1013 |
'Resize','off',... |
---|
1014 |
'Position',[600 350 625 650],... |
---|
1015 |
'NumberTitle','off',... |
---|
1016 |
'Name','GENerate Boundary ELement file'); |
---|
1017 |
|
---|
1018 |
% Create main Axes |
---|
1019 |
% |
---|
1020 |
GBaxes=axes('Tag','GBMainAx','Position',[.075 .10 .875 .55]); |
---|
1021 |
|
---|
1022 |
% Create small frame for info lines at bottom of figure |
---|
1023 |
% |
---|
1024 |
frmuinfo=uicontrol(GBfig,'Style','frame',... |
---|
1025 |
'Units','normalized',... |
---|
1026 |
'Position',[0.0 0.0 1. .05]); |
---|
1027 |
GBinfo=uicontrol(GBfig,'Style','text',... |
---|
1028 |
'Units','normalized',... |
---|
1029 |
'Position',[.01 .005 .1 .04],... |
---|
1030 |
'String','GB Info:',... |
---|
1031 |
'Tag','GBInfoText',... |
---|
1032 |
'BackGroundColor','w'); |
---|
1033 |
GBInfoLine=uicontrol(GBfig,'Style','text',... |
---|
1034 |
'Units','normalized',... |
---|
1035 |
'Position',[.12 .005 .84 .04],... |
---|
1036 |
'String',' Load a Grid with "Load Grid"',... |
---|
1037 |
'Tag','GBInfoLine',... |
---|
1038 |
'HorizontalAlignment','Left',... |
---|
1039 |
'BackGroundColor','w'); |
---|
1040 |
GBHelpBut=uicontrol(GBfig,'Style','push',... |
---|
1041 |
'Units','normalized',... |
---|
1042 |
'Position',[.90 .005 .1 .04],... |
---|
1043 |
'String','HELP',... |
---|
1044 |
'Tag','GBHelpBut',... |
---|
1045 |
'HorizontalAlignment','center',... |
---|
1046 |
'Enable','on',... |
---|
1047 |
'CallBack','genbel4(''Help'')'); |
---|
1048 |
|
---|
1049 |
% Create big frame for buttons |
---|
1050 |
% |
---|
1051 |
frmuimain=uicontrol(GBfig,'Style','frame',... |
---|
1052 |
'Units','normalized',... |
---|
1053 |
'Position',[0.0 0.7 1. .3]); |
---|
1054 |
|
---|
1055 |
% Create 'Boundary Type' label and Radio buttons |
---|
1056 |
% |
---|
1057 |
txtui(1)=uicontrol(GBfig,'Style','text',... |
---|
1058 |
'Units','normalized',... |
---|
1059 |
'Position',[.04 .95 .18 .04],... |
---|
1060 |
'String','Click on'); |
---|
1061 |
txtui(1)=uicontrol(GBfig,'Style','text',... |
---|
1062 |
'Units','normalized',... |
---|
1063 |
'Position',[.04 .91 .18 .04],... |
---|
1064 |
'String','Boundary Type'); |
---|
1065 |
btbpos=[.01 .87 .24 .04 |
---|
1066 |
.01 .83 .24 .04 |
---|
1067 |
.01 .79 .24 .04 |
---|
1068 |
.01 .75 .24 .04 |
---|
1069 |
.01 .71 .24 .04]; |
---|
1070 |
|
---|
1071 |
code_color=['w','r','b','y','c','g']; |
---|
1072 |
|
---|
1073 |
btb(1)=uicontrol(GBfig,'Style','Radio',... |
---|
1074 |
'Units','normalized',... |
---|
1075 |
'Position',btbpos(1,:),... |
---|
1076 |
'String','Land (1)',... |
---|
1077 |
'Value',0,... |
---|
1078 |
'Tag','GBLandBut',... |
---|
1079 |
'BackGroundColor','r',... |
---|
1080 |
'HorizontalAlignment','left'); |
---|
1081 |
btb(2)=uicontrol(GBfig,'Style','Radio',... |
---|
1082 |
'Units','normalized',... |
---|
1083 |
'Position',btbpos(2,:),... |
---|
1084 |
'String','Island (2)',... |
---|
1085 |
'Value',0,... |
---|
1086 |
'Tag','GBIslandBut',... |
---|
1087 |
'BackGroundColor','b',... |
---|
1088 |
'ForeGroundColor','w',... |
---|
1089 |
'HorizontalAlignment','left'); |
---|
1090 |
btb(3)=uicontrol(GBfig,'Style','Radio',... |
---|
1091 |
'Units','normalized',... |
---|
1092 |
'Position',btbpos(3,:),... |
---|
1093 |
'String','Non-0 Norm (3)',... |
---|
1094 |
'Value',0,... |
---|
1095 |
'Tag','GBNon-0NormBut',... |
---|
1096 |
'BackGroundColor','y',... |
---|
1097 |
'HorizontalAlignment','left'); |
---|
1098 |
btb(4)=uicontrol(GBfig,'Style','Radio',... |
---|
1099 |
'Units','normalized',... |
---|
1100 |
'Position',btbpos(4,:),... |
---|
1101 |
'String','GeosT. Out (4)',... |
---|
1102 |
'Value',0,... |
---|
1103 |
'Tag','GBGeosT.OutBut',... |
---|
1104 |
'BackGroundColor','c',... |
---|
1105 |
'HorizontalAlignment','left'); |
---|
1106 |
btb(5)=uicontrol(GBfig,'Style','Radio',... |
---|
1107 |
'Units','normalized',... |
---|
1108 |
'Position',btbpos(5,:),... |
---|
1109 |
'String','Elevation (5)',... |
---|
1110 |
'Value',0,... |
---|
1111 |
'Tag','GBElevationBut',... |
---|
1112 |
'BackGroundColor','g',... |
---|
1113 |
'HorizontalAlignment','left'); |
---|
1114 |
|
---|
1115 |
for i=1:5 |
---|
1116 |
set(btb(i),'UserData',btb(:,[1:(i-1),(i+1):5])) |
---|
1117 |
end |
---|
1118 |
CALL1=['me=get(gcf,''CurrentObject'');',... |
---|
1119 |
'if(get(me,''Value'')==1),',... |
---|
1120 |
'set(get(me,''UserData''),''Value'',0),',... |
---|
1121 |
'genbel4(''Check2''),',... |
---|
1122 |
'else,',... |
---|
1123 |
'set(me,''Value'',1),',... |
---|
1124 |
'end']; |
---|
1125 |
set(btb,'CallBack',CALL1); |
---|
1126 |
|
---|
1127 |
% UI for Starting node number |
---|
1128 |
% |
---|
1129 |
txtui(2)=uicontrol(GBfig,'Style','text',... |
---|
1130 |
'Units','normalized',... |
---|
1131 |
'Position',[.25 .95 .15 .04],... |
---|
1132 |
'String','Starting N#'); |
---|
1133 |
stnnui=uicontrol(GBfig,'Style','edit',... |
---|
1134 |
'Units','normalized',... |
---|
1135 |
'Position',[.40 .95 .1 .04],... |
---|
1136 |
'String','<enter>',... |
---|
1137 |
'Tag','GBStartingNN',... |
---|
1138 |
'CallBack','genbel4(''Check1'')'); |
---|
1139 |
% UI for ending node number |
---|
1140 |
% |
---|
1141 |
txtui(3)=uicontrol(GBfig,'Style','text',... |
---|
1142 |
'Units','normalized',... |
---|
1143 |
'Position',[.25 .90 .15 .04],... |
---|
1144 |
'String','Ending N#'); |
---|
1145 |
endnnui=uicontrol(GBfig,'Style','edit',... |
---|
1146 |
'Units','normalized',... |
---|
1147 |
'Position',[.40 .90 .1 .04],... |
---|
1148 |
'String','<enter>',... |
---|
1149 |
'Tag','GBEndingNN',... |
---|
1150 |
'CallBack','genbel4(''Check2'')'); |
---|
1151 |
switchui=uicontrol(GBfig,'Style','push',... |
---|
1152 |
'Units','normalized',... |
---|
1153 |
'Position',[.40 .850 .1 .04],... |
---|
1154 |
'String','SWITCH',... |
---|
1155 |
'Tag','GBSWITCHNN',... |
---|
1156 |
'CallBack','genbel4(''Switch'')'); |
---|
1157 |
|
---|
1158 |
% Place buttons on UI FRAME |
---|
1159 |
% |
---|
1160 |
ConnectBut=uicontrol(GBfig,'Style','Push',... |
---|
1161 |
'Units','normalized',... |
---|
1162 |
'Position',[.6 .94 .15 .04],... |
---|
1163 |
'String','Connect',... |
---|
1164 |
'Callback','genbel4(''Connect'')',... |
---|
1165 |
'BackGroundColor','r',... |
---|
1166 |
'Tag','GBConnectBut','Enable','off'); |
---|
1167 |
|
---|
1168 |
MarkBndBut=uicontrol(GBfig,'Style','Push',... |
---|
1169 |
'Units','normalized',... |
---|
1170 |
'Position',[.6 .83 .15 .04],... |
---|
1171 |
'String','Mark Bnd',... |
---|
1172 |
'Callback','genbel4(''Markbnd'')',... |
---|
1173 |
'Tag','GBMarkBndBut'); |
---|
1174 |
NumBndBut=uicontrol(GBfig,'Style','Push',... |
---|
1175 |
'Units','normalized',... |
---|
1176 |
'Position',[.6 .79 .15 .04],... |
---|
1177 |
'String','Number Bnd',... |
---|
1178 |
'Callback','genbel4(''Numbnd'')',... |
---|
1179 |
'Tag','GBNumBndBut'); |
---|
1180 |
ClrNumBut=uicontrol(GBfig,'Style','Push',... |
---|
1181 |
'Units','normalized',... |
---|
1182 |
'Position',[.6 .75 .15 .04],... |
---|
1183 |
'String','Clr Marks',... |
---|
1184 |
'Callback','genbel4(''ClearNums'')',... |
---|
1185 |
'Tag','GBClrNumBut'); |
---|
1186 |
ClrCodesBut=uicontrol(GBfig,'Style','Push',... |
---|
1187 |
'Units','normalized',... |
---|
1188 |
'Position',[.6 .71 .15 .04],... |
---|
1189 |
'String','Clr Codes',... |
---|
1190 |
'Callback','genbel4(''ClearCodes'')',... |
---|
1191 |
'Tag','GBClrCodesBut'); |
---|
1192 |
|
---|
1193 |
LoadGridBut=uicontrol(GBfig,'Style','Push',... |
---|
1194 |
'Units','normalized',... |
---|
1195 |
'Position',[.835 .94 .15 .04],... |
---|
1196 |
'String','Load Grid',... |
---|
1197 |
'Callback','genbel4(''LoadGrid'',''no_opt'')',... |
---|
1198 |
'Tag','GBLoadGridBut'); |
---|
1199 |
LoadBelBut=uicontrol(GBfig,'Style','Push',... |
---|
1200 |
'Units','normalized',... |
---|
1201 |
'Position',[.835 .90 .15 .04],... |
---|
1202 |
'String','Load Bel',... |
---|
1203 |
'Callback','genbel4(''LoadBel'')',... |
---|
1204 |
'Enable','off','Tag','GBLoadBelBut'); |
---|
1205 |
HashBndBut=uicontrol(GBfig,'Style','Push',... |
---|
1206 |
'Units','normalized',... |
---|
1207 |
'Position',[.835 .86 .15 .04],... |
---|
1208 |
'String','New Bel',... |
---|
1209 |
'Callback','genbel4(''HashBnd'')',... |
---|
1210 |
'Enable','off','Tag','GBHashBndBut'); |
---|
1211 |
OutputBut=uicontrol(GBfig,'Style','Push',... |
---|
1212 |
'Units','normalized',... |
---|
1213 |
'Position',[.835 .82 .15 .04],... |
---|
1214 |
'String','Output Bel',... |
---|
1215 |
'Callback','genbel4(''OutPutBel'',''SetUp'')',... |
---|
1216 |
'Enable','off','Tag','GBOutputBelBut'); |
---|
1217 |
ClearAllBut=uicontrol(GBfig,'Style','Push',... |
---|
1218 |
'Units','normalized',... |
---|
1219 |
'Position',[.835 .75 .15 .04],... |
---|
1220 |
'String','Clear All',... |
---|
1221 |
'Callback','genbel4(''ClearAll'')',... |
---|
1222 |
'Enable','on','Tag','GBClearAll'); |
---|
1223 |
KillBut=uicontrol(GBfig,'Style','Push',... |
---|
1224 |
'Units','normalized',... |
---|
1225 |
'Position',[.835 .71 .15 .04],... |
---|
1226 |
'String','Kill (No Save)',... |
---|
1227 |
'Callback','genbel4(''KillGenbel'')',... |
---|
1228 |
'Enable','on','Tag','GBKillBut'); |
---|
1229 |
|
---|
1230 |
AxisEq=uicontrol(GBfig,'Style','Push',... |
---|
1231 |
'Units','normalized',... |
---|
1232 |
'Position',[.35 .79 .175 .04],... |
---|
1233 |
'String','Axis Equal',... |
---|
1234 |
'Callback','genbel4(''SetAxis'')',... |
---|
1235 |
'Tag','GBAxisEq'); |
---|
1236 |
ZoomBut=uicontrol(GBfig,'Style','radio',... |
---|
1237 |
'Units','normalized',... |
---|
1238 |
'Position',[.35 .75 .175 .04],... |
---|
1239 |
'String','ZOOM OFF',... |
---|
1240 |
'Callback','genbel4(''Zoom'')',... |
---|
1241 |
'Tag','GBZoomBut'); |
---|
1242 |
PanBut=uicontrol(GBfig,'Style','radio',... |
---|
1243 |
'Units','normalized',... |
---|
1244 |
'Position',[.35 .71 .175 .04],... |
---|
1245 |
'String','PAN OFF',... |
---|
1246 |
'Callback','genbel4(''Pan'')',... |
---|
1247 |
'Tag','GBPanBut'); |
---|
1248 |
% Define Button-down events |
---|
1249 |
% |
---|
1250 |
genbel4('Def_buttons'); |
---|
1251 |
|
---|
1252 |
elseif strcmp(command,'Switch') %%% SWITCH STARTING AND ENDING NUMBERS |
---|
1253 |
%%% |
---|
1254 |
%%% SWITCH STARTING AND ENDING NUMBERS |
---|
1255 |
%%% |
---|
1256 |
% Retrieve starting and ending nodes and switch |
---|
1257 |
% |
---|
1258 |
GBStartingNN=findobj(GBfig,'Type','uicontrol','Tag','GBStartingNN'); |
---|
1259 |
GBEndingNN=findobj(GBfig,'Type','uicontrol','Tag','GBEndingNN'); |
---|
1260 |
startingnn=get(GBStartingNN,'String'); |
---|
1261 |
endingnn=get(GBEndingNN,'String'); |
---|
1262 |
if strcmp(startingnn,'<enter>')|strcmp(endingnn,'<enter>'),return,end |
---|
1263 |
set(GBStartingNN,'String',endingnn); |
---|
1264 |
set(GBEndingNN,'String',startingnn); |
---|
1265 |
|
---|
1266 |
elseif strcmp(command,'Markbnd') %%% MARK BND WITH INVIS TEXT and .'s |
---|
1267 |
%%% |
---|
1268 |
%%% MARK BND WITH INVISIBLE TEXT and VISIBLE LARGE .'s |
---|
1269 |
%%% |
---|
1270 |
if GB_GRID==0 |
---|
1271 |
set(GBInfoLine,'String',' Grid not Loaded yet. Use "Load Grid".'); |
---|
1272 |
return |
---|
1273 |
elseif GB_BND==0 |
---|
1274 |
set(GBInfoLine,'String',' Boundary NOT parsed or .bel NOT loaded.'); |
---|
1275 |
return |
---|
1276 |
end |
---|
1277 |
|
---|
1278 |
bellist=get(GBaxes,'UserData'); |
---|
1279 |
codes=bellist(:,5); |
---|
1280 |
|
---|
1281 |
% Delete previous node numbering text objs |
---|
1282 |
% |
---|
1283 |
delete(findobj(GBaxes,'Tag','Bnd Node #')); |
---|
1284 |
|
---|
1285 |
X=get(GBaxes,'XLim'); |
---|
1286 |
Y=get(GBaxes,'YLim'); |
---|
1287 |
|
---|
1288 |
ns=bnd(:,1); |
---|
1289 |
ne=bnd(:,2); |
---|
1290 |
x=x(ns); |
---|
1291 |
y=y(ns); |
---|
1292 |
nlist=bnd(:,1); |
---|
1293 |
|
---|
1294 |
% get indices of nodes within viewing window defined by X,Y |
---|
1295 |
filt=find(x>=X(1)&x<=X(2)&y>=Y(1)&y<=Y(2)); |
---|
1296 |
|
---|
1297 |
code_color=['w','r','b','y','c','g']; |
---|
1298 |
|
---|
1299 |
% label only those nodes that lie within viewing window. |
---|
1300 |
for i=1:length(filt) |
---|
1301 |
line(x(filt(i)),y(filt(i)),.5,... |
---|
1302 |
'Marker','.',... |
---|
1303 |
'Color',code_color(codes(filt(i))+1),... |
---|
1304 |
'MarkerSize',25,... |
---|
1305 |
'Tag','Bnd Node #',... |
---|
1306 |
'UserData',int2str(nlist(filt(i)))); |
---|
1307 |
end |
---|
1308 |
|
---|
1309 |
elseif strcmp(command,'ClearAll') %%% CLEAR CURRENT GRID AND .bel LIST |
---|
1310 |
%%% |
---|
1311 |
%%% CLEAR CURRENT GRID AND .bel LIST AND RESET AXIS |
---|
1312 |
%%% |
---|
1313 |
cla |
---|
1314 |
axis('auto') |
---|
1315 |
set(GBfig,'UserData',[]); |
---|
1316 |
set(GBaxes,'UserData',[]); |
---|
1317 |
GBLoadBelBut=findobj(GBfig,'Type','uicontrol','Tag','GBLoadBelBut'); |
---|
1318 |
GBHashBndBut=findobj(GBfig,'Type','uicontrol','Tag','GBHashBndBut'); |
---|
1319 |
GBOutputBelBut=findobj(GBfig,'Type','uicontrol','Tag','GBOutputBelBut'); |
---|
1320 |
set([GBLoadBelBut GBHashBndBut GBOutputBelBut],'Enable','off'); |
---|
1321 |
set(GBInfoLine,'String',' Load a Grid with "Load Grid"'); |
---|
1322 |
GB_GRID=0; |
---|
1323 |
GB_BND=0; |
---|
1324 |
GBOutPutBelFig=findobj(0,'Type','figure','Tag','GBOutPutBelFig'); |
---|
1325 |
delete(GBOutPutBelFig); |
---|
1326 |
GBStartingNN=findobj(GBfig,'Type','uicontrol','Tag','GBStartingNN'); |
---|
1327 |
set(GBStartingNN,'String','<enter>'); |
---|
1328 |
GBEndingNN=findobj(GBfig,'Type','uicontrol','Tag','GBEndingNN'); |
---|
1329 |
set(GBEndingNN,'String','<enter>'); |
---|
1330 |
|
---|
1331 |
elseif strcmp(command,'HashBnd') %%% GENERATE BND LIST AND ORIENT LHS |
---|
1332 |
%%% |
---|
1333 |
%%% GENERATE BND LIST AND ORIENT LHS, IF BEL LISR DOES NOT EXIST |
---|
1334 |
%%% |
---|
1335 |
|
---|
1336 |
% Call "Clear Codes" function if a bel list already exists; otherwise, |
---|
1337 |
% compute the list from scratch |
---|
1338 |
if ~isnan(nbnd) |
---|
1339 |
genbel4('ClearCodes') |
---|
1340 |
return |
---|
1341 |
end |
---|
1342 |
|
---|
1343 |
set(GBInfoLine,'String',' Computing Boundary (Ignore "Divide by zero" warnings) ...'); |
---|
1344 |
drawnow |
---|
1345 |
oldpt=get(GBfig,'Pointer'); |
---|
1346 |
set(GBfig,'Pointer','watch'); |
---|
1347 |
|
---|
1348 |
% Compute element-finding arrays |
---|
1349 |
% |
---|
1350 |
belint4(e,x,y); |
---|
1351 |
ineg=el_areas4(e,x,y); |
---|
1352 |
global AR A B T |
---|
1353 |
if ~isempty(ineg) |
---|
1354 |
disp('??? Error using ==> genbel4') |
---|
1355 |
disp('negative element areas detected in element list') |
---|
1356 |
disp('check mesh with trigrid, diagnstcs, or convcodes'); |
---|
1357 |
return |
---|
1358 |
end |
---|
1359 |
|
---|
1360 |
% Determine Boundary list |
---|
1361 |
% |
---|
1362 |
% Form (i,j) connection list from .ele element list |
---|
1363 |
% |
---|
1364 |
i=[e(:,1);e(:,2);e(:,3)]; |
---|
1365 |
j=[e(:,2);e(:,3);e(:,1)]; |
---|
1366 |
|
---|
1367 |
% Form the sparse adjacency matrix and add transpose. |
---|
1368 |
% |
---|
1369 |
n = max(max(i),max(j)); |
---|
1370 |
ICM = sparse(i,j,-1,n,n); |
---|
1371 |
ICM = ICM + ICM'; |
---|
1372 |
|
---|
1373 |
% Consider only the upper part of ICM, since ICM is symmetric |
---|
1374 |
% |
---|
1375 |
ICM=ICM.*triu(ICM); |
---|
1376 |
|
---|
1377 |
% The boundary segments are ICM's with value == 1 |
---|
1378 |
% |
---|
1379 |
ICM=ICM==1; |
---|
1380 |
|
---|
1381 |
% Extract the row,col from new ICM for the boundary list. |
---|
1382 |
% |
---|
1383 |
[ib,jb,s]=find(ICM); |
---|
1384 |
ib=ib(:);jb=jb(:); |
---|
1385 |
|
---|
1386 |
% Sort Col#1 of bnd and permute Col#2 |
---|
1387 |
% |
---|
1388 |
[ib,iperm]=sort(ib); |
---|
1389 |
jb=jb(iperm); |
---|
1390 |
bnd=[ib(:) jb(:)]; |
---|
1391 |
|
---|
1392 |
set(GBInfoLine,'String',' Re-ordering boundary list (this may take a while) ...'); |
---|
1393 |
drawnow |
---|
1394 |
|
---|
1395 |
% The boundary list generated by the above sparse-matrix method |
---|
1396 |
% does not ensure that the "left-hand toward the grid interior" |
---|
1397 |
% convention is maintained. We'll force that part now. Unfortunately, |
---|
1398 |
% this could take a while. However, once this is done for a mesh, it |
---|
1399 |
% need not be done again. An existing .bel file can be loaded; its boundary |
---|
1400 |
% list will necessarily be ordered correctly. |
---|
1401 |
% |
---|
1402 |
|
---|
1403 |
% Compute test points as follows: |
---|
1404 |
% |
---|
1405 |
% Assume that the segments are oriented such that |
---|
1406 |
% the interior of the FEM domain is to the left and then: |
---|
1407 |
% 1) compute boundary line-segment mid-points |
---|
1408 |
% 2) compute slopes of boundary line-segments |
---|
1409 |
% 3) compute normal slopes of boundary line-segments |
---|
1410 |
% 4) compute unit direction vectors of the boundary segment |
---|
1411 |
% from the first node to the second. |
---|
1412 |
% 5) rotate the unit vectors pi/2 CCW, which SHOULD point |
---|
1413 |
% toward the interior, atleast locally. |
---|
1414 |
% 6) test points lie along normal segment direction vectors |
---|
1415 |
% from mid-point. |
---|
1416 |
|
---|
1417 |
% 1) compute boundary line segment mid-points |
---|
1418 |
midp=[x(ib)+(x(jb)-x(ib))/2 y(ib)+(y(jb)-y(ib))/2]; |
---|
1419 |
|
---|
1420 |
% 2) Compute boundary line segment slopes and replace Inf's by 1e10 |
---|
1421 |
slope=(y(jb)-y(ib))./(x(jb)-x(ib)); |
---|
1422 |
idx=find(slope>1e10); |
---|
1423 |
slope(idx)=1e10*ones(size(idx)); |
---|
1424 |
|
---|
1425 |
% 3) Compute perpendicular slopes and replace Inf's by 1e10 |
---|
1426 |
slopeperp=-1./slope; |
---|
1427 |
idx=find(slopeperp>1e10); |
---|
1428 |
slopeperp(idx)=1e10*ones(size(idx)); |
---|
1429 |
|
---|
1430 |
% 4) Compute unit direction vectors |
---|
1431 |
mag=sqrt((x(jb)-x(ib)).*(x(jb)-x(ib))+(y(jb)-y(ib)).*(y(jb)-y(ib))); |
---|
1432 |
UDVx=[x(jb)-x(ib)]./mag; |
---|
1433 |
UDVy=[y(jb)-y(ib)]./mag; |
---|
1434 |
|
---|
1435 |
% 5) rotate vectors; theta=pi/2, so cos terms==0, sin terms==1 |
---|
1436 |
PUDVx=-UDVy; |
---|
1437 |
PUDVy=UDVx; |
---|
1438 |
|
---|
1439 |
% 6) test points are along normal direction vectors eminating |
---|
1440 |
% from the boundary line-segment mid-points. |
---|
1441 |
dxy=sqrt(min(AR))/10; |
---|
1442 |
testx=midp(:,1)+PUDVx*dxy; |
---|
1443 |
testy=midp(:,2)+PUDVy*dxy; |
---|
1444 |
|
---|
1445 |
set(GBInfoLine,'String',' Ignore "Divide by zero" warnings!!') |
---|
1446 |
|
---|
1447 |
% Now, locate elements for each test point. If a point is in the |
---|
1448 |
% domain, an element will be found for it, and the boundary segment |
---|
1449 |
% is oriented correctly. Otherwise, switch the order of the boundary |
---|
1450 |
% segment node numbers. The test points whose corresponding element |
---|
1451 |
% number, as returned by FINDELE, is NaN is a test point from a boundary |
---|
1452 |
% segment in the reverse order. |
---|
1453 |
% |
---|
1454 |
% j=findelemex4(testx,testy,AR,A,B,T); |
---|
1455 |
j=findelemex5(testx,testy,AR,A,B,T); |
---|
1456 |
|
---|
1457 |
irev=find(isnan(j)); |
---|
1458 |
temp=bnd(irev,1); |
---|
1459 |
bnd(irev,1)=bnd(irev,2); |
---|
1460 |
bnd(irev,2)=temp; |
---|
1461 |
|
---|
1462 |
% Resort Col#1 of bnd and permute Col#2, |
---|
1463 |
% just to make it easier to debug |
---|
1464 |
% |
---|
1465 |
ib=bnd(:,1);jb=bnd(:,2); |
---|
1466 |
[ib,iperm]=sort(ib); |
---|
1467 |
jb=jb(iperm); |
---|
1468 |
bnd=[ib(:) jb(:)]; |
---|
1469 |
|
---|
1470 |
% Store bnd list in figure UserData, along with rest of grid |
---|
1471 |
% |
---|
1472 |
temp=get(GBfig,'UserData'); |
---|
1473 |
temp(2,6)=length(bnd); |
---|
1474 |
temp(1:length(bnd),7:8)=bnd; |
---|
1475 |
set(GBfig,'UserData',temp); |
---|
1476 |
|
---|
1477 |
% Create the ".bel" matrix, this will be placed in the main axes |
---|
1478 |
% 'UserData' for later retrieval |
---|
1479 |
% |
---|
1480 |
% 5-columns 1) segment number |
---|
1481 |
% 2) left-hand boundary node number, facing interior |
---|
1482 |
% 3) right-hand boundary node number, facing interior |
---|
1483 |
% 4) code for left of boundary segment; always 0 |
---|
1484 |
% 5) code for right of boundary segment; 1-5 |
---|
1485 |
% |
---|
1486 |
temp=get(GBfig,'UserData'); |
---|
1487 |
nbnd=temp(2,6); |
---|
1488 |
bnd=temp(1:nbnd,7:8); |
---|
1489 |
bellist=zeros(length(bnd),5); |
---|
1490 |
bellist(:,1)=[1:length(bnd)]'; |
---|
1491 |
bellist(:,2)=bnd(:,1); |
---|
1492 |
bellist(:,3)=bnd(:,2); |
---|
1493 |
set(GBaxes,'UserData',bellist); |
---|
1494 |
|
---|
1495 |
% Draw boundary as is, probably with the 'no code assigned' color (white) |
---|
1496 |
% |
---|
1497 |
genbel4('PlotBnd') |
---|
1498 |
|
---|
1499 |
GBOutputBelBut=findobj(GBfig,'Type','uicontrol','Tag','GBOutputBelBut'); |
---|
1500 |
set(GBOutputBelBut,'Enable','on'); |
---|
1501 |
set(GBInfoLine,'String',' Enter Starting and Ending NN to connect (ignore "div by 0" warnings)') |
---|
1502 |
GB_BND=1; |
---|
1503 |
set(GBfig,'Pointer',oldpt); |
---|
1504 |
|
---|
1505 |
elseif strcmp(command,'Help') %%% HELP PAGES |
---|
1506 |
%%% |
---|
1507 |
%%% HELP PAGES |
---|
1508 |
%%% |
---|
1509 |
page1=[]; % Intro and Credits |
---|
1510 |
page2=[]; |
---|
1511 |
page3=[]; |
---|
1512 |
page4=[]; |
---|
1513 |
page5=[]; |
---|
1514 |
% |
---|
1515 |
% COLUMN COUNTERS |
---|
1516 |
% 10 20 30 40 50 60 70 80 |
---|
1517 |
% * * * * * * * * |
---|
1518 |
%2345678901234567890123456789012345678901234567890123456789012345678901234567890 |
---|
1519 |
% PAGE 1 |
---|
1520 |
page1=str2mat(' ',... |
---|
1521 |
' Introduction and Startup: ',... |
---|
1522 |
' ',... |
---|
1523 |
' GENBEL is a mouse-driven interface for creating .bel files',... |
---|
1524 |
' from the domain files .ele and .nod. GENBEL will either',... |
---|
1525 |
' create a .bel file from scratch or load an existing one',... |
---|
1526 |
' for the domain name specified in the .ele and .nod files.',... |
---|
1527 |
' ',... |
---|
1528 |
' At the MATLAB prompt, type "genbel4". The GENBEL4',... |
---|
1529 |
' figure and controls will be generated. At the bottom ,',... |
---|
1530 |
' of the figure there is an "Info" line that usually'); |
---|
1531 |
page1=str2mat(page1,... |
---|
1532 |
' points the user in next direction. Reading these "Help ',... |
---|
1533 |
' Pages" and following those prompts should cover most',... |
---|
1534 |
' problems. The GENBEL4 Help windows are resizable, so',... |
---|
1535 |
' if text hangs off the edge or end, "drag" the window to',... |
---|
1536 |
' a new size.'); |
---|
1537 |
page1=str2mat(page1,... |
---|
1538 |
' ',... |
---|
1539 |
' GENBEL4 was written by:',... |
---|
1540 |
' Brian O. Blanton',... |
---|
1541 |
' OPNML - Curr. in Marine Sciences',... |
---|
1542 |
' 12-7 Venable Hall, CB#3300',... |
---|
1543 |
' UNC-CH, Chapel Hill, NC, 27599-3300',... |
---|
1544 |
' December 1995'); |
---|
1545 |
% PAGE 2 |
---|
1546 |
% 10 20 30 40 50 60 70 80 |
---|
1547 |
% * * * * * * * * |
---|
1548 |
%2345678901234567890123456789012345678901234567890123456789012345678901234567890 |
---|
1549 |
page2=str2mat(' ',... |
---|
1550 |
' Initial Steps: ',... |
---|
1551 |
' ',... |
---|
1552 |
' 1) Load a domain by clicking on the "Load Grid" button.',... |
---|
1553 |
' Navigate to the input files with the "PopUp" file browers.',... |
---|
1554 |
' 2a) If you have an existing .bel file for the domain, ',... |
---|
1555 |
' load it with the "Load Bel" button. Use this even if ',... |
---|
1556 |
' you intend on changing all of the boundary codes. ',... |
---|
1557 |
' 2b) Use the "New Bel" only if you have NO .bel file for a ',... |
---|
1558 |
' domain. This function parses and orders a bnd list '); |
---|
1559 |
page2=str2mat(page2,... |
---|
1560 |
' directly from the element connectivity list and the',... |
---|
1561 |
' re-ordering can take a while if the mesh is >10000',... |
---|
1562 |
' elements.',... |
---|
1563 |
' 3) Click on "Axis Equal" if you want a 1-to-1 aspect ratio.'); |
---|
1564 |
|
---|
1565 |
% PAGE 3 |
---|
1566 |
% 10 20 30 40 50 60 70 80 |
---|
1567 |
% * * * * * * * * |
---|
1568 |
%2345678901234567890123456789012345678901234567890123456789012345678901234567890 |
---|
1569 |
page3=str2mat(' ',... |
---|
1570 |
' Specifying nodes and conditions: ',... |
---|
1571 |
' ',... |
---|
1572 |
' There are 2 ways to specify the starting and ending node',... |
---|
1573 |
' numbers. ',... |
---|
1574 |
' 1) Enter directly into the spaces marked "<enter>"',... |
---|
1575 |
' 2) Navigate to a node-region with the zoom button',... |
---|
1576 |
' and click on "Number Bnd" or "Mark Bnd", and ',... |
---|
1577 |
' then click on the highlighted node itself.'); |
---|
1578 |
page3=str2mat(page3,... |
---|
1579 |
' The left mouse button will enter the number ',... |
---|
1580 |
' into the "Starting NN" field and the middle',... |
---|
1581 |
' mouse button will enter the number into the',... |
---|
1582 |
' "Ending NN" field. Double-clicking with any ',... |
---|
1583 |
' button will clear both fields. You MUST turn ZOOM',... |
---|
1584 |
' off before clicking on a node number. Zoom all the',... |
---|
1585 |
' way out by double-clicking with any button while ',... |
---|
1586 |
' ZOOM is on.'); |
---|
1587 |
page3=str2mat(page3,... |
---|
1588 |
' ',... |
---|
1589 |
' The order in which the starting and ending nodes are',... |
---|
1590 |
' specified MATTERS. GENBEL4 will connect the segments in',... |
---|
1591 |
' CounterClockWise (CCW) order. However, if the numbers',... |
---|
1592 |
' are entered ClockWise, you can re-enter them in reverse',... |
---|
1593 |
' order by clicking on "SWITCH", click on "Connect", and ',... |
---|
1594 |
' the "error" will be over-written.'); |
---|
1595 |
page3=str2mat(page3,... |
---|
1596 |
' ',... |
---|
1597 |
' Next, click on the boundary type to assign the segment.',... |
---|
1598 |
' If all needed parameters have been specified, the "Connect"',... |
---|
1599 |
' button will turn green; click on it to make the connection.',... |
---|
1600 |
' The segment will be re-drawn in a color according to the',... |
---|
1601 |
' color of the "Boundary Type" specification buttons.'); |
---|
1602 |
|
---|
1603 |
% PAGE 4 |
---|
1604 |
% 10 20 30 40 50 60 70 80 |
---|
1605 |
% * * * * * * * * |
---|
1606 |
%2345678901234567890123456789012345678901234567890123456789012345678901234567890 |
---|
1607 |
page4=str2mat(' ',... |
---|
1608 |
' Islands and Outputing the .bel file',... |
---|
1609 |
' ',... |
---|
1610 |
' You do not need to specify "Island" boundary codes',... |
---|
1611 |
' and segments. Complete the outer boundary segments',... |
---|
1612 |
' first and at output time (see below), GENBEL4 will',... |
---|
1613 |
' provide the oportunity to assume ALL remaining ',... |
---|
1614 |
' un-assigned boundary segments are islands. If the ',... |
---|
1615 |
' exterior boundary has been completely accounted for,',... |
---|
1616 |
' THIS WILL BE TRUE!!. If you need to specify an '); |
---|
1617 |
page4=str2mat(page4,... |
---|
1618 |
' island, enter the same number for starting and ending ',... |
---|
1619 |
' points, click on the BLUE Boundary Type bar, and click',... |
---|
1620 |
' on "Connect".'); |
---|
1621 |
page4=str2mat(page4,... |
---|
1622 |
' ',... |
---|
1623 |
' When you are ready to output the current boundary',... |
---|
1624 |
' configuration, click on "Output Bel" and follow the',... |
---|
1625 |
' prompts. See "Data File Standards for the Gulf of',... |
---|
1626 |
' Maine Project", by Christopher E. Naimie, March 29,',... |
---|
1627 |
' 1993, Numerical Methods Laboratory, Thayer School of',... |
---|
1628 |
' Engineering, Dartmouth College, for a discussion of',... |
---|
1629 |
' filetypes and conventions.'); |
---|
1630 |
|
---|
1631 |
|
---|
1632 |
% PAGE 5 |
---|
1633 |
% 10 20 30 40 50 60 70 80 |
---|
1634 |
% * * * * * * * * |
---|
1635 |
%2345678901234567890123456789012345678901234567890123456789012345678901234567890 |
---|
1636 |
page5=str2mat(' ',... |
---|
1637 |
' Other Functions',... |
---|
1638 |
' ',... |
---|
1639 |
' "Clr Marks" clears the node numbers (vis & invis).',... |
---|
1640 |
' "Clear All" clears the current grid and boundary data',... |
---|
1641 |
' from GENBEL4 and is ready to start fresh.',... |
---|
1642 |
' "Kill (No Save)" terminates GENBEL4 with no option to save.',... |
---|
1643 |
' "SWITCH" flips the starting and ending nodes, which ',... |
---|
1644 |
' effectively reverses the order of connection from CW to ',... |
---|
1645 |
' CCW. This is useful if the node numbers were entered ',... |
---|
1646 |
' in the wrong direction.'); |
---|
1647 |
|
---|
1648 |
|
---|
1649 |
figname='GENBEL4 Help'; |
---|
1650 |
ttlstr='GENBEL4 Help Pages'; |
---|
1651 |
helpfun2(figname,ttlstr,page1,page2,page3,page4,page5); |
---|
1652 |
else %%% IF THIS POINT IS EVER REACHED.... |
---|
1653 |
disp('HOLE IN COMMAND SWITCHING') %%% SOMETHING IS TERRIBLY WRONG!!! |
---|
1654 |
disp('HOLE IN COMMAND SWITCHING') |
---|
1655 |
disp('HOLE IN COMMAND SWITCHING') |
---|
1656 |
disp('HOLE IN COMMAND SWITCHING') |
---|
1657 |
end |
---|