This is a static copy of a profile report

Home

NodePad (1 call, 0.045 sec)
Generated 04-Aug-2014 13:05:15 using cpu time.
function in file /gdata/projects/atl/FV_Matlab_Framework_JingPJH/trunk/Src/Util/NodePad.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
Bottom_Gravity_Current_Setup6script1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
36
[Masku, Maskv] = maskuv(Mask);
10.013 s28.6%
71
NodeP = [NodeP; bndnum*ones(1,...
10.006 s14.3%
63
NodeP = [NodeP'; bndnum*ones(1...
10.006 s14.3%
56
Nodeu = [bndnum*ones(1,Ny  ); ...
10.006 s14.3%
48
Nodeu(idsu) = (1:length(idsu))...
10.006 s14.3%
All other lines  0.006 s14.3%
Totals  0.045 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
maskuvfunction10.006 s14.3%
Self time (built-ins, overhead, etc.)  0.039 s85.7%
Totals  0.045 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function99
Non-code lines (comments, blank lines)47
Code lines (lines that can run)52
Code lines that did run41
Code lines that did not run11
Coverage (did run/can run)78.85 %
Function listing
time 
calls 
 line
   1 
function [NodeP, Nodeu, Nodev, idsP, idsu, idsv] = NodePad(Mask, bnd, periodic)
   2 
% function [NodeP, Nodeu, Nodev, idsP, idsu, idsv] = NodePad(Mask, bnd, periodicity)
   3 
% This function adds boundary or periodic cells at the four sides of the domain and
   4 
% creates the node numbering reference matrices for P, u and v grids.
   5 
%
   6 
% INPUTS:
   7 
%       Mask:   The pressure grid mask matrix (i.e. the tracer grid mask matrix)
   8 
%               NOTE: Internal boundaries should be numbered from 1 to #internal BCs!
   9 
%       bnd:    Vector containing true or false values of which boundaries to add:
  10 
%               bnd = [left right bottom top]
  11 
%       periodic: Logical variable: true if there are periodic BCs (optional)
  12 
%   
  13 
% OUTPUTS:
  14 
%       NodeP:  Reference node numbering matrix for pressure
  15 
%       NodeU:  Reference node numbering matrix for u-velocity 
  16 
%       NodeV:  Reference node numbering matrix for v-velocity 
  17 
%       idsP:   Location of active Pressure cells in interior
  18 
%       idsu:   Location of active u-velocity cells in interior
  19 
%       idsv:   Location of active v-velocity cells in interior
  20 
%
  21 
% See also: maskuv.m
  22 
%
  23 
% Written by:   Matt Ueckermann
  24 

  25 

  26 
%% Construct node numbering matrices with boundaries at four sides added
  27 

  28 
% Get mask size
      1 
  29 
[Ny, Nx] = size(Mask); 
  30 

  31 
% Get number of different internal bcs
      1 
  32 
bndnum = max(Mask(:)); 
      1 
  33 
Nbcs = max(Mask(:)) + sum(bnd); 
  34 

  35 
% Create u, v masks from P mask.
  0.01 
      1 
  36 
[Masku, Maskv] = maskuv(Mask); 
  37 

  38 
% Find internal active nodes id's.
      1 
  39 
idsP = find(Mask == 0); 
      1 
  40 
NodeP = Mask; 
      1 
  41 
idsu = find(Masku == 0); 
      1 
  42 
Nodeu = Masku; 
      1 
  43 
idsv = find(Maskv == 0); 
      1 
  44 
Nodev = Maskv; 
  45 

  46 
% Number only the internal active nodes, starting from #bcs+1
      1 
  47 
NodeP(idsP) = (1:length(idsP)) + Nbcs; 
< 0.01 
      1 
  48 
Nodeu(idsu) = (1:length(idsu)) + Nbcs; 
      1 
  49 
Nodev(idsv) = (1:length(idsv)) + Nbcs; 
  50 

  51 
% Add boundaries
  52 
% Left
      1 
  53 
if bnd(1) 
      1 
  54 
    bndnum = bndnum + 1; 
      1 
  55 
    NodeP = [bndnum*ones(1,Ny  ); NodeP']'; 
< 0.01 
      1 
  56 
    Nodeu = [bndnum*ones(1,Ny  ); Nodeu']'; 
      1 
  57 
    Nodev = [bndnum*ones(1,Ny-1); Nodev']'; 
      1 
  58 
    Nx = Nx + 1; 
      1 
  59 
end; 
  60 
% Right
      1 
  61 
if bnd(2) 
      1 
  62 
    bndnum = bndnum + 1; 
< 0.01 
      1 
  63 
    NodeP = [NodeP'; bndnum*ones(1,Ny  )]'; 
      1 
  64 
    Nodeu = [Nodeu'; bndnum*ones(1,Ny  )]'; 
      1 
  65 
    Nodev = [Nodev'; bndnum*ones(1,Ny-1)]'; 
      1 
  66 
    Nx = Nx + 1; 
      1 
  67 
end; 
  68 
% Bottom
      1 
  69 
if bnd(3) 
      1 
  70 
    bndnum = bndnum + 1; 
< 0.01 
      1 
  71 
    NodeP = [NodeP; bndnum*ones(1,Nx  )]; 
      1 
  72 
    Nodeu = [Nodeu; bndnum*ones(1,Nx-1)]; 
      1 
  73 
    Nodev = [Nodev; bndnum*ones(1,Nx  )]; 
      1 
  74 
end; 
  75 
% Top
      1 
  76 
if bnd(4) 
      1 
  77 
    bndnum = bndnum + 1; 
      1 
  78 
    NodeP = [bndnum*ones(1,Nx  ); NodeP]; 
      1 
  79 
    Nodeu = [bndnum*ones(1,Nx-1); Nodeu]; 
      1 
  80 
    Nodev = [bndnum*ones(1,Nx  ); Nodev]; 
      1 
  81 
end; 
      1 
  82 
Nx = Nx - sum(bnd(1:2)); 
  83 

  84 

  85 
%% Check for periodicity
  86 

  87 
% Add a boundary to handle periodicity correctly.
      1 
  88 
if (nargin == 3)&&(periodic) 
  89 
    if  size(NodeP,1) == Ny
  90 
        NodeP = [NodeP(end,:) ; NodeP ; NodeP(1,:)];
  91 
        Nodeu = [Nodeu(end,:) ; Nodeu ; Nodeu(1,:)];
  92 
        Nodev = [Nodev(end,:) ; Nodev ; Nodev(1,:)];
  93 
    end;
  94 
    if size(NodeP,2) == Nx
  95 
        NodeP = [NodeP(:,end)' ; NodeP' ; NodeP(:,1)']';
  96 
        Nodeu = [Nodeu(:,end)' ; Nodeu' ; Nodeu(:,1)']';
  97 
        Nodev = [Nodev(:,end)' ; Nodev' ; Nodev(:,1)']';
  98 
    end;
  99 
end;