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-2018 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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 template<class Type, class DType, class LUType>
33 (
34  const word& fieldName,
35  const LduMatrix<Type, DType, LUType>& matrix,
36  const dictionary& smootherDict
37 )
38 {
39  word smootherName = smootherDict.lookup("smoother");
40 
41  if (matrix.symmetric())
42  {
43  typename symMatrixConstructorTable::iterator constructorIter =
44  symMatrixConstructorTablePtr_->find(smootherName);
45 
46  if (constructorIter == symMatrixConstructorTablePtr_->end())
47  {
48  FatalIOErrorInFunction(smootherDict)
49  << "Unknown symmetric matrix smoother " << smootherName
50  << endl << endl
51  << "Valid symmetric matrix smoothers are :" << endl
52  << symMatrixConstructorTablePtr_->toc()
53  << exit(FatalIOError);
54  }
55 
57  (
58  constructorIter()
59  (
60  fieldName,
61  matrix
62  )
63  );
64  }
65  else if (matrix.asymmetric())
66  {
67  typename asymMatrixConstructorTable::iterator constructorIter =
68  asymMatrixConstructorTablePtr_->find(smootherName);
69 
70  if (constructorIter == asymMatrixConstructorTablePtr_->end())
71  {
72  FatalIOErrorInFunction(smootherDict)
73  << "Unknown asymmetric matrix smoother " << smootherName
74  << endl << endl
75  << "Valid asymmetric matrix smoothers are :" << endl
76  << asymMatrixConstructorTablePtr_->toc()
77  << exit(FatalIOError);
78  }
79 
81  (
82  constructorIter()
83  (
84  fieldName,
85  matrix
86  )
87  );
88  }
89  else
90  {
91  FatalIOErrorInFunction(smootherDict)
92  << "cannot solve incomplete matrix, no off-diagonal coefficients"
93  << exit(FatalIOError);
94 
96  (
97  nullptr
98  );
99  }
100 }
101 
102 
103 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
104 
105 template<class Type, class DType, class LUType>
107 (
108  const word& fieldName,
109  const LduMatrix<Type, DType, LUType>& matrix
110 )
111 :
112  fieldName_(fieldName),
113  matrix_(matrix)
114 {}
115 
116 
117 // ************************************************************************* //
smoother(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix)
bool symmetric() const
Definition: LduMatrix.H:581
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
static autoPtr< smoother > New(const word &fieldName, const LduMatrix< Type, DType, LUType > &matrix, const dictionary &smootherDict)
Return a new smoother.
A class for handling words, derived from string.
Definition: word.H:59
bool asymmetric() const
Definition: LduMatrix.H:586
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:331
LduMatrix is a general matrix class in which the coefficients are stored as three arrays...
Definition: LduMatrix.H:69
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:576
IOerror FatalIOError