lduMatrixSmoother.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "lduMatrix.H"
27 #include "noSmoother.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
35 }
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
41 (
42  const dictionary& solverControls
43 )
44 {
45  word name;
46 
47  // handle primitive or dictionary entry
48  const entry& e = solverControls.lookupEntry("smoother", false, false);
49  if (e.isDict())
50  {
51  e.dict().lookup("smoother") >> name;
52  }
53  else
54  {
55  e.stream() >> name;
56  }
57 
58  return name;
59 }
60 
61 
63 (
64  const word& fieldName,
65  const lduMatrix& matrix,
66  const FieldField<Field, scalar>& interfaceBouCoeffs,
67  const FieldField<Field, scalar>& interfaceIntCoeffs,
68  const lduInterfaceFieldPtrsList& interfaces,
69  const dictionary& solverControls
70 )
71 {
72  word name;
73 
74  // handle primitive or dictionary entry
75  const entry& e = solverControls.lookupEntry("smoother", false, false);
76  if (e.isDict())
77  {
78  e.dict().lookup("smoother") >> name;
79  }
80  else
81  {
82  e.stream() >> name;
83  }
84 
85  // not (yet?) needed:
86  // const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
87 
88  if (matrix.diagonal())
89  {
91  (
92  new noSmoother
93  (
94  fieldName,
95  matrix,
96  interfaceBouCoeffs,
97  interfaceIntCoeffs,
98  interfaces
99  )
100  );
101  }
102  else if (matrix.symmetric())
103  {
104  symMatrixConstructorTable::iterator constructorIter =
105  symMatrixConstructorTablePtr_->find(name);
106 
107  if (constructorIter == symMatrixConstructorTablePtr_->end())
108  {
109  FatalIOErrorInFunction(solverControls)
110  << "Unknown symmetric matrix smoother "
111  << name << nl << nl
112  << "Valid symmetric matrix smoothers are :" << endl
113  << symMatrixConstructorTablePtr_->sortedToc()
114  << exit(FatalIOError);
115  }
116 
118  (
119  constructorIter()
120  (
121  fieldName,
122  matrix,
123  interfaceBouCoeffs,
124  interfaceIntCoeffs,
125  interfaces
126  )
127  );
128  }
129  else if (matrix.asymmetric())
130  {
131  asymMatrixConstructorTable::iterator constructorIter =
132  asymMatrixConstructorTablePtr_->find(name);
133 
134  if (constructorIter == asymMatrixConstructorTablePtr_->end())
135  {
136  FatalIOErrorInFunction(solverControls)
137  << "Unknown asymmetric matrix smoother "
138  << name << nl << nl
139  << "Valid asymmetric matrix smoothers are :" << endl
140  << asymMatrixConstructorTablePtr_->sortedToc()
141  << exit(FatalIOError);
142  }
143 
145  (
146  constructorIter()
147  (
148  fieldName,
149  matrix,
150  interfaceBouCoeffs,
151  interfaceIntCoeffs,
152  interfaces
153  )
154  );
155  }
156  else
157  {
158  FatalIOErrorInFunction(solverControls)
159  << "cannot solve incomplete matrix, "
160  "no diagonal or off-diagonal coefficient"
161  << exit(FatalIOError);
162 
163  return autoPtr<lduMatrix::smoother>(nullptr);
164  }
165 }
166 
167 
168 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
169 
171 (
172  const word& fieldName,
173  const lduMatrix& matrix,
174  const FieldField<Field, scalar>& interfaceBouCoeffs,
175  const FieldField<Field, scalar>& interfaceIntCoeffs,
176  const lduInterfaceFieldPtrsList& interfaces
177 )
178 :
179  fieldName_(fieldName),
180  matrix_(matrix),
181  interfaceBouCoeffs_(interfaceBouCoeffs),
182  interfaceIntCoeffs_(interfaceIntCoeffs),
183  interfaces_(interfaces)
184 {}
185 
186 
187 // ************************************************************************* //
Generic field type.
Definition: FieldField.H:77
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
Definition: dictionary.C:626
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:68
Abstract base-class for lduMatrix smoothers.
Definition: lduMatrix.H:271
smoother(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces)
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.
static word getName(const dictionary &)
Find the smoother name (directly or from a sub-dictionary)
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Definition: lduMatrix.H:80
bool symmetric() const
Definition: lduMatrix.H:609
bool diagonal() const
Definition: lduMatrix.H:595
bool asymmetric() const
Definition: lduMatrix.H:623
A lduMatrix::smoother that does nothing. Not on the selection table. Only used by GAMG in the event t...
Definition: noSmoother.H:52
A class for handling words, derived from string.
Definition: word.H:63
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
const doubleScalar e
Definition: doubleScalar.H:106
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
defineRunTimeSelectionTable(fvConstraint, dictionary)
IOerror FatalIOError
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
static const char nl
Definition: Ostream.H:297