1 function coarse_ind=map_submesh(fine_ind,coarse_size,fine_size)
2 % coarse_sub=map_submesh(fine_ind,size(coarse,size(fine))
4 % fine maps to rectangular blocs of fine
5 % given index vector to fine find corresponding index vector to coarse
8 % fine=kron(coarse,ones(m,n))
9 % now fine(fine_ind) == coarse(coarse_ind)
11 ratio = fine_size ./coarse_size;
12 [fine_i,fine_j]=ind2sub(fine_size,fine_ind); % convert index to subscript
13 coarse_i = 1 + floor((fine_i - 1)/ ratio(1));
14 coarse_j = 1 + floor((fine_j - 1)/ ratio(2));
15 coarse_ind = sub2ind(coarse_size,coarse_i,coarse_j);