File size: 1,514 Bytes
bc2cdff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
% Description of Neumann boundary condition for the
% conductivity problem.  
%
% The format of this file is suitable for describing the boundary condition
% for the assempde.m routine of Matlabs PDE toolbox.
%
% Arguments:
% p     triangulation points
% e     edge data
% u     not used here
% time  not used here
%
% Returns:
% q     zeros(1,ne), where ne is the number of edges in e
% g     values of Neumann data at centerpoint on each edge 
% h     ones(1,2*ne)
% r     zeros(1,2*ne)
%
% Samuli Siltanen May 2008

function [q,g,h,r] = BoundaryData(p,e,u,time) 

% Number of edges
ne = size(e,2);

% Give value to q, g and h
q = zeros(1,ne);
h = zeros(1,2*ne);
r = zeros(1,2*ne);

% Initialize Neumann data matrix
g = zeros(1,ne);

% Initialize vector for storing edge lengths for integration
elen = zeros(1,ne);

% Loop over edges
for nnn = 1:ne
    % Coordinates of starting and ending points of the current edge
    sp1 = p(1,e(1,nnn));
    sp2 = p(2,e(1,nnn));
    ep1 = p(1,e(2,nnn));
    ep2 = p(2,e(2,nnn));
    
    % Compute midpoint of boundary segment
    mp1 = (sp1+ep1)/2;
    mp2 = (sp2+ep2)/2;

    % Record length of edge
    elen(nnn) = abs((sp1+i*sp2)-(mp1+i*mp2));
    
    % Evaluate Neumann data at the plane point (mp1,mp2)
    % We know that this trigonometric data integrates to zero, 
    % ensuring solvability of the Neumann problem.
    load  data/BoundaryDataN n
    g(nnn) = 1/sqrt(2*pi)*exp(i*n*angle(mp1+i*mp2));
end