function [mn,mx]=meshdl(fem_grid_struct) %MESHDL determine the minimum and maximum element edge lengths % MESHDL determines the minimum and maximum grid element edge lengths, % suitable for use is a Courant number estimate. MESHDL trys to % determine if the input mesh is in Lat/Long of meters. % % Input : fem_grid_struct - OPNML mesh structure % % Output : mn,mx - minumin and maximum element edge lengths. % returned in meters!! % % Call as : [mn,mx]=meshdl(fem_grid_struct); % % Written by: Brian Blanton, Jun 1999 if nargin~=1 error('MESHDL must have a valid FEM_GRID_STRUCT as input.') else if ~isstruct(fem_grid_struct) error('Argument to MESHDL is not a structure.') elseif ~is_valid_struct(fem_grid_struct) error('FEM_GRID_STRUCT to MESHDL is not a valid grid structure.') end end % Try to determine if the grid is lon/lat minx=min(fem_grid_struct.x); maxx=max(fem_grid_struct.x); miny=min(fem_grid_struct.y); maxy=max(fem_grid_struct.y); gxy=fem_grid_struct; % Copy struct if (maxx-minx)<90 | (maxy-miny)<90 % grid appears to be in degrees gxy.x=deg2km(fem_grid_struct.x)*1000; gxy.y=deg2km(fem_grid_struct.y)*1000; end gxy=belint(gxy); dx=gxy.A; dy=gxy.B; dxy=sqrt(dx.*dx+dy.*dy); mn=min(min(dxy)); mx=max(max(dxy));