An example of a fast advancing front technique to
compute L2 projections from an arbitrary triangular grid onto
another arbitrary one for non-conforming (e.g. mortar) methods.
To obtain the Matlab code, see below.
Check also out the 3d case, and the case
where the interfaces two dimensional, but in 3d, and not at
precisely the same geometrical location.
Below is the short Matlab code which does the projection: it is
explained in the paper "An
algorithm with optimal complexity for
non-matching grid projections", M.J. Gander and C. Japhet,
Proceedings of the 18th international conference of
Domain Decomposition methods, 2008. The complete demo code in Matlab
with an example can be downloaded here,
and also the slides of
the corresponding presentation with several helpful illustrations.
% INTERFACEMATRIX projection matrix for nonmatching triangular grids
% M=InterfaceMatrix(Na,Ta,Nb,Tb); takes two triangular meshes Ta
% and Tb with associated nodal coordinates in Na and Nb and
% computes the interface projection matrix M
bl=; % bl: list of triangles of Tb to treat
bil=; % bil: list of triangles Ta to start with
bd=zeros(size(Tb,1)+1,1); % bd: flag for triangles in Tb treated
bd(end)=1; % guard, to treat boundaries
bd(1)=1; % mark first triangle in b list.
bc=bl(1); bl=bl(2:end); % bc: current triangle of Tb
al=bil(1); bil=bil(2:end); % triangle of Ta to start with
ad=zeros(size(Ta,1)+1,1); % same as for bd
n=[0 0 0]; % triangles intersecting with neighbors
ac=al(1); al=al(2:end); % take next candidate
if ~isempty(P) % intersection found
al=[al t]; % add neighbors
n(find(nc>0))=ac; % ac is starting candidate for neighbor
tmp=find(bd(Tb(bc,4:6))==0); % find non-treated neighbors
idx=find(n(tmp)>0); % take those which intersect
bl=[bl t]; % and add them
bil=[bil n(tmp(idx))]; % with starting candidates Ta