% boundariesex.m
%
% NOTE: 
% study this example to see how to define 
% the geometry and pass the boundary values. 
%
%
%                        ---------------------

% Choose the geometry  
% see also circleg.m       

 geometry = 'halfcirclegeom';  % the boundary geometry: returns  points on boundary
 boundaries = 'halfcirclegfunc';  % the boundary geometry: returns  points on boundary

 [p,e,t]=initmesh(geometry,   'Hmax',5,  'jiggle','off');




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

% 	plot the mesh and the refined mesh 


 pdeplotn(p,e,t); 
 disp('Note that numbering of the boudaries on the row 5 of e:')
 disp(' e= ')
 disp(e)
 
 
 for i=1:3; 
    disp('press return to refine the mesh '); pause; 

  [p,e,t]=refinemesh(geometry,p,e,t,'longest'); 
  pdeplotn(p,e,t);  

    axis('equal'); title(sprintf('The %i refinement',i)); 
    disp(' e=');  disp(e)
 end


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

 disp('And now look at the boundary conditions!'); 

 disp('press return'); pause; 
 nd=feval(geometry);   % # of segments
 d=feval(geometry,1:nd);  % parameters of segments 
 ns = 11; 
 s = linspace(0,1,ns)';
 s = s*d(1,:) + (1-s)*d(2,:);  % 11 points on segments. 
 bs = ones(ns,1)*(1:size(d,2));  % the segments
 [x,y]= feval(geometry, bs, s); 
 [z,a,b] = feval(boundaries, bs, s); 

 clf
 plot3(x,y,z); 
 hold
 plot3(x,y,a,'x'); 
 plot3(x,y,b,'o'); 
 title('The functions a,b,g'); 
 hold
