FreeFOAM The Cross-Platform CFD Toolkit
lduMatrixPreconditioner.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::preconditioner, symMatrix);
33  defineRunTimeSelectionTable(lduMatrix::preconditioner, asymMatrix);
34 }
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("preconditioner", false, false);
49  if (e.isDict())
50  {
51  e.dict().lookup("preconditioner") >> name;
52  }
53  else
54  {
55  e.stream() >> name;
56  }
57 
58  return name;
59 }
60 
61 
64 (
65  const solver& sol,
66  const dictionary& solverControls
67 )
68 {
69  word name;
70 
71  // handle primitive or dictionary entry
72  const entry& e = solverControls.lookupEntry("preconditioner", false, false);
73  if (e.isDict())
74  {
75  e.dict().lookup("preconditioner") >> name;
76  }
77  else
78  {
79  e.stream() >> name;
80  }
81 
82  const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
83 
84  if (sol.matrix().symmetric())
85  {
86  symMatrixConstructorTable::iterator constructorIter =
87  symMatrixConstructorTablePtr_->find(name);
88 
89  if (constructorIter == symMatrixConstructorTablePtr_->end())
90  {
92  (
93  "lduMatrix::preconditioner::New"
94  "(const solver&, const dictionary&)",
95  controls
96  ) << "Unknown symmetric matrix preconditioner "
97  << name << nl << nl
98  << "Valid symmetric matrix preconditioners :" << endl
99  << symMatrixConstructorTablePtr_->sortedToc()
100  << exit(FatalIOError);
101  }
102 
104  (
105  constructorIter()
106  (
107  sol,
108  controls
109  )
110  );
111  }
112  else if (sol.matrix().asymmetric())
113  {
114  asymMatrixConstructorTable::iterator constructorIter =
115  asymMatrixConstructorTablePtr_->find(name);
116 
117  if (constructorIter == asymMatrixConstructorTablePtr_->end())
118  {
120  (
121  "lduMatrix::preconditioner::New"
122  "(const solver&, const dictionary&)",
123  controls
124  ) << "Unknown asymmetric matrix preconditioner "
125  << name << nl << nl
126  << "Valid asymmetric matrix preconditioners :" << endl
127  << asymMatrixConstructorTablePtr_->sortedToc()
128  << exit(FatalIOError);
129  }
130 
132  (
133  constructorIter()
134  (
135  sol,
136  controls
137  )
138  );
139  }
140  else
141  {
143  (
144  "lduMatrix::preconditioner::New"
145  "(const solver&, const dictionary&)",
146  controls
147  ) << "cannot solve incomplete matrix, "
148  "no diagonal or off-diagonal coefficient"
149  << exit(FatalIOError);
150 
152  }
153 }
154 
155 
156 // ************************ vim: set sw=4 sts=4 et: ************************ //