% restriction et prolongement
close all
clear all

meshfile=fc_oogmsh.gmsh.buildmesh2d('condenser11',10);
Th=fc_simesh.siMesh(meshfile); % maillage global

Th.plotmeshinfo()

u=@(x,y) cos(pi*x).*sin(pi/3*y)+1;

%%% 2-simplex in dim==2
i=Th.find(2,20); % get index of the 2-simplices elementary mesh with label=10
Eh=Th.sTh{i};
U=Eh.eval(u); % dim Eh.nq

% prolongement par 0 dans Th (maillage global)
V=zeros(Th.nq,1);
V(Eh.toGlobal)=U;  

figure()
Th.plot(V)
shading interp
view(3);axis off;hold on
colorbar
Th.plotmesh('z',V,'edgecolor','k','facecolor','None','merge',true)

% prolongement par 1 dans Th (maillage global)
V2=ones(Th.nq,1);
V2(Eh.toGlobal)=U;  

figure()
Th.plot(V2)
shading interp
view(3);axis off;hold on
colorbar
Th.plotmesh('z',V2,'edgecolor','k','facecolor','None','merge',true)

% restriction dans Eh (i.e. Omega(20) )
Ug=Th.eval(u);       % Ug: dimension Th.nq
Ul=Ug(Eh.toGlobal);  % Ul: dimension Eh.nq

figure()
Eh.plot(Ul)
shading interp
view(3);axis off;hold on
colorbar
Th.plotmesh('z',V2,'edgecolor','lightgray','facecolor','None','merge',true)

