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.
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.
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
21 % F: vector of length `K` holding the quadrature evaluations on edges
24 % See also: edge_quad_point()
for construction of quadrature points.
26 % Bernard Haasdonk 13.5.2007
28 li = sub2ind(size(grid.ECX),elids(:),edgeids(:));
29 nedges = length(elids);
32 % simple midpoint integration
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)];
42 % gauss quadrature of order 3
43 % x0 = 0.5-0.5* sqrt(3/5) w0 = 5/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;
49 error('quadrature degree not implemented!');