Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #include <OpenFOAM/lduMatrix.H>
00027 
00028 
00029 
00030 namespace Foam
00031 {
00032     defineRunTimeSelectionTable(lduMatrix::preconditioner, symMatrix);
00033     defineRunTimeSelectionTable(lduMatrix::preconditioner, asymMatrix);
00034 }
00035 
00036 
00037 
00038 
00039 Foam::word
00040 Foam::lduMatrix::preconditioner::getName
00041 (
00042     const dictionary& solverControls
00043 )
00044 {
00045     word name;
00046 
00047     
00048     const entry& e = solverControls.lookupEntry("preconditioner", false, false);
00049     if (e.isDict())
00050     {
00051         e.dict().lookup("preconditioner") >> name;
00052     }
00053     else
00054     {
00055         e.stream() >> name;
00056     }
00057 
00058     return name;
00059 }
00060 
00061 
00062 Foam::autoPtr<Foam::lduMatrix::preconditioner>
00063 Foam::lduMatrix::preconditioner::New
00064 (
00065     const solver& sol,
00066     const dictionary& solverControls
00067 )
00068 {
00069     word name;
00070 
00071     
00072     const entry& e = solverControls.lookupEntry("preconditioner", false, false);
00073     if (e.isDict())
00074     {
00075         e.dict().lookup("preconditioner") >> name;
00076     }
00077     else
00078     {
00079         e.stream() >> name;
00080     }
00081 
00082     const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
00083 
00084     if (sol.matrix().symmetric())
00085     {
00086         symMatrixConstructorTable::iterator constructorIter =
00087             symMatrixConstructorTablePtr_->find(name);
00088 
00089         if (constructorIter == symMatrixConstructorTablePtr_->end())
00090         {
00091             FatalIOErrorIn
00092             (
00093                 "lduMatrix::preconditioner::New"
00094                 "(const solver&, const dictionary&)",
00095                 controls
00096             )   << "Unknown symmetric matrix preconditioner "
00097                 << name << nl << nl
00098                 << "Valid symmetric matrix preconditioners :" << endl
00099                 << symMatrixConstructorTablePtr_->sortedToc()
00100                 << exit(FatalIOError);
00101         }
00102 
00103         return autoPtr<lduMatrix::preconditioner>
00104         (
00105             constructorIter()
00106             (
00107                 sol,
00108                 controls
00109             )
00110         );
00111     }
00112     else if (sol.matrix().asymmetric())
00113     {
00114         asymMatrixConstructorTable::iterator constructorIter =
00115             asymMatrixConstructorTablePtr_->find(name);
00116 
00117         if (constructorIter == asymMatrixConstructorTablePtr_->end())
00118         {
00119             FatalIOErrorIn
00120             (
00121                 "lduMatrix::preconditioner::New"
00122                 "(const solver&, const dictionary&)",
00123                 controls
00124             )   << "Unknown asymmetric matrix preconditioner "
00125                 << name << nl << nl
00126                 << "Valid asymmetric matrix preconditioners :" << endl
00127                 << asymMatrixConstructorTablePtr_->sortedToc()
00128                 << exit(FatalIOError);
00129         }
00130 
00131         return autoPtr<lduMatrix::preconditioner>
00132         (
00133             constructorIter()
00134             (
00135                 sol,
00136                 controls
00137             )
00138         );
00139     }
00140     else
00141     {
00142         FatalIOErrorIn
00143         (
00144             "lduMatrix::preconditioner::New"
00145             "(const solver&, const dictionary&)",
00146             controls
00147         )   << "cannot solve incomplete matrix, "
00148                "no diagonal or off-diagonal coefficient"
00149             << exit(FatalIOError);
00150 
00151         return autoPtr<lduMatrix::preconditioner>(NULL);
00152     }
00153 }
00154 
00155 
00156