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 | Copyright (C) 2011 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 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32  defineRunTimeSelectionTable(lduMatrix::smoother, symMatrix);
33  defineRunTimeSelectionTable(lduMatrix::smoother, asymMatrix);
34 }
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
40 (
41  const dictionary& solverControls
42 )
43 {
44  word name;
45 
46  // handle primitive or dictionary entry
47  const entry& e = solverControls.lookupEntry("smoother", false, false);
48  if (e.isDict())
49  {
50  e.dict().lookup("smoother") >> name;
51  }
52  else
53  {
54  e.stream() >> name;
55  }
56 
57  return name;
58 }
59 
60 
62 (
63  const word& fieldName,
64  const lduMatrix& matrix,
65  const FieldField<Field, scalar>& interfaceBouCoeffs,
66  const FieldField<Field, scalar>& interfaceIntCoeffs,
67  const lduInterfaceFieldPtrsList& interfaces,
68  const dictionary& solverControls
69 )
70 {
71  word name;
72 
73  // handle primitive or dictionary entry
74  const entry& e = solverControls.lookupEntry("smoother", false, false);
75  if (e.isDict())
76  {
77  e.dict().lookup("smoother") >> name;
78  }
79  else
80  {
81  e.stream() >> name;
82  }
83 
84  // not (yet?) needed:
85  // const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
86 
87  if (matrix.symmetric())
88  {
89  symMatrixConstructorTable::iterator constructorIter =
90  symMatrixConstructorTablePtr_->find(name);
91 
92  if (constructorIter == symMatrixConstructorTablePtr_->end())
93  {
95  (
96  "lduMatrix::smoother::New", solverControls
97  ) << "Unknown symmetric matrix smoother "
98  << name << nl << nl
99  << "Valid symmetric matrix smoothers are :" << endl
100  << symMatrixConstructorTablePtr_->sortedToc()
101  << exit(FatalIOError);
102  }
103 
105  (
106  constructorIter()
107  (
108  fieldName,
109  matrix,
110  interfaceBouCoeffs,
111  interfaceIntCoeffs,
112  interfaces
113  )
114  );
115  }
116  else if (matrix.asymmetric())
117  {
118  asymMatrixConstructorTable::iterator constructorIter =
119  asymMatrixConstructorTablePtr_->find(name);
120 
121  if (constructorIter == asymMatrixConstructorTablePtr_->end())
122  {
124  (
125  "lduMatrix::smoother::New", solverControls
126  ) << "Unknown asymmetric matrix smoother "
127  << name << nl << nl
128  << "Valid asymmetric matrix smoothers are :" << endl
129  << asymMatrixConstructorTablePtr_->sortedToc()
130  << exit(FatalIOError);
131  }
132 
134  (
135  constructorIter()
136  (
137  fieldName,
138  matrix,
139  interfaceBouCoeffs,
140  interfaceIntCoeffs,
141  interfaces
142  )
143  );
144  }
145  else
146  {
148  (
149  "lduMatrix::smoother::New", solverControls
150  ) << "cannot solve incomplete matrix, "
151  "no diagonal or off-diagonal coefficient"
152  << exit(FatalIOError);
153 
154  return autoPtr<lduMatrix::smoother>(NULL);
155  }
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 // ************************************************************************* //
virtual bool isDict() const
Return true if this entry is a dictionary.
Definition: entry.H:153
Generic field type.
Definition: FieldField.H:51
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static word getName(const dictionary &)
Find the smoother name (directly or from a sub-dictionary)
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
A class for handling words, derived from string.
Definition: word.H:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
virtual ITstream & stream() const =0
Return token stream if this entry is a primitive entry.
static const char nl
Definition: Ostream.H:260
const double e
Elementary charge.
Definition: doubleFloat.H:78
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOerror FatalIOError
bool asymmetric() const
Definition: lduMatrix.H:605
lduMatrix is a general matrix class in which the coefficients are stored as three arrays...
Definition: lduMatrix.H:77
smoother(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces)
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:65
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
bool symmetric() const
Definition: lduMatrix.H:600
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
Definition: dictionary.C:428
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:325
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117