rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
edge_quad_points.m
1 function PP = edge_quad_points(grid,elids,edgeids,degree)
2 %function PP = edge_quad_points(grid,elids,edgeids, degree)
3 % get the evaluation points for a quadrature over edges of the
4 % given grid.
5 %
6 % Given a list of edges `\{e(i_k, j_k)\}_{i=1}^K`, where `i_k` are cell indices
7 % and `j_k` denotes local edge numbers, this function computes quadrature
8 % points
9 % ``\left( x_k^1, \ldots, x_k^Q \right)``
10 % for each `k=1,\ldots, K`.
11 %
12 % Parameters:
13 % elids: vector of length `K` of cell indices `i_k`.
14 % edgeids: vector of length `K` of local edge indices `j_k`.
15 % degree: scalar defining the degree of the quadrature rule.
16 %
17 % Return values:
18 % PP: matrix of size `K \times Q` holding the quadrature for each edge.
19 % This can be used as last argument for either edge_quad_eval() or
20 % edge_quad_eval_mean().
21 %
22 
23 % Bernard Haasdonk 12.5.2007
24 
25 switch degree
26  case {0,1}
27  % simple midpoint integration
28  % x0 = 0.5, w0 = 1;
29  li = sub2ind(size(grid.ECX),elids(:),edgeids(:));
30  PP = [grid.ECX(li), grid.ECY(li)];
31  case 2
32  % gauss quadrature of order 2
33  % x0 = 0.5-0.5* sqrt(1/3) w0 = 0.5
34  % x1 = 0.5+0.5* sqrt(1/3) w1 = 0.5
35  x0 = 0.5 - 0.5*sqrt(1/3);
36  x1 = 0.5 + 0.5*sqrt(1/3);
37  [P1,P2] = get_edge_points(grid,elids,edgeids);
38  PP = [P1*x0 + P2*(1-x0); P1*x1 + P2*(1-x1)];
39  case 3
40  % gauss quadrature of order 3
41  % x0 = 0.5-0.5* sqrt(3/5) w0 = 5/18
42  % x1 = 0.5 w0 = 8/18
43  % x0 = 0.5+0.5* sqrt(3/5) w0 = 5/18
44  a = 0.5*sqrt(0.6);
45  x0 = 0.5 - a;
46  x1 = 0.5;
47  x2 = 0.5 + a;
48  [P1,P2] = get_edge_points(grid,elids,edgeids);
49  PP = [P1*x0 + P2*(1-x0); P1*x1 + P2*(1-x1); P1*x2 + P2*(1-x2) ];
50  otherwise
51  error('quadrature degree not implemented!');
52 end;
53 
54