/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_smooth/diffsmooth2D.m
ViewVC logotype

Diff of /MITgcm_contrib/gael/matlab_class/gcmfaces_smooth/diffsmooth2D.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2 by gforget, Sun Feb 14 17:29:28 2010 UTC revision 1.4 by gforget, Wed Aug 1 00:27:13 2012 UTC
# Line 1  Line 1 
1  function [FLD]=diffsmooth2D(fld,dxCsm,dyCsm);  function [FLD]=diffsmooth2D(fld,dxCsm,dyCsm);
2    %object: diffusive smoother (after Weaver and Courtier 2001)
3  %object: implementation (gforget@mit.edu) of a diffusive smoother (Weaver and Courtier 2001)  %
4    %input: fld               field to be smoothed (masked with NaN)
5  %input: fld     field to be smoothed (masked with NaN)  %       dxCsm,dyCsm       scale in first/second grid direction
6  %       dxCsm,dyCsm     scale in first/second direction  %output:FLD               smoothed field
7  %output:FLD     smoothed field  %
8    %asumption: dxCsm/dyCsm are given at U/V points (as DXC/DYC are)
 %asumption: dxCsm/dyCsm are assumed to be given at the positions of U/V points  
9    
10  global mygrid;  global mygrid;
11    
 dxC=mygrid.DXC; dyC=mygrid.DYC;  
 dxG=mygrid.DXG; dyG=mygrid.DYG;  
 rA=mygrid.RAC;  
   
12  %scale the diffusive operator:  %scale the diffusive operator:
13    dxC=mygrid.DXC; dyC=mygrid.DYC;
14    
15  tmp0=dxCsm./dxC; tmp0(isnan(fld))=NaN; tmp00=nanmax(tmp0);  tmp0=dxCsm./dxC; tmp0(isnan(fld))=NaN; tmp00=nanmax(tmp0);
16  tmp0=dyCsm./dyC; tmp0(isnan(fld))=NaN; tmp00=max([tmp00 nanmax(tmp0)]);  tmp0=dyCsm./dyC; tmp0(isnan(fld))=NaN; tmp00=max([tmp00 nanmax(tmp0)]);
17  smooth2D_nbt=tmp00;  nbt=tmp00;
18  smooth2D_nbt=ceil(1.1*2*smooth2D_nbt^2);  nbt=ceil(1.1*2*nbt^2);
   
 smooth2D_dt=1;  
 smooth2D_T=smooth2D_nbt*smooth2D_dt;  
 smooth2D_Kux=dxCsm.*dxCsm/smooth2D_T/2;  
 smooth2D_Kvy=dyCsm.*dyCsm/smooth2D_T/2;  
   
 %time-stepping loop:  
 FLD=fld;  
   
 for it=1:smooth2D_nbt;  
 %    if mod(it,ceil(smooth2D_nbt/50))==0; fprintf([num2str(it) '/' num2str(smooth2D_nbt) ' done\n']); end;  
   
     [dTdxAtU,dTdyAtV]=calc_T_grad(FLD,0);  
     tmpU=dTdxAtU.*smooth2D_Kux;  
     tmpV=dTdyAtV.*smooth2D_Kvy;  
     [fldDIV]=calc_UV_div(tmpU,tmpV);  
     dFLDdt=smooth2D_dt*fldDIV./rA;  
     FLD=FLD-dFLDdt;  
19    
20  end;  dt=1;
21    T=nbt*dt;
22    
23    %diffusion operator:
24    Kux=dxCsm.*dxCsm/T/2;
25    Kvy=dyCsm.*dyCsm/T/2;
26    
27    %setup problem:
28    myOp.dt=1;
29    myOp.nbt=nbt;
30    myOp.Kux=Kux;
31    myOp.Kvy=Kvy;
32    
33    %time step problem:
34    FLD=gcmfaces_timestep(myOp,fld);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.22