OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

lduMatrixSmoother.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "lduMatrix.H"
00028 
00029 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033     defineRunTimeSelectionTable(lduMatrix::smoother, symMatrix);
00034     defineRunTimeSelectionTable(lduMatrix::smoother, asymMatrix);
00035 }
00036 
00037 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00038 
00039 Foam::word
00040 Foam::lduMatrix::smoother::getName
00041 (
00042     const dictionary& solverControls
00043 )
00044 {
00045     word name;
00046 
00047     // handle primitive or dictionary entry
00048     const entry& e = solverControls.lookupEntry("smoother", false, false);
00049     if (e.isDict())
00050     {
00051         e.dict().lookup("smoother") >> name;
00052     }
00053     else
00054     {
00055         e.stream() >> name;
00056     }
00057 
00058     return name;
00059 }
00060 
00061 
00062 Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
00063 (
00064     const word& fieldName,
00065     const lduMatrix& matrix,
00066     const FieldField<Field, scalar>& interfaceBouCoeffs,
00067     const FieldField<Field, scalar>& interfaceIntCoeffs,
00068     const lduInterfaceFieldPtrsList& interfaces,
00069     const dictionary& solverControls
00070 )
00071 {
00072     word name;
00073 
00074     // handle primitive or dictionary entry
00075     const entry& e = solverControls.lookupEntry("smoother", false, false);
00076     if (e.isDict())
00077     {
00078         e.dict().lookup("smoother") >> name;
00079     }
00080     else
00081     {
00082         e.stream() >> name;
00083     }
00084 
00085     // not (yet?) needed:
00086     // const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
00087 
00088     if (matrix.symmetric())
00089     {
00090         symMatrixConstructorTable::iterator constructorIter =
00091             symMatrixConstructorTablePtr_->find(name);
00092 
00093         if (constructorIter == symMatrixConstructorTablePtr_->end())
00094         {
00095             FatalIOErrorIn
00096             (
00097                 "lduMatrix::smoother::New", solverControls
00098             )   << "Unknown symmetric matrix smoother "
00099                 << name << nl << nl
00100                 << "Valid symmetric matrix smoothers are :" << endl
00101                 << symMatrixConstructorTablePtr_->toc()
00102                 << exit(FatalIOError);
00103         }
00104 
00105         return autoPtr<lduMatrix::smoother>
00106         (
00107             constructorIter()
00108             (
00109                 fieldName,
00110                 matrix,
00111                 interfaceBouCoeffs,
00112                 interfaceIntCoeffs,
00113                 interfaces
00114             )
00115         );
00116     }
00117     else if (matrix.asymmetric())
00118     {
00119         asymMatrixConstructorTable::iterator constructorIter =
00120             asymMatrixConstructorTablePtr_->find(name);
00121 
00122         if (constructorIter == asymMatrixConstructorTablePtr_->end())
00123         {
00124             FatalIOErrorIn
00125             (
00126                 "lduMatrix::smoother::New", solverControls
00127             )   << "Unknown asymmetric matrix smoother "
00128                 << name << nl << nl
00129                 << "Valid asymmetric matrix smoothers are :" << endl
00130                 << asymMatrixConstructorTablePtr_->toc()
00131                 << exit(FatalIOError);
00132         }
00133 
00134         return autoPtr<lduMatrix::smoother>
00135         (
00136             constructorIter()
00137             (
00138                 fieldName,
00139                 matrix,
00140                 interfaceBouCoeffs,
00141                 interfaceIntCoeffs,
00142                 interfaces
00143             )
00144         );
00145     }
00146     else
00147     {
00148         FatalIOErrorIn
00149         (
00150             "lduMatrix::smoother::New", solverControls
00151         )   << "cannot solve incomplete matrix, "
00152                "no diagonal or off-diagonal coefficient"
00153             << exit(FatalIOError);
00154 
00155         return autoPtr<lduMatrix::smoother>(NULL);
00156     }
00157 }
00158 
00159 
00160 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00161 
00162 Foam::lduMatrix::smoother::smoother
00163 (
00164     const word& fieldName,
00165     const lduMatrix& matrix,
00166     const FieldField<Field, scalar>& interfaceBouCoeffs,
00167     const FieldField<Field, scalar>& interfaceIntCoeffs,
00168     const lduInterfaceFieldPtrsList& interfaces
00169 )
00170 :
00171     fieldName_(fieldName),
00172     matrix_(matrix),
00173     interfaceBouCoeffs_(interfaceBouCoeffs),
00174     interfaceIntCoeffs_(interfaceIntCoeffs),
00175     interfaces_(interfaces)
00176 {}
00177 
00178 
00179 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd