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