DILUSmoother.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 "DILUSmoother.H"
00028 #include "DILUPreconditioner.H"
00029
00030
00031
00032 namespace Foam
00033 {
00034 defineTypeNameAndDebug(DILUSmoother, 0);
00035
00036 lduMatrix::smoother::addasymMatrixConstructorToTable<DILUSmoother>
00037 addDILUSmootherAsymMatrixConstructorToTable_;
00038 }
00039
00040
00041
00042
00043 Foam::DILUSmoother::DILUSmoother
00044 (
00045 const word& fieldName,
00046 const lduMatrix& matrix,
00047 const FieldField<Field, scalar>& interfaceBouCoeffs,
00048 const FieldField<Field, scalar>& interfaceIntCoeffs,
00049 const lduInterfaceFieldPtrsList& interfaces
00050 )
00051 :
00052 lduMatrix::smoother
00053 (
00054 fieldName,
00055 matrix,
00056 interfaceBouCoeffs,
00057 interfaceIntCoeffs,
00058 interfaces
00059 ),
00060 rD_(matrix_.diag())
00061 {
00062 DILUPreconditioner::calcReciprocalD(rD_, matrix_);
00063 }
00064
00065
00066
00067
00068 void Foam::DILUSmoother::smooth
00069 (
00070 scalarField& psi,
00071 const scalarField& source,
00072 const direction cmpt,
00073 const label nSweeps
00074 ) const
00075 {
00076 const scalar* const __restrict__ rDPtr = rD_.begin();
00077
00078 const label* const __restrict__ uPtr =
00079 matrix_.lduAddr().upperAddr().begin();
00080 const label* const __restrict__ lPtr =
00081 matrix_.lduAddr().lowerAddr().begin();
00082
00083 const scalar* const __restrict__ upperPtr = matrix_.upper().begin();
00084 const scalar* const __restrict__ lowerPtr = matrix_.lower().begin();
00085
00086
00087 scalarField rA(rD_.size());
00088 scalar* __restrict__ rAPtr = rA.begin();
00089
00090 for (label sweep=0; sweep<nSweeps; sweep++)
00091 {
00092 matrix_.residual
00093 (
00094 rA,
00095 psi,
00096 source,
00097 interfaceBouCoeffs_,
00098 interfaces_,
00099 cmpt
00100 );
00101
00102 rA *= rD_;
00103
00104 register label nFaces = matrix_.upper().size();
00105 for (register label face=0; face<nFaces; face++)
00106 {
00107 register label u = uPtr[face];
00108 rAPtr[u] -= rDPtr[u]*lowerPtr[face]*rAPtr[lPtr[face]];
00109 }
00110
00111 register label nFacesM1 = nFaces - 1;
00112 for (register label face=nFacesM1; face>=0; face--)
00113 {
00114 register label l = lPtr[face];
00115 rAPtr[l] -= rDPtr[l]*upperPtr[face]*rAPtr[uPtr[face]];
00116 }
00117
00118 psi += rA;
00119 }
00120 }
00121
00122
00123
Copyright © 2000-2009 OpenCFD Ltd