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