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