Revision 495
(checked in by cbc, 12 years ago)
|
Initial import of Stark code.
|
Line | |
---|
1 |
function fem_grid_struct=grd_to_opnml(fort14name) |
---|
2 |
%GRD_TO_OPNML Convert an ADCIRC grd file to an OPNML fem_grid_struct. |
---|
3 |
% Convert an ADCIRC grd file to an OPNML fem_grid_struct. |
---|
4 |
% ADCIRC grid information assumed in "fort.14" format. |
---|
5 |
% The boundary/island information at the tail of the fort.14 |
---|
6 |
% file is ignored. |
---|
7 |
% |
---|
8 |
% Input: fort14name - path/name of fort.14 file; if not passed, |
---|
9 |
% assumes fort.14 in the currect working dir. |
---|
10 |
% Output: fem_grid_struct - OPNML grid structure |
---|
11 |
% |
---|
12 |
% Call: fem_grid_struct=grd_to_opnml(fort14name); |
---|
13 |
% fem_grid_struct=grd_to_opnml; |
---|
14 |
|
---|
15 |
if ~exist('fort14name') |
---|
16 |
% assume fort.14 filename in the current wd. |
---|
17 |
fort14name='fort.14'; |
---|
18 |
end |
---|
19 |
|
---|
20 |
% Open fort.14 file |
---|
21 |
[f14,message]=fopen(fort14name,'r'); |
---|
22 |
if (f14<0) |
---|
23 |
error(message) |
---|
24 |
end |
---|
25 |
|
---|
26 |
% Get grid info |
---|
27 |
gridname=fgetl(f14); |
---|
28 |
|
---|
29 |
temp=fscanf(f14,'%d %d',2); |
---|
30 |
nn=temp(2); |
---|
31 |
ne=temp(1); |
---|
32 |
|
---|
33 |
% Get node locations |
---|
34 |
temp=fscanf(f14,'%d %f %f %f',[4 nn])'; |
---|
35 |
x=temp(:,2); |
---|
36 |
y=temp(:,3); |
---|
37 |
z=temp(:,4); |
---|
38 |
|
---|
39 |
% Get elements |
---|
40 |
temp=fscanf(f14,'%d %d %d %d',[5 ne])'; |
---|
41 |
e=temp(:,3:5); |
---|
42 |
|
---|
43 |
fem_grid_struct.name=gridname; |
---|
44 |
fem_grid_struct.x=x; |
---|
45 |
fem_grid_struct.y=y; |
---|
46 |
fem_grid_struct.z=z; |
---|
47 |
fem_grid_struct.e=e; |
---|
48 |
fem_grid_struct.bnd=detbndy(e); |
---|
49 |
|
---|
50 |
fclose(f14); |
---|