fixing ndt boundary conditions tile and domain bounds, adding debug prints
[wrf-fire-matlab.git] / vis3d / interp_w2buv.m
blob6f25a869d1040ea45cbfe83d0710bc30deecb1a5
1 function [a_bu,a_bv]=interp_w2buv(a)
2 % interpolate horizontally values at w points to bottom of cell 
3 % under the u and v points
5 % extend values at at w by 1 on each side by continuation
6 etype='constant'; % extend by constant
7 s=size1(a,4); 
8 alt=zeros(s(1)+2,s(2)+2,s(3),s(4)); % extend laterally by 1
9 alt(2:end-1,2:end-1,:,:)=a;         % embded original array
10 alt(1,2:end-1,:,:)=extend(a(1,:,:,:),a(2,:,:,:),etype); % extend by reflection
11 alt(end,2:end-1,:,:)=extend(a(end,:,:,:),a(end-1,:,:,:),etype);
12 alt(2:end-1,1,:,:)=extend(a(:,2*1,:,:),a(:,2,:,:),etype); % 
13 alt(2:end-1,end,:,:)=extend(a(:,end,:,:),a(:,end-1,:,:),etype);
15 % interpolate to bottom cell locations under u and v
16 a_bu=0.5*(alt(1:end-1,:,:,:)+alt(2:end,:,:,:));
17 a_bv=0.5*(alt(:,1:end-1,:,:)+alt(:,2:end,:,:));
18 end
20 function x0=extend(x1,x2,etype)
21 switch etype(1)
22     case 'c'  
23         x0=x1;  % constant
24     case 'r'
25         x0=x1+(x1-x2); % reflection
26     otherwise
27         type
28         error('extend: unknown type')
29 end
30 end