initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / matrices / lduMatrix / lduMatrix / lduMatrixSmoother.C
blob4ce5381fb18e76a938cb0dec61c4fdf803f153b3
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 "lduMatrix.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 namespace Foam
33     defineRunTimeSelectionTable(lduMatrix::smoother, symMatrix);
34     defineRunTimeSelectionTable(lduMatrix::smoother, asymMatrix);
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 Foam::word
40 Foam::lduMatrix::smoother::getName
42     const dictionary& solverControls
45     word name;
47     // handle primitive or dictionary entry
48     const entry& e = solverControls.lookupEntry("smoother", false, false);
49     if (e.isDict())
50     {
51         e.dict().lookup("smoother") >> name;
52     }
53     else
54     {
55         e.stream() >> name;
56     }
58     return name;
62 Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
64     const word& fieldName,
65     const lduMatrix& matrix,
66     const FieldField<Field, scalar>& interfaceBouCoeffs,
67     const FieldField<Field, scalar>& interfaceIntCoeffs,
68     const lduInterfaceFieldPtrsList& interfaces,
69     const dictionary& solverControls
72     word name;
74     // handle primitive or dictionary entry
75     const entry& e = solverControls.lookupEntry("smoother", false, false);
76     if (e.isDict())
77     {
78         e.dict().lookup("smoother") >> name;
79     }
80     else
81     {
82         e.stream() >> name;
83     }
85     // not (yet?) needed:
86     // const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
88     if (matrix.symmetric())
89     {
90         symMatrixConstructorTable::iterator constructorIter =
91             symMatrixConstructorTablePtr_->find(name);
93         if (constructorIter == symMatrixConstructorTablePtr_->end())
94         {
95             FatalIOErrorIn
96             (
97                 "lduMatrix::smoother::New", solverControls
98             )   << "Unknown symmetric matrix smoother "
99                 << name << nl << nl
100                 << "Valid symmetric matrix smoothers are :" << endl
101                 << symMatrixConstructorTablePtr_->toc()
102                 << exit(FatalIOError);
103         }
105         return autoPtr<lduMatrix::smoother>
106         (
107             constructorIter()
108             (
109                 fieldName,
110                 matrix,
111                 interfaceBouCoeffs,
112                 interfaceIntCoeffs,
113                 interfaces
114             )
115         );
116     }
117     else if (matrix.asymmetric())
118     {
119         asymMatrixConstructorTable::iterator constructorIter =
120             asymMatrixConstructorTablePtr_->find(name);
122         if (constructorIter == asymMatrixConstructorTablePtr_->end())
123         {
124             FatalIOErrorIn
125             (
126                 "lduMatrix::smoother::New", solverControls
127             )   << "Unknown asymmetric matrix smoother "
128                 << name << nl << nl
129                 << "Valid asymmetric matrix smoothers are :" << endl
130                 << asymMatrixConstructorTablePtr_->toc()
131                 << exit(FatalIOError);
132         }
134         return autoPtr<lduMatrix::smoother>
135         (
136             constructorIter()
137             (
138                 fieldName,
139                 matrix,
140                 interfaceBouCoeffs,
141                 interfaceIntCoeffs,
142                 interfaces
143             )
144         );
145     }
146     else
147     {
148         FatalIOErrorIn
149         (
150             "lduMatrix::smoother::New", solverControls
151         )   << "cannot solve incomplete matrix, "
152                "no diagonal or off-diagonal coefficient"
153             << exit(FatalIOError);
155         return autoPtr<lduMatrix::smoother>(NULL);
156     }
160 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
162 Foam::lduMatrix::smoother::smoother
164     const word& fieldName,
165     const lduMatrix& matrix,
166     const FieldField<Field, scalar>& interfaceBouCoeffs,
167     const FieldField<Field, scalar>& interfaceIntCoeffs,
168     const lduInterfaceFieldPtrsList& interfaces
171     fieldName_(fieldName),
172     matrix_(matrix),
173     interfaceBouCoeffs_(interfaceBouCoeffs),
174     interfaceIntCoeffs_(interfaceIntCoeffs),
175     interfaces_(interfaces)
179 // ************************************************************************* //