Merge branch 'femwind' of github.com:janmandel/wrf-fire-matlab into femwind
[wrf-fire-matlab.git] / detection / sfire_simple_mat.m
blob1d35602d500e09a96dd792d930fe1816bcc2a4a3
1 function t1=sfire_simple_mat(rr,t0,mask,ncycles)
2 % in:
3 % rr            structure with 2d fields r11...r33 
4 % t0            starting tign
5 % mask          if not 0, update 
6 % out:
7 % t1            updated ignition times
9 persistent r11 r12 r13 r21 r23 r31 r32 r33 
11 if ncycles<=0,
12     r11=rr.r11;
13     r12=rr.r12;
14     r13=rr.r13;
15     r21=rr.r21;
16     r23=rr.r23;
17     r31=rr.r31;
18     r32=rr.r32;
19     r33=rr.r33;
20 else
21     [m,n]=size(t0);
22     t1=t0;
23     for k=1:ncycles,
24         for j=2:n-1
25             for i=2:m-1
26                 if mask(i,j)>0,
27                 t=inf;
28                 t=min(t,t0(i-1,j)+r32(i-1,j));
29                 t=min(t,t0(i+1,j)+r12(i+1,j));
30                 t=min(t,t0(i,j-1)+r23(i,j-1));
31                 t=min(t,t0(i,j+1)+r21(i,j+1));
32                 t=min(t,t0(i-1,j-1)+r33(i-1,j-1));
33                 t=min(t,t0(i+1,j-1)+r13(i+1,j-1));
34                 t=min(t,t0(i-1,j+1)+r31(i-1,j+1));
35                 t=min(t,t0(i+1,j+1)+r11(i+1,j+1));
36                 t1(i,j)=t;
37                 end
38             end
39         end
40     end
41 end