Loading...
Searching...
No Matches
lduMatrixSmoother.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-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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\*---------------------------------------------------------------------------*/
29#include "lduMatrix.H"
30
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33namespace Foam
34{
37}
38
39// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40
43(
44 const dictionary& solverControls
45)
46{
47 word name;
48
49 // Handle primitive or dictionary entry
50 const entry& e =
51 solverControls.lookupEntry("smoother", keyType::LITERAL);
52
53 if (e.isDict())
54 {
55 e.dict().readEntry("smoother", name);
56 }
57 else
58 {
59 e.stream() >> name;
60 }
61
62 return name;
63}
64
65
67(
68 const word& fieldName,
69 const lduMatrix& matrix,
70 const FieldField<Field, scalar>& interfaceBouCoeffs,
71 const FieldField<Field, scalar>& interfaceIntCoeffs,
72 const lduInterfaceFieldPtrsList& interfaces,
73 const dictionary& solverControls
74)
75{
76 word name;
77
78 // Handle primitive or dictionary entry
79 const entry& e =
80 solverControls.lookupEntry("smoother", keyType::LITERAL);
81
82 if (e.isDict())
83 {
84 e.dict().readEntry("smoother", name);
85 }
86 else
87 {
88 e.stream() >> name;
89 }
90
91 const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
92
93 if (matrix.symmetric())
94 {
95 auto* ctorPtr = symMatrixConstructorTable(name);
96
97 if (!ctorPtr)
98 {
100 (
101 solverControls,
102 "symmetric matrix smoother",
103 name,
104 *symMatrixConstructorTablePtr_
105 ) << exit(FatalIOError);
106 }
107
108 return autoPtr<lduMatrix::smoother>
109 (
110 ctorPtr
111 (
112 fieldName,
113 matrix,
114 interfaceBouCoeffs,
115 interfaceIntCoeffs,
116 interfaces,
117 controls
118 )
119 );
120 }
121 else if (matrix.asymmetric())
122 {
123 auto* ctorPtr = asymMatrixConstructorTable(name);
124
125 if (!ctorPtr)
126 {
128 (
129 solverControls,
130 "asymmetric matrix smoother",
131 name,
132 *asymMatrixConstructorTablePtr_
133 ) << exit(FatalIOError);
134 }
135
136 return autoPtr<lduMatrix::smoother>
137 (
138 ctorPtr
139 (
140 fieldName,
141 matrix,
142 interfaceBouCoeffs,
143 interfaceIntCoeffs,
144 interfaces,
145 controls
146 )
147 );
148 }
149
150 FatalIOErrorInFunction(solverControls)
151 << "cannot solve incomplete matrix, "
152 "no diagonal or off-diagonal coefficient"
153 << exit(FatalIOError);
155 return nullptr;
156}
157
158
159// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
160
162(
163 const word& fieldName,
164 const lduMatrix& matrix,
165 const FieldField<Field, scalar>& interfaceBouCoeffs,
166 const FieldField<Field, scalar>& interfaceIntCoeffs,
167 const lduInterfaceFieldPtrsList& interfaces
168)
169:
170 fieldName_(fieldName),
171 matrix_(matrix),
172 interfaceBouCoeffs_(interfaceBouCoeffs),
173 interfaceIntCoeffs_(interfaceIntCoeffs),
174 interfaces_(interfaces)
175{}
176
177
178// ************************************************************************* //
A field of fields is a PtrList of fields with reference counting.
Definition FieldField.H:77
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const entry & lookupEntry(const word &keyword, enum keyType::option matchOpt) const
Search for an entry (const access) with the given keyword.
Definition dictionary.C:347
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition dictionary.H:487
A keyword and a list of tokens is an 'entry'.
Definition entry.H:66
virtual bool isDict() const noexcept
True if this entry is a dictionary.
Definition entry.H:284
@ LITERAL
String literal.
Definition keyType.H:82
Abstract base-class for lduMatrix smoothers.
Definition lduMatrix.H:410
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
Definition lduMatrix.H:538
const lduMatrix & matrix_
Definition lduMatrix.H:416
const lduInterfaceFieldPtrsList & interfaces_
Definition lduMatrix.H:419
smoother(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces)
Construct for given field name, matrix etc.
const lduInterfaceFieldPtrsList & interfaces() const noexcept
Definition lduMatrix.H:543
const FieldField< Field, scalar > & interfaceBouCoeffs_
Definition lduMatrix.H:417
const lduMatrix & matrix() const noexcept
Definition lduMatrix.H:528
static autoPtr< smoother > New(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls)
Return a new smoother.
const FieldField< Field, scalar > & interfaceIntCoeffs_
Definition lduMatrix.H:418
static word getName(const dictionary &)
Find the smoother name (directly or from a sub-dictionary).
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
Definition lduMatrix.H:533
const word & fieldName() const noexcept
Definition lduMatrix.H:523
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Definition lduMatrix.H:81
lduMatrix(const lduMesh &mesh)
Construct (without coefficients) for an LDU addressed mesh.
Definition lduMatrix.C:54
bool asymmetric() const noexcept
Matrix is asymmetric (ie, full).
Definition lduMatrix.H:850
bool symmetric() const noexcept
Matrix is symmetric.
Definition lduMatrix.H:842
A class for handling words, derived from Foam::string.
Definition word.H:66
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition error.H:637
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
auto & name
Namespace for OpenFOAM.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
volScalarField & e