echo on

% assemhints (matlab-script)
%
% This file assembles the fem-system, when parts are obtained 
% by assema and assemb functions. 
% See the file (by 'type assemhints') for details. 
% Note that this script toggles the echoing on!
%
% We suppose we have defined 
% the system by pdetool 
% (use the usual names given by export) 

% ------------------------------------------------------------

[k,m,f1]  = assema( p,t,c,a,f); 
[q,g,h,r] = assemb( b,p,e); 

% This is how we assemble the system: 
% Note the way we find the equations corresponding to the 
% boundary conditions in the edge (e) matrix.

i=sort(e(1,:)); 
aa = k+m +q;  aa(i,:)=h; 
bb = f1  +g;  bb(i,:)=r;


% Finally look at the old and new systems (the differences): 
% blue wihtout and yellow with boundary conds.

 figure(4); clf; 
spy([k+m, f1],'b');
 hold on; 
 title('without bound. cond.')
 drawnow; pause(2); 
spy([aa,bb],'y'); 
 title('with bound. cond.')

% now solve the system 

u2 =  aa \ bb; 

% and plot the solution. 

 figure(5); clf
if exist('u'),
  pdeplot(p,e,t,'xydata',u-u2); title 'error = u-u_hand'
  error= norm(u-u2) 
else
  pdeplot(p,e,t,'xydata',u2); title 'new solution'
end

% -------------------------------------------------------------
