1 |
function j=findelem(fem_grid_struct,xylist) |
---|
2 |
%FINDELEM element finding utility |
---|
3 |
% FINDELEM finds the element number for the |
---|
4 |
% current mouse position. FINDELEM prompts |
---|
5 |
% the user to click on the current axes and returns |
---|
6 |
% the element for the "click-on" position, or NaN |
---|
7 |
% if the click is outside the domain. |
---|
8 |
% |
---|
9 |
% Alternatively, a list of horizontal points can |
---|
10 |
% be passed in and a list of element numbers, one for |
---|
11 |
% each input point, will be returned; NaN is returned |
---|
12 |
% for each point outside of the FEM domain. |
---|
13 |
% |
---|
14 |
% In determining which element has been selected, |
---|
15 |
% FINDELEM needs elemental areas and shape functions. |
---|
16 |
% The routines BELINT and EL_AREAS compute these arrays |
---|
17 |
% and add them to a previously created fem_grid_struct. |
---|
18 |
% These two functions MUST be run before FINDELEM will |
---|
19 |
% run. |
---|
20 |
% BELINT is run as: |
---|
21 |
% new_struct=belint(fem_grid_struct); |
---|
22 |
% EL_AREAS is run as: |
---|
23 |
% [new_struct,ineg]=el_areas(fem_grid_struct); |
---|
24 |
% |
---|
25 |
% INPUT : fem_grid_struct - (from LOADGRID, see FEM_GRID_STRUCT) |
---|
26 |
% xylist - points to find elements for [n x 2 double] |
---|
27 |
% |
---|
28 |
% OUTPUT : an element number(s) |
---|
29 |
% |
---|
30 |
% CALL : >> j=findelem(fem_grid_struct) for interactive |
---|
31 |
% OR >> j=findelem(fem_grid_struct,xylist) |
---|
32 |
% |
---|
33 |
% Written by : Brian O. Blanton |
---|
34 |
% Summer 1997 |
---|
35 |
% |
---|
36 |
|
---|
37 |
% VERIFY INCOMING STRUCTURE |
---|
38 |
% |
---|
39 |
if ~is_valid_struct(fem_grid_struct) |
---|
40 |
error(' fem_grid_struct to FINDELEM invalid.') |
---|
41 |
end |
---|
42 |
|
---|
43 |
% Make sure additional needed fields of the fem_grid_struct |
---|
44 |
% have been filled. |
---|
45 |
if ~is_valid_struct2(fem_grid_struct) |
---|
46 |
error(' fem_grid_struct to FINDELEM invalid.') |
---|
47 |
end |
---|
48 |
|
---|
49 |
if exist('xylist') |
---|
50 |
xp=xylist(:,1); |
---|
51 |
yp=xylist(:,2); |
---|
52 |
% line(xp,yp,'LineStyle','.','Marker','+') |
---|
53 |
else |
---|
54 |
disp('Click on element ...'); |
---|
55 |
waitforbuttonpress; |
---|
56 |
Pt=gcp; |
---|
57 |
xp=Pt(2);yp=Pt(4); |
---|
58 |
line(xp,yp,'LineStyle','+') |
---|
59 |
|
---|
60 |
end |
---|
61 |
j=findelemex5(xp,yp,fem_grid_struct.ar,... |
---|
62 |
fem_grid_struct.A,... |
---|
63 |
fem_grid_struct.B,... |
---|
64 |
fem_grid_struct.T); |
---|
65 |
|
---|
66 |
% |
---|
67 |
% Brian O. Blanton |
---|
68 |
% Department of Marine Sciences |
---|
69 |
% Ocean Processes Numerical Modeling Laboratory |
---|
70 |
% 15-1A Venable Hall |
---|
71 |
% CB# 3300 |
---|
72 |
% Uni. of North Carolina |
---|
73 |
% Chapel Hill, NC |
---|
74 |
% 27599-3300 |
---|
75 |
% |
---|
76 |
% 919-962-4466 |
---|
77 |
% blanton@marine.unc.edu |
---|
78 |
% |
---|
79 |
% Summer 1997 |
---|
80 |
% |
---|
81 |
|
---|