forked from FESTUNG/FESTUNG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
integrateRefElemDphiPhi.m
64 lines (63 loc) · 2.61 KB
/
integrateRefElemDphiPhi.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
60
61
62
63
64
% Compute integrals on the reference triangle, whose integrands consist of all
% permutations of a basis function with one of the (spatial) derivatives of a
% basis function.
%===============================================================================
%> @file integrateRefElemDphiPhi.m
%>
%> @brief Compute integrals on the reference triangle, whose integrands consist
%> of all permutations of a basis function with one of the (spatial)
%> derivatives of a basis function.
%===============================================================================
%>
%> @brief Compute integrals on the reference triangle @f$\hat{T}@f$,
%> whose integrands consist of all permutations of a basis function with
%> one of the (spatial) derivatives of a basis function.
%>
%> It computes a multidimensional array
%> @f$\hat{\mathsf{H}} \in \mathbb{R}^{N \times N \times 2}@f$
%> defined by
%> @f[
%> [\hat{\mathsf{H}}]_{i,j,m} = \int_{\hat{T}} \partial_{\hat{x}^m}
%> \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 and gradPhi2D.
%> @retval ret The computed array @f$[N\times N\times 2]@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 = integrateRefElemDphiPhi(N, basesOnQuad)
validateattributes(basesOnQuad, {'struct'}, {}, mfilename, 'basesOnQuad')
ret = zeros(N, N, 2); % [ N x N x 2]
if N > 1 % p > 0
p = (sqrt(8*N+1)-3)/2; qOrd = max(2*p, 1); [~,~,W] = quadRule2D(qOrd);
for i = 1 : N
for j = 1 : N
for m = 1 : 2
ret(i, j, m) = sum( W' .* basesOnQuad.gradPhi2D{qOrd}(:,i,m) .* basesOnQuad.phi2D{qOrd}(:,j) );
end % for
end % for
end % for
end % if
end % function