correction to d4edb38234db8268907f04836d49bb93461b8a88
[OpenFOAM-1.5.x.git] / src / OpenFOAM / matrices / solution / solution.C
blob5429a20e8177fe8365fbdff1ebbcc9df2a5f1aee
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 "solution.H"
28 #include "Time.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 int Foam::solution::debug(Foam::debug::debugSwitch("solution", false));
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 Foam::solution::solution(const objectRegistry& obr, const fileName& dictName)
38     IOdictionary
39     (
40         IOobject
41         (
42             dictName,
43             obr.time().system(),
44             obr,
45             IOobject::MUST_READ,
46             IOobject::NO_WRITE
47         )
48     ),
49     relaxationFactors_(ITstream("relaxationFactors", tokenList())()),
50     solvers_(ITstream("solvers", tokenList())())
52     read();
56 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
58 bool Foam::solution::read()
60     if (regIOobject::read())
61     {
62         const dictionary& dict = solutionDict();
64         if (dict.found("relaxationFactors"))
65         {
66             relaxationFactors_ = dict.subDict("relaxationFactors");
67         }
69         if (dict.found("solvers"))
70         {
71             solvers_ = dict.subDict("solvers");
72         }
74         return true;
75     }
76     else
77     {
78         return false;
79     }
83 const Foam::dictionary& Foam::solution::solutionDict() const
85     if (found("select"))
86     {
87         return subDict(word(lookup("select")));
88     }
89     else
90     {
91         return *this;
92     }
96 bool Foam::solution::relax(const word& name) const
98     if (debug)
99     {
100         Info<< "Lookup relax for " << name << endl;
101     }
103     return relaxationFactors_.found(name);
107 Foam::scalar Foam::solution::relaxationFactor(const word& name) const
109     if (debug)
110     {
111         Info<< "Lookup relaxationFactor for " << name << endl;
112     }
114     return readScalar(relaxationFactors_.lookup(name));
118 const Foam::dictionary& Foam::solution::solverDict(const word& name) const
120     if (debug)
121     {
122         InfoIn("solution::solverDict(const word& name)")
123             << "Lookup solver for " << name << endl;
124     }
126     return solvers_.subDict(name);
130 Foam::ITstream& Foam::solution::solver(const word& name) const
132     if (debug)
133     {
134         InfoIn("solution::solver(const word& name)")
135             << "Lookup solver for " << name << endl;
136     }
138     return solvers_.lookup(name);
142 // ************************************************************************* //