rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
edge_quad_eval_mean.m
1 function F = edge_quad_eval_mean(grid,elids,edgeids,degree,FF)
2 %function F = edge_quad_eval_mean(grid,elids,edgeids,degree,FF)
3 % Compute an edge-average integral of a scalar function in various edges
4 % simultaneously. Approximation by Gauss-quadratures are performed.
5 %
6 % Computes quadratures approximating integrals
7 % `` \frac{1}{|e(i_k,j_k)|} \int_{e(i_k,j_k)} f(s) ds ``
8 % over edges `e(i_k, j_k)` for `k=1,...,K`, where `i_k` are cell indices and
9 % `j_k` denotes local edge numbers.
10 %
11 % Parameters:
12 % elids: vector of length `K` of cell indices `i_k`.
13 % edgeids: vector of length `K` of local edge indices `j_k`.
14 % degree: scalar defining the degree of the quadrature rule.
15 % FF: matrix of size 'degree x grid.nedges' holding evaluations of a
16 % function `f:\mathbb{R} \to \mathbb{R}` in quadrature points. This
17 % is usually obtained by a call @code FF=f(edge_quad_points(elids,
18 % edgeids, degree) @endcode
19 %
20 % Return values:
21 % F: vector of length `K` holding the quadrature evaluations on edges
22 % `e(i_k, j_k)`.
23 %
24 % See also: edge_quad_point() for construction of quadrature points.
25 
26 % Bernard Haasdonk 13.5.2007
27 
28 li = sub2ind(size(grid.ECX),elids(:),edgeids(:));
29 nedges = length(elids);
30 switch degree
31  case {0,1}
32  % simple midpoint integration
33  % x0 = 0.5, w0 = 1;
34  F = FF(:);
35  case 2
36  % gauss quadrature of order 2
37  % x0 = 0.5-0.5* sqrt(1/3) w0 = 0.5
38  % x1 = 0.5+0.5* sqrt(1/3) w1 = 0.5
39  F = 0.5*(FF(1:nedges) + FF((nedges+1):end));
40 % PP = [P1*x0 + P2*(1-x0), P1*x1 + P2*(1-x1)];
41  case 3
42  % gauss quadrature of order 3
43  % x0 = 0.5-0.5* sqrt(3/5) w0 = 5/18
44  % x1 = 0.5 w0 = 8/18
45  % x2 = 0.5+0.5* sqrt(3/5) w0 = 5/18
46  F = (5*FF(1:nedges) + 8*FF((nedges+1):(2*nedges)) + ...
47  5*FF((2*nedges+1):end))/18;
48  otherwise
49  error('quadrature degree not implemented!');
50 end;
51 
52 
53 
54