This is a static copy of a profile report

Home

Bottom_Gravity_Current_Setup6DO (1 call, 15.399 sec)
Generated 04-Aug-2014 13:05:17 using cpu time.
script in file /gdata/projects/atl/FV_Matlab_Framework_JingPJH/trunk/Cases/Bottom_Gravity_Current/Bottom_Gravity_Current_Setup6DO.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
FluidsSolver2_DO3function1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
135
[u,v,rho,ui,vi,rhoi,Yi] = BGC_...
114.688 s95.4%
5
Bottom_Gravity_Current_Setup6
10.679 s4.4%
23
vi = zeros(length(v),app.S(1))...
10.013 s0.1%
25
rhoi = zeros(length(rho),app.S...
10.006 s0.0%
24
Pi = zeros(length(P),app.S(1))...
10.006 s0.0%
All other lines  0.006 s0.0%
Totals  15.399 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
BGC_DO_simsvdICfunction114.681 s95.3%
Bottom_Gravity_Current_Setup6script10.673 s4.4%
Self time (built-ins, overhead, etc.)  0.045 s0.3%
Totals  15.399 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function151
Non-code lines (comments, blank lines)49
Code lines (lines that can run)102
Code lines that did run16
Code lines that did not run86
Coverage (did run/can run)15.69 %
Function listing
time 
calls 
 line
  0.68 
      1 
   5 
Bottom_Gravity_Current_Setup6 
   6 

   7 
% Initialize DO modes.
   8 

   9 
% extract parameters from app structure
      1 
  10 
S = app.S ; MC = app.MC ; 
  11 

      1 
  12 
if isfield (app,'DO_IC_flag') 
      1 
  13 
   DO_IC_flag = app.DO_IC_flag; 
  14 
else
  15 
   DO_IC_flag = 'SineCosine_Plateau';
  16 
end;
  17 

      1 
  18 
if ~isfield (app,'MollifierWidth') 
      1 
  19 
   app.MollifierWidth = []; 
      1 
  20 
end; 
  21 

< 0.01 
      1 
  22 
ui = zeros(length(u),app.S(1)) ; 
  0.01 
      1 
  23 
vi = zeros(length(v),app.S(1)) ; 
< 0.01 
      1 
  24 
Pi = zeros(length(P),app.S(1)) ; 
< 0.01 
      1 
  25 
rhoi = zeros(length(rho),app.S(1)) ; 
      1 
  26 
var = ones(app.S(1),1) ; 
  27 

      1 
  28 
switch DO_IC_flag 
  29 

      1 
  30 
   case {'SineCosine_Plateau' 'SineCosine_Plateau_Sic'}; 
  31 

  32 
   % Initialize with Sines & Cosines over plateau or only over
  33 
   % plateau region with nonzero initial S.
  34 

  35 
      if strcmp (DO_IC_flag, 'SineCosine_Plateau_Sic')
  36 
         a_do_ic = a2;
  37 
      else
  38 
         a_do_ic = a1;
  39 
      end;
  40 
      b_do_ic = b-b1;
  41 

  42 
      initfn1 = @(x,y,M,N) (-(1/b_do_ic)*sin(pi.*x/a_do_ic).*sin(pi.*M.*x/a_do_ic) ...
  43 
       .*( cos(pi.*(b-y)/b_do_ic).*sin(pi.*N.*(b-y)/b_do_ic) ...
  44 
           + N.*sin(pi.*(b-y)/b_do_ic).*cos(pi.*N.*(b-y)/b_do_ic) )) .* ((x<=a_do_ic) & (y>=b1)) ;
  45 
      initfn2 = @(x,y,M,N)  ((1/a_do_ic)*sin(pi.*(b-y)/b_do_ic).*sin(pi.*N.*(b-y)/b_do_ic) ...
  46 
       .*( cos(pi.*x/a_do_ic).*sin(pi.*M.*x/a_do_ic) ...
  47 
           + M.*sin(pi.*x/a_do_ic).*cos(pi.*M.*x/a_do_ic) )) .* ((x<=a_do_ic) & (y>=b1)) ;
  48 

  49 
      i = 1 ;
  50 
      i_rho = 1;
  51 
      for ii = 1:app.S(1)
  52 
          for iiy = 1:ceil(ii/2)
  53 
              if ( i <= app.S(1) )
  54 
                  ix = ii - iiy + 1 ;
  55 
                  iy = iiy ;
  56 
                  nrm = sqrt(((ix^2 + 1))/16*(3/2)^(iy==1) ...
  57 
                        + ((iy^2 + 1))/16*(3/2)^(ix==1)) ;
  58 
                  ui(Nbcs+1:length(u),i) = initfn1(XU(idsu), YU(idsu), ix, iy ) / (nrm*sqrt(app.IP(1)));
  59 
                  vi(Nbcs+1:length(v),i) = initfn2(XV(idsv), YV(idsv), ix, iy ) / (nrm*sqrt(app.IP(2)));
  60 
                  var(i) = 10 * exp((1-i)/2.5) ;
  61 
                  i = i + 1;
  62 
                  if (i_rho <=app.S(1))
  63 
                     rhoi(Nbcs+1:length(rho),i_rho) = initfn1(XP(idsP),YP(idsP),ix,iy)./(nrm.*sqrt(app.IP(3)));
  64 
                     i_rho = i_rho + 1;
  65 
                  end;
  66 
                  if ( i_rho <= app.S(1) )
  67 
                     rhoi(Nbcs+1:length(rho),i_rho) = initfn2(XP(idsP),YP(idsP),ix,iy)./(nrm*sqrt(app.IP(3)));
  68 
                     i_rho = i_rho + 1;
  69 
                  end;
  70 
              end
  71 
              if ( i <= app.S(1) && ix ~= iy )
  72 
                  % ix and iy interchanged
  73 
                  iy = ii - iiy + 1 ;
  74 
                  ix = iiy ;
  75 
                  nrm = sqrt(((ix^2 + 1))/16*(3/2)^(iy==1) ...
  76 
                        + ((iy^2 + 1))/16*(3/2)^(ix==1)) ;
  77 
                  ui(Nbcs+1:length(u),i) = initfn1(XU(idsu), YU(idsu), ix, iy ) / (nrm*sqrt(app.IP(1)));
  78 
                  vi(Nbcs+1:length(v),i) = initfn2(XV(idsv), YV(idsv), ix, iy ) / (nrm*sqrt(app.IP(2)));
  79 
                  var(i) = 10 * exp((1-i)/2.5) ;
  80 
                  i = i + 1;
  81 
                  if (i_rho <=app.S(1))
  82 
                     rhoi(Nbcs+1:length(rho),i_rho) = initfn1(XP(idsP),YP(idsP),ix,iy)./(nrm*sqrt(app.IP(3)));
  83 
                     i_rho = i_rho + 1;
  84 
                  end;
  85 
                  if ( i_rho <= app.S(1) )
  86 
                     rhoi(Nbcs+1:length(rho),i_rho) = initfn2(XP(idsP),YP(idsP),ix,iy)./(nrm*sqrt(app.IP(3)));
  87 
                     i_rho = i_rho + 1;
  88 
                  end;
  89 
              end
  90 
          end
  91 
      end
  92 

  93 
      % orthonormalize DO modes
  94 

  95 
      uid = Nbcs+1:length(u);
  96 
      vid = Nbcs+1:length(v);
  97 
      pid = Nbcs+1:length(rho);
  98 

  99 
      for i = 1:S
 100 
          for j = 1:S
 101 
              if ( i ~= j )
 102 
                  coef = app.IP(1) * InProd(ui(:,i),ui(:,j),dx,dy,uid) ...
 103 
                         + app.IP(2) * InProd(vi(:,i),vi(:,j),dx,dy,vid) ...
 104 
                         + app.IP(3) * InProd(rhoi(:,i), rhoi(:,i), dx, dy, pid);
 105 
                  ui(:,i) = ui(:,i) - coef * ui(:,j) ;
 106 
                  vi(:,i) = vi(:,i) - coef * vi(:,j) ;
 107 
                  rhoi(:,i) = rhoi(:,i) - coef * rhoi(:,j);
 108 
              end
 109 
          end
 110 
          nrm = sqrt(app.IP(1)*InProd(ui(:,i),ui(:,i),dx,dy,uid) ...
 111 
                     + app.IP(2)*InProd(vi(:,i),vi(:,i),dx,dy,vid) ...
 112 
                     + app.IP(3)*InProd(rhoi(:,i), rhoi(:,i), dx, dy, pid)) ;
 113 
          ui(:,i) = ui(:,i)/nrm ;
 114 
          vi(:,i) = vi(:,i)/nrm ;
 115 
          rhoi(:,i) = rhoi(:,i) / nrm;
 116 
      end
 117 

 118 
      % Redimensionalize modes
 119 

 120 
      ui = ui .*app.varscale./sqrt(app.IP(1));
 121 
      vi = vi .*app.varscale./sqrt(app.IP(2));
 122 
      rhoi = rhoi .*app.varscale./sqrt(app.IP(3));
 123 

 124 
      %Initialize stochastic coefficients as normal random with variance as calculated
 125 
      %in Stoch_Initial_Perturb
 126 
      Yi=zeros(app.MC,app.S(1));
 127 
      for i=1:app.S(1)
 128 
          Yi(:,i)=var(i).*normrnd(0,1,app.MC,1);
 129 
      end
 130 

      1 
 131 
   case {'SVD_ICs'}; 
 132 

 133 
   % This option creates modes by SVD of frequent output from short run.
 134 

 14.69 
      1 
 135 
   [u,v,rho,ui,vi,rhoi,Yi] = BGC_DO_simsvdIC (app); 
 136 

 137 
   case {'Correlation_Rho' 'Correlation_Rho_Sic' };
 138 

 139 
      switch (DO_IC_flag)
 140 
         case 'Correlation_Rho_Sic'
 141 
            a_limit = a2;
 142 
         otherwise
 143 
            a_limit = a1;
 144 
      end;
 145 

 146 
%keyboard
 147 
      [rhoi, Yi] = Stoch_Initial_Perturb_rho (XP,YP,dx,dy,a_limit,b,b1,app,Nbcs,NodeP,idsP);
 148 

 149 
   case {'Restart'};
 150 

 151 
   % This option creates modes by SVD of frequent output from short run.
 152 

 153 
   [u,v,rho,P,ui,vi,rhoi,Pi,Yi] = BGC_DO_restart (app,u,v,rho,P,ui,vi,rhoi,Pi,idsu,idsv,idsP,Nodeu,Nodev,NodeP);
 154 

 155 
end;

Other subfunctions in this file are not included in this listing.