1 |
gforget |
1.3 |
function [FLD]=diffsmooth2D_extrap_fwd(fld,mskOut,eps); |
2 |
|
|
%object: extrapolate an incomplete field to create a full field, by |
3 |
|
|
% time-stepping a diffusion equation to near-equilibrium. |
4 |
|
|
%inputs: fld incomplete field of interest (masked with NaN) |
5 |
|
|
% mskOut land mask (1s and NaNs) for the full field (output) |
6 |
|
|
% eps convergence criterium |
7 |
|
|
%output: FLD full field |
8 |
gforget |
1.1 |
|
9 |
|
|
global mygrid; |
10 |
|
|
|
11 |
|
|
dxC=mygrid.DXC; dyC=mygrid.DYC; |
12 |
|
|
rA=mygrid.RAC; |
13 |
|
|
|
14 |
|
|
dxCsm=dxC; dyCsm=dyC; |
15 |
gforget |
1.4 |
|
16 |
|
|
%mask of points which values will evolve |
17 |
|
|
doStep=1*(isnan(fld)); |
18 |
gforget |
1.1 |
|
19 |
|
|
%put first guess: |
20 |
|
|
x=convert2array(mygrid.XC); |
21 |
|
|
y=convert2array(mygrid.YC); |
22 |
|
|
z=convert2array(fld); |
23 |
|
|
m=convert2array(mskOut); |
24 |
|
|
tmp1=find(~isnan(z)); |
25 |
|
|
tmp2=find(~isnan(m)); |
26 |
|
|
zz=z; |
27 |
|
|
zz(tmp2) = griddata(x(tmp1),y(tmp1),z(tmp1),x(tmp2),y(tmp2),'nearest'); |
28 |
gforget |
1.2 |
fld=convert2array(zz); |
29 |
gforget |
1.1 |
|
30 |
|
|
%put 0 first guess if needed and switch land mask: |
31 |
|
|
fld(find(isnan(fld)))=0; fld=fld.*mskOut; |
32 |
|
|
|
33 |
|
|
%scale the diffusive operator: |
34 |
|
|
tmp0=dxCsm./dxC; tmp0(isnan(mskOut))=NaN; tmp00=nanmax(tmp0); |
35 |
|
|
tmp0=dyCsm./dyC; tmp0(isnan(mskOut))=NaN; tmp00=max([tmp00 nanmax(tmp0)]); |
36 |
|
|
smooth2D_nbt=tmp00; |
37 |
|
|
smooth2D_nbt=ceil(1.1*2*smooth2D_nbt^2); |
38 |
|
|
|
39 |
|
|
smooth2D_dt=1; |
40 |
|
|
smooth2D_T=smooth2D_nbt*smooth2D_dt; |
41 |
|
|
smooth2D_Kux=dxCsm.*dxCsm/smooth2D_T/2; |
42 |
|
|
smooth2D_Kvy=dyCsm.*dyCsm/smooth2D_T/2; |
43 |
|
|
|
44 |
gforget |
1.4 |
%setup problem: |
45 |
|
|
myOp.dt=1; |
46 |
|
|
myOp.eps=eps; |
47 |
|
|
myOp.Kux=smooth2D_Kux; |
48 |
|
|
myOp.Kvy=smooth2D_Kvy; |
49 |
|
|
myOp.doStep=doStep; |
50 |
gforget |
1.1 |
|
51 |
gforget |
1.4 |
%time step problem: |
52 |
|
|
FLD=gcmfaces_timestep(myOp,fld); |
53 |
gforget |
1.1 |
|
54 |
|
|
|