## -*- texinfo -*-
## @deftypefn  {} {} AnalyzeBoundary.m
##
## This is a demo file  inside the `doc/Examples/EIT/` directory@*
## Find the description in the documentation FEMdoc.pdf
##
## @end deftypefn

%% script to analyze the flux on the boundary
%% assumes that EITforward.m war run before
Angle = -90  % use 60, 120 or -90
Angle = deg2rad(Angle);
Section = pi/20; phi = Angle + linspace(-Section,+Section,100)';
x_b = 0.999*Rx*cos(phi); y_b = 0.999*Ry*sin(phi);

[u_boundary,ux_boundary,uy_boundary]   = FEMgriddata(FEMmesh,u,x_b,y_b);

ds = sqrt(Rx^2*sin(phi).^2 + Ry^2*cos(phi).^2);
n = [Ry*cos(phi)./ds, Rx*sin(phi)./ds];

flux = (ux_boundary.*n(:,1) + uy_boundary.*n(:,2));
figure(1); plot(rad2deg(phi),flux)
           xlabel('\phi [deg]'); ylabel('flux density')
TotalFlux = trapz(phi,flux.*ds)
