FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include <OpenFOAM/lduMatrix.H>
00027 
00028 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00029 
00030 namespace Foam
00031 {
00032     defineRunTimeSelectionTable(lduMatrix::smoother, symMatrix);
00033     defineRunTimeSelectionTable(lduMatrix::smoother, asymMatrix);
00034 }
00035 
00036 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00037 
00038 Foam::word
00039 Foam::lduMatrix::smoother::getName
00040 (
00041     const dictionary& solverControls
00042 )
00043 {
00044     word name;
00045 
00046     // handle primitive or dictionary entry
00047     const entry& e = solverControls.lookupEntry("smoother", false, false);
00048     if (e.isDict())
00049     {
00050         e.dict().lookup("smoother") >> name;
00051     }
00052     else
00053     {
00054         e.stream() >> name;
00055     }
00056 
00057     return name;
00058 }
00059 
00060 
00061 Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
00062 (
00063     const word& fieldName,
00064     const lduMatrix& matrix,
00065     const FieldField<Field, scalar>& interfaceBouCoeffs,
00066     const FieldField<Field, scalar>& interfaceIntCoeffs,
00067     const lduInterfaceFieldPtrsList& interfaces,
00068     const dictionary& solverControls
00069 )
00070 {
00071     word name;
00072 
00073     // handle primitive or dictionary entry
00074     const entry& e = solverControls.lookupEntry("smoother", false, false);
00075     if (e.isDict())
00076     {
00077         e.dict().lookup("smoother") >> name;
00078     }
00079     else
00080     {
00081         e.stream() >> name;
00082     }
00083 
00084     // not (yet?) needed:
00085     // const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
00086 
00087     if (matrix.symmetric())
00088     {
00089         symMatrixConstructorTable::iterator constructorIter =
00090             symMatrixConstructorTablePtr_->find(name);
00091 
00092         if (constructorIter == symMatrixConstructorTablePtr_->end())
00093         {
00094             FatalIOErrorIn
00095             (
00096                 "lduMatrix::smoother::New", solverControls
00097             )   << "Unknown symmetric matrix smoother "
00098                 << name << nl << nl
00099                 << "Valid symmetric matrix smoothers are :" << endl
00100                 << symMatrixConstructorTablePtr_->sortedToc()
00101                 << exit(FatalIOError);
00102         }
00103 
00104         return autoPtr<lduMatrix::smoother>
00105         (
00106             constructorIter()
00107             (
00108                 fieldName,
00109                 matrix,
00110                 interfaceBouCoeffs,
00111                 interfaceIntCoeffs,
00112                 interfaces
00113             )
00114         );
00115     }
00116     else if (matrix.asymmetric())
00117     {
00118         asymMatrixConstructorTable::iterator constructorIter =
00119             asymMatrixConstructorTablePtr_->find(name);
00120 
00121         if (constructorIter == asymMatrixConstructorTablePtr_->end())
00122         {
00123             FatalIOErrorIn
00124             (
00125                 "lduMatrix::smoother::New", solverControls
00126             )   << "Unknown asymmetric matrix smoother "
00127                 << name << nl << nl
00128                 << "Valid asymmetric matrix smoothers are :" << endl
00129                 << asymMatrixConstructorTablePtr_->sortedToc()
00130                 << exit(FatalIOError);
00131         }
00132 
00133         return autoPtr<lduMatrix::smoother>
00134         (
00135             constructorIter()
00136             (
00137                 fieldName,
00138                 matrix,
00139                 interfaceBouCoeffs,
00140                 interfaceIntCoeffs,
00141                 interfaces
00142             )
00143         );
00144     }
00145     else
00146     {
00147         FatalIOErrorIn
00148         (
00149             "lduMatrix::smoother::New", solverControls
00150         )   << "cannot solve incomplete matrix, "
00151                "no diagonal or off-diagonal coefficient"
00152             << exit(FatalIOError);
00153 
00154         return autoPtr<lduMatrix::smoother>(NULL);
00155     }
00156 }
00157 
00158 
00159 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00160 
00161 Foam::lduMatrix::smoother::smoother
00162 (
00163     const word& fieldName,
00164     const lduMatrix& matrix,
00165     const FieldField<Field, scalar>& interfaceBouCoeffs,
00166     const FieldField<Field, scalar>& interfaceIntCoeffs,
00167     const lduInterfaceFieldPtrsList& interfaces
00168 )
00169 :
00170     fieldName_(fieldName),
00171     matrix_(matrix),
00172     interfaceBouCoeffs_(interfaceBouCoeffs),
00173     interfaceIntCoeffs_(interfaceIntCoeffs),
00174     interfaces_(interfaces)
00175 {}
00176 
00177 
00178 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines