OpenFOAM: API Guide
v2006
The open source CFD toolbox
lduMatrixPreconditioner.C
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | www.openfoam.com
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
Copyright (C) 2011-2016 OpenFOAM Foundation
9
Copyright (C) 2019 OpenCFD Ltd.
10
-------------------------------------------------------------------------------
11
License
12
This file is part of OpenFOAM.
13
14
OpenFOAM is free software: you can redistribute it and/or modify it
15
under the terms of the GNU General Public License as published by
16
the Free Software Foundation, either version 3 of the License, or
17
(at your option) any later version.
18
19
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22
for more details.
23
24
You should have received a copy of the GNU General Public License
25
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27
\*---------------------------------------------------------------------------*/
28
29
#include "
lduMatrix.H
"
30
31
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33
namespace
Foam
34
{
35
defineRunTimeSelectionTable
(lduMatrix::preconditioner, symMatrix);
36
defineRunTimeSelectionTable
(lduMatrix::preconditioner, asymMatrix);
37
}
38
39
40
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41
42
Foam::word
Foam::lduMatrix::preconditioner::getName
43
(
44
const
dictionary
& solverControls
45
)
46
{
47
word
name
;
48
49
// Handle primitive or dictionary entry
50
const
entry
&
e
=
51
solverControls.
lookupEntry
(
"preconditioner"
, keyType::LITERAL);
52
53
if
(
e
.isDict())
54
{
55
e
.dict().readEntry(
"preconditioner"
,
name
);
56
}
57
else
58
{
59
e
.stream() >>
name
;
60
}
61
62
return
name
;
63
}
64
65
66
Foam::autoPtr<Foam::lduMatrix::preconditioner>
67
Foam::lduMatrix::preconditioner::New
68
(
69
const
solver
& sol,
70
const
dictionary
& solverControls
71
)
72
{
73
word
name
;
74
75
// Handle primitive or dictionary entry
76
77
const
entry
&
e
=
78
solverControls.
lookupEntry
(
"preconditioner"
, keyType::LITERAL);
79
80
if
(
e
.isDict())
81
{
82
e
.dict().readEntry(
"preconditioner"
,
name
);
83
}
84
else
85
{
86
e
.stream() >>
name
;
87
}
88
89
const
dictionary
& controls =
e
.isDict() ?
e
.dict() : dictionary::null;
90
91
if
(sol.
matrix
().
symmetric
())
92
{
93
auto
cstrIter = symMatrixConstructorTablePtr_->cfind(
name
);
94
95
if
(!cstrIter.found())
96
{
97
FatalIOErrorInLookup
98
(
99
controls,
100
"symmetric matrix preconditioner"
,
101
name
,
102
*symMatrixConstructorTablePtr_
103
) <<
exit
(
FatalIOError
);
104
}
105
106
return
autoPtr<lduMatrix::preconditioner>
107
(
108
cstrIter()
109
(
110
sol,
111
controls
112
)
113
);
114
}
115
else
if
(sol.
matrix
().
asymmetric
())
116
{
117
auto
cstrIter = asymMatrixConstructorTablePtr_->cfind(
name
);
118
119
if
(!cstrIter.found())
120
{
121
FatalIOErrorInLookup
122
(
123
controls,
124
"asymmetric matrix preconditioner"
,
125
name
,
126
*asymMatrixConstructorTablePtr_
127
) <<
exit
(
FatalIOError
);
128
}
129
130
return
autoPtr<lduMatrix::preconditioner>
131
(
132
cstrIter()
133
(
134
sol,
135
controls
136
)
137
);
138
}
139
140
FatalIOErrorInFunction
(controls)
141
<<
"cannot solve incomplete matrix, "
142
"no diagonal or off-diagonal coefficient"
143
<<
exit
(
FatalIOError
);
144
145
return
nullptr
;
146
}
147
148
149
// ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition:
entry.H:67
Foam::lduMatrix::preconditioner::getName
static word getName(const dictionary &)
Find the preconditioner name (directly or from a sub-dictionary)
Definition:
lduMatrixPreconditioner.C:43
Foam::word
A class for handling words, derived from Foam::string.
Definition:
word.H:62
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::lduMatrix::symmetric
bool symmetric() const
Definition:
lduMatrix.H:622
Foam::lduMatrix::preconditioner::New
static autoPtr< preconditioner > New(const solver &sol, const dictionary &solverControls)
Return a new preconditioner.
Definition:
lduMatrixPreconditioner.C:68
Foam::lduMatrix::solver::matrix
const lduMatrix & matrix() const
Definition:
lduMatrix.H:231
Foam::FatalIOError
IOerror FatalIOError
Foam::lduMatrix::solver
Abstract base-class for lduMatrix solvers.
Definition:
lduMatrix.H:97
lduMatrix.H
Foam::dictionary::lookupEntry
const entry & lookupEntry(const word &keyword, enum keyType::option matchOpt) const
Search for an entry (const access) with the given keyword.
Definition:
dictionary.C:404
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition:
error.H:397
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition:
complex.C:76
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition:
dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition:
errorManip.H:130
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition:
HashPtrTable.H:53
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition:
createFields.H:11
Foam::lduMatrix::asymmetric
bool asymmetric() const
Definition:
lduMatrix.H:627
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition:
error.H:392
src
OpenFOAM
matrices
lduMatrix
lduMatrix
lduMatrixPreconditioner.C
Generated by
1.8.17
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.