1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "lduMatrix.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 defineRunTimeSelectionTable(lduMatrix::preconditioner, symMatrix);
34 defineRunTimeSelectionTable(lduMatrix::preconditioner, asymMatrix);
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 Foam::lduMatrix::preconditioner::getName
43 const dictionary& solverControls
48 // handle primitive or dictionary entry
49 const entry& e = solverControls.lookupEntry("preconditioner", false, false);
52 e.dict().lookup("preconditioner") >> name;
63 Foam::autoPtr<Foam::lduMatrix::preconditioner>
64 Foam::lduMatrix::preconditioner::New
67 const dictionary& solverControls
72 // handle primitive or dictionary entry
73 const entry& e = solverControls.lookupEntry("preconditioner", false, false);
76 e.dict().lookup("preconditioner") >> name;
83 const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
85 if (sol.matrix().symmetric())
87 symMatrixConstructorTable::iterator constructorIter =
88 symMatrixConstructorTablePtr_->find(name);
90 if (constructorIter == symMatrixConstructorTablePtr_->end())
94 "lduMatrix::preconditioner::New"
95 "(const solver&, const dictionary&)",
97 ) << "Unknown symmetric matrix preconditioner "
99 << "Valid symmetric matrix preconditioners :" << endl
100 << symMatrixConstructorTablePtr_->toc()
101 << exit(FatalIOError);
104 return autoPtr<lduMatrix::preconditioner>
113 else if (sol.matrix().asymmetric())
115 asymMatrixConstructorTable::iterator constructorIter =
116 asymMatrixConstructorTablePtr_->find(name);
118 if (constructorIter == asymMatrixConstructorTablePtr_->end())
122 "lduMatrix::preconditioner::New"
123 "(const solver&, const dictionary&)",
125 ) << "Unknown asymmetric matrix preconditioner "
127 << "Valid asymmetric matrix preconditioners :" << endl
128 << asymMatrixConstructorTablePtr_->toc()
129 << exit(FatalIOError);
132 return autoPtr<lduMatrix::preconditioner>
145 "lduMatrix::preconditioner::New"
146 "(const solver&, const dictionary&)",
148 ) << "cannot solve incomplete matrix, "
149 "no diagonal or off-diagonal coefficient"
150 << exit(FatalIOError);
152 return autoPtr<lduMatrix::preconditioner>(NULL);
157 // ************************************************************************* //