Home > utilities > ComputeMatrixRx1_nodes.m

ComputeMatrixRx1_nodes

PURPOSE ^

Computes rx1 matrix as in ComputeMatrixRx1_V2.m downloaded from

SYNOPSIS ^

function RX1matrix=ComputeMatrixRx1_nodes(Z_w, Mobj)

DESCRIPTION ^

 Computes rx1 matrix as in ComputeMatrixRx1_V2.m downloaded from
 https://github.com/dcherian/tools

 function [RX1matrix] = ComputeMatrixRx1_nodes(Z_w, Mobj)

 DESCRIPTION:
    Calculates the hydrostatic consistency condition:
      r = abs(Sigma/H deltaxH/deltaSigma)
    this reflects the errors associated with horizontal pressure gradients
    calculations that are associated with steep bathyemtry and low
    vertical resolution.

 INPUT
   Z_w    = This is the sigmal layer vertical distribution in Z coordinates
   Mobj   = needs triangulation and mesh information
            table. read_sms_mesh provides everything it needs.


 OUTPUT:
    RX1matrix = node based field with values of max(rx1)

 EXAMPLE USAGE
    [RX1matrix] = ComputeMatrixRx1_nodes(Z_w, Mobj)

 Author(s):
    Ricardo Torres (Plymouth Marine Laboratory) based on ComputeMatrixRx1_V2

 Revision history

   2018-03-22 First version.

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function RX1matrix=ComputeMatrixRx1_nodes(Z_w, Mobj)
0002 % Computes rx1 matrix as in ComputeMatrixRx1_V2.m downloaded from
0003 % https://github.com/dcherian/tools
0004 %
0005 % function [RX1matrix] = ComputeMatrixRx1_nodes(Z_w, Mobj)
0006 %
0007 % DESCRIPTION:
0008 %    Calculates the hydrostatic consistency condition:
0009 %      r = abs(Sigma/H deltaxH/deltaSigma)
0010 %    this reflects the errors associated with horizontal pressure gradients
0011 %    calculations that are associated with steep bathyemtry and low
0012 %    vertical resolution.
0013 %
0014 % INPUT
0015 %   Z_w    = This is the sigmal layer vertical distribution in Z coordinates
0016 %   Mobj   = needs triangulation and mesh information
0017 %            table. read_sms_mesh provides everything it needs.
0018 %
0019 %
0020 % OUTPUT:
0021 %    RX1matrix = node based field with values of max(rx1)
0022 %
0023 % EXAMPLE USAGE
0024 %    [RX1matrix] = ComputeMatrixRx1_nodes(Z_w, Mobj)
0025 %
0026 % Author(s):
0027 %    Ricardo Torres (Plymouth Marine Laboratory) based on ComputeMatrixRx1_V2
0028 %
0029 % Revision history
0030 %
0031 %   2018-03-22 First version.
0032 %
0033 %==============================================================================
0034 
0035 subname = 'ComputeMatrixRx1_nodes';
0036 global ftbverbose
0037 if ftbverbose
0038     fprintf('\nbegin : %s \n', subname)
0039 end
0040 %--------------------------------------------------------------------------
0041 % Estimate dimensins of mesh based on array's sizes
0042 %--------------------------------------------------------------------------
0043 
0044 N=size(Z_w,2)-1;
0045 nNodes = size(Z_w,1);
0046 RX1matrix=zeros(nNodes,1);
0047 TR = triangulation(Mobj.tri, [Mobj.x, Mobj.y]);
0048 % loop through all Nodes
0049 for iXi=1:nNodes
0050     rx1=0;
0051 % Find neighbouring nodes for the node under consideration
0052     ti = cell2mat(vertexAttachments(TR,iXi));
0053     vertices = setdiff(unique(TR.ConnectivityList(ti,:)),iXi);
0054 % calculate max rx1 values in the vertical and horizontal among all neighbouring nodes
0055     for nn=1:length(vertices)
0056         for i=1:N
0057             a1=abs(Z_w(iXi,i+1) - Z_w(vertices(nn),i+1) + ...
0058                 Z_w(iXi,i) - Z_w(vertices(nn),i));
0059             b1=abs(Z_w(iXi,i+1) + Z_w(vertices(nn),i+1) - ...
0060                 Z_w(iXi,i) - Z_w(vertices(nn),i));
0061             quot=abs(a1/b1);
0062             rx1=max(rx1, quot);
0063         end
0064     end
0065     RX1matrix(iXi)=rx1;
0066 end
0067 if ftbverbose
0068   fprintf('end   : %s\n', subname)
0069 end

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