%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Main function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear, close all;

global depth width height gap

%% Define variables
% All dimensions are given in meters
depth = 20e-2;
height = 20e-2;
width = 3.76e-3;
gap = 3e-3;
scrsz = get(0,'ScreenSize');

%% Processing
figure('Name','Simualtion Window','Position', [1 scrsz(4) scrsz(3)/2 scrsz(4)]);
[p,e,t]=initmesh('geom_cap');
[p,e,t]=refinemesh('geom_cap',p,e,t);
[p,e,t]=refinemesh('geom_cap',p,e,t);
figure(1)
pdemesh(p,e,t);
u=assempde('geomb_cap',p,e,t,1,0,0);
[ux,uy] = pdegrad(p,t,u);
flowt = -1*[sign(ux).*log(abs(ux)+1);sign(uy).*log(abs(uy)+1)];
flow = -1*[ux;uy];
figure(2)
pdeplot(p,e,t,'xydata',u,'flowdata',flowt,'flowstyle','arrow','mesh','off','colormap','jet');

