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/GAMGPreconditioner.H>
00027 
00028 
00029 
00030 namespace Foam
00031 {
00032     defineTypeNameAndDebug(GAMGPreconditioner, 0);
00033 
00034     lduMatrix::preconditioner::addsymMatrixConstructorToTable
00035     <GAMGPreconditioner> addGAMGPreconditionerSymMatrixConstructorToTable_;
00036 
00037     lduMatrix::preconditioner::addasymMatrixConstructorToTable
00038     <GAMGPreconditioner> addGAMGPreconditionerAsymMatrixConstructorToTable_;
00039 }
00040 
00041 
00042 
00043 
00044 Foam::GAMGPreconditioner::GAMGPreconditioner
00045 (
00046     const lduMatrix::solver& sol,
00047     const dictionary& solverControls
00048 )
00049 :
00050     GAMGSolver
00051     (
00052         sol.fieldName(),
00053         sol.matrix(),
00054         sol.interfaceBouCoeffs(),
00055         sol.interfaceIntCoeffs(),
00056         sol.interfaces(),
00057         solverControls
00058     ),
00059     lduMatrix::preconditioner(sol),
00060     nVcycles_(2)
00061 {
00062     readControls();
00063 }
00064 
00065 
00066 
00067 
00068 Foam::GAMGPreconditioner::~GAMGPreconditioner()
00069 {}
00070 
00071 
00072 
00073 
00074 void Foam::GAMGPreconditioner::readControls()
00075 {
00076     GAMGSolver::readControls();
00077     nVcycles_ = controlDict_.lookupOrDefault<label>("nVcycles", 2);
00078 }
00079 
00080 
00081 void Foam::GAMGPreconditioner::precondition
00082 (
00083     scalarField& wA,
00084     const scalarField& rA,
00085     const direction cmpt
00086 ) const
00087 {
00088     wA = 0.0;
00089     scalarField AwA(wA.size());
00090     scalarField finestCorrection(wA.size());
00091     scalarField finestResidual(rA);
00092 
00093     
00094     PtrList<scalarField> coarseCorrFields;
00095 
00096     
00097     PtrList<scalarField> coarseSources;
00098 
00099     
00100     PtrList<lduMatrix::smoother> smoothers;
00101 
00102     
00103     initVcycle(coarseCorrFields, coarseSources, smoothers);
00104 
00105     for (label cycle=0; cycle<nVcycles_; cycle++)
00106     {
00107         Vcycle
00108         (
00109             smoothers,
00110             wA,
00111             rA,
00112             AwA,
00113             finestCorrection,
00114             finestResidual,
00115             coarseCorrFields,
00116             coarseSources,
00117             cmpt
00118         );
00119 
00120         if (cycle < nVcycles_-1)
00121         {
00122             
00123             matrix_.Amul(AwA, wA, interfaceBouCoeffs_, interfaces_, cmpt);
00124             finestResidual = rA;
00125             finestResidual -= AwA;
00126         }
00127     }
00128 }
00129 
00130 
00131