
% function [g,a,b]=halfcirclegfunc(bs, s); 
%
% returns the parameters for boundaryvalues 
% for given boundarysegments (bs) and 
% parametervalues (s) 
%
% See halfcirclegeom for the definition of the geometry



function [g,a,b]=halfcirclegfunc(bs, s);

 
 if nargin<2, 
    error(sprintf('too few (%i<2) arguments ',nargin)); end
 if ~(all(size(bs)==size(s))), 
    error(sprintf('sizes of arguments do not match (%i %i)~=(%i %i) ',...
    size(bs),size(s))); end
   

 g = zeros(size(bs))+NaN; % 
 a = zeros(size(bs))+NaN; % 
 b = zeros(size(bs))+NaN; % 


% boundary segment 1
% this is the Dirichlet cond. 

 ii  =  find(bs == 1);
 g(ii) = 4*s(ii).*(1-s(ii)); 
 a(ii) = 0*ii; 
 b(ii) = 1+0*ii; 

% boundary segment 2
% this is the Neumann cond. 

 ii = find(bs == 2);
 g(ii) = 0*ones(size(ii)); 
 a(ii) = 1*ones(size(ii)); 
 b(ii) = 0*ones(size(ii)); 


% note that the segments are oriented!
 end

 if any(isnan(g)), error('Non existent boundary number'); end



  



