forked from FESTUNG/FESTUNG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
integrateRefElemPhiPhi.m
59 lines (58 loc) · 2.35 KB
/
integrateRefElemPhiPhi.m
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
% Compute integrals on the reference triangle, whose integrands
% consist of all permutations of two basis functions.
%===============================================================================
%> @file integrateRefElemPhiPhi.m
%>
%> @brief Compute integrals on the reference triangle, whose
%> integrands consist of all permutations of two basis functions.
%===============================================================================
%>
%> @brief Compute integrals on the reference triangle @f$\hat{T}@f$,
%> whose integrands consist of all permutations of two basis functions.
%>
%> It computes a matrix
%> @f$\hat{\mathsf{M}}\in\mathbb{R}^{N\times N}@f$
%> defined by
%> @f[
%> [\hat{\mathsf{M}}]_{i,j} =
%> \int_{\hat{T}} \hat{\varphi}_i \hat{\varphi}_j \mathrm{d}\hat{\mathbf{x}} \,.
%> @f]
%>
%> @param N The local number of degrees of freedom
%> @param basesOnQuad A struct containing precomputed values of the basis
%> functions on quadrature points. Must provide at
%> least phi2D.
%> @param qOrd (optional) The order of the quadrature rule to be used.
%> @retval ret The computed matrix @f$[N\times N]@f$
%>
%> This file is part of FESTUNG
%>
%> @copyright 2014-2015 Florian Frank, Balthasar Reuter, Vadym Aizinger
%>
%> @par License
%> @parblock
%> This program is free software: you can redistribute it and/or modify
%> it under the terms of the GNU General Public License as published by
%> the Free Software Foundation, either version 3 of the License, or
%> (at your option) any later version.
%>
%> This program is distributed in the hope that it will be useful,
%> but WITHOUT ANY WARRANTY; without even the implied warranty of
%> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%> GNU General Public License for more details.
%>
%> You should have received a copy of the GNU General Public License
%> along with this program. If not, see <http:https://www.gnu.org/licenses/>.
%> @endparblock
%
function ret = integrateRefElemPhiPhi(N, basesOnQuad, qOrd)
validateattributes(basesOnQuad, {'struct'}, {}, mfilename, 'basesOnQuad')
if nargin < 3, p = (sqrt(8*N+1)-3)/2; qOrd = max(2*p, 1); end
[~,~,W] = quadRule2D(qOrd);
ret = zeros(N); % [N x N]
for i = 1 : N
for j = 1 : N
ret(i, j) = sum( W' .* basesOnQuad.phi2D{qOrd}(:, i) .* basesOnQuad.phi2D{qOrd}(:, j) );
end % for
end % for
end % function