Home > fvcom_prepro > change_shallow_bathy.m

change_shallow_bathy

PURPOSE ^

Deepens shallow nodes by setting a minimum depth and making nodes that

SYNOPSIS ^

function M = change_shallow_bathy(M, min_depth)

DESCRIPTION ^

 Deepens shallow nodes by setting a minimum depth and making nodes that
 are too shallow the mean of the surrouding deep nodes. Loop until all
 nodes are deeper than the minuimum depth required.

 function [M]=change_shallow_bathy(M, min_depth)

 DESCRIPTION:

 INPUT:
  M         = Mesh object
  min_depth = the minimum depth of nodes

 OUTPUT:
  Nested  Mesh object with altered bathymetry.

 EXAMPLE USAGE:


 Author(s):
   Rory O'Hara Murray (Marine Scotland Science)

 Revision history:
 2014 sometime - first version

==========================================================================

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function M  = change_shallow_bathy(M, min_depth)
0002 % Deepens shallow nodes by setting a minimum depth and making nodes that
0003 % are too shallow the mean of the surrouding deep nodes. Loop until all
0004 % nodes are deeper than the minuimum depth required.
0005 %
0006 % function [M]=change_shallow_bathy(M, min_depth)
0007 %
0008 % DESCRIPTION:
0009 %
0010 % INPUT:
0011 %  M         = Mesh object
0012 %  min_depth = the minimum depth of nodes
0013 %
0014 % OUTPUT:
0015 %  Nested  Mesh object with altered bathymetry.
0016 %
0017 % EXAMPLE USAGE:
0018 %
0019 %
0020 % Author(s):
0021 %   Rory O'Hara Murray (Marine Scotland Science)
0022 %
0023 % Revision history:
0024 % 2014 sometime - first version
0025 %
0026 %==========================================================================
0027 
0028 count = 0;
0029 h=-99; % just to start
0030 
0031 while sum(h==-99)>0
0032     count=count+1;
0033     disp(['iteration # ' num2str(count)])
0034     I = M.h<=min_depth;         % find shallow nodes as depth is +ve down.
0035     If = find(I);
0036     h = [];
0037     
0038     % loop through all shallow nodes with depth<=min_depth
0039     for ii=1:length(If)
0040         
0041         % find elements surrounding the shallow node
0042         test = [];
0043         for jj=1:3
0044             test = [test; find(M.tri(:,jj)==If(ii))];
0045         end
0046         % find nodes for all these elements surrounding the shallow node
0047         % (the surrounding nodes)
0048         nodes = unique(M.tri(test,:));
0049         
0050         htmp = M.h(nodes);
0051         bla = htmp>min_depth;       % find the nodes that are deeper than min_depth
0052         if sum(bla)>0
0053             h(ii) = mean(htmp(bla));% make the shallow node the mean of the surrounding nodes deeper than min_depth
0054         else
0055             h(ii) = -99;  % id no deep surroundign nodes then make it -99 and try again.
0056         end
0057     end
0058     M.h(I) = h;  % save changes to the Mobj array.
0059 end
0060 
0061 end

Generated on Wed 20-Feb-2019 16:06:01 by m2html © 2005