FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/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 // ************************ vim: set sw=4 sts=4 et: ************************ //