ExaDG
Toggle main menu visibility
Loading...
Searching...
No Matches
include
exadg
solvers_and_preconditioners
utilities
block_jacobi_matrices.h
1
/* ______________________________________________________________________
2
*
3
* ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4
*
5
* Copyright (C) 2021 by the ExaDG authors
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19
* ______________________________________________________________________
20
*/
21
22
#ifndef EXADG_SOLVERS_AND_PRECONDITIONERS_UTILITIES_BLOCK_JACOBI_MATRICES_H_
23
#define EXADG_SOLVERS_AND_PRECONDITIONERS_UTILITIES_BLOCK_JACOBI_MATRICES_H_
24
25
namespace
ExaDG
26
{
27
/*
28
* Initialize block Jacobi matrices with zeros.
29
*/
30
template
<
typename
Number>
31
void
32
initialize_block_jacobi_matrices_with_zero(std::vector<dealii::LAPACKFullMatrix<Number>> & matrices)
33
{
34
// initialize matrices
35
for
(
auto
& m : matrices)
36
m = 0;
37
}
38
39
40
/*
41
* This function calculates the LU factorization for a given vector
42
* of matrices of type LAPACKFullMatrix.
43
*/
44
template
<
typename
Number>
45
void
46
calculate_lu_factorization_block_jacobi(std::vector<dealii::LAPACKFullMatrix<Number>> & matrices)
47
{
48
for
(
auto
& matrix : matrices)
49
{
50
try
// the matrix might be singular
51
{
52
matrix.compute_lu_factorization();
53
}
54
catch
(std::exception & exc)
55
{
56
// add a small, positive value to the diagonal
57
// of the LU factorized matrix
58
for
(
unsigned
int
i = 0; i < matrix.m(); ++i)
59
{
60
for
(
unsigned
int
j = 0; j < matrix.n(); ++j)
61
{
62
if
(i == j)
63
matrix(i, j) += 1.e-4;
64
}
65
}
66
}
67
}
68
}
69
70
}
// namespace ExaDG
71
72
#endif
/* EXADG_SOLVERS_AND_PRECONDITIONERS_UTILITIES_BLOCK_JACOBI_MATRICES_H_ */
ExaDG
Definition
driver.cpp:33
Generated by
1.17.0