GaussSeidelSmoother.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 "GaussSeidelSmoother.H"
00028
00029
00030
00031 namespace Foam
00032 {
00033 defineTypeNameAndDebug(GaussSeidelSmoother, 0);
00034
00035 lduMatrix::smoother::addsymMatrixConstructorToTable<GaussSeidelSmoother>
00036 addGaussSeidelSmootherSymMatrixConstructorToTable_;
00037
00038 lduMatrix::smoother::addasymMatrixConstructorToTable<GaussSeidelSmoother>
00039 addGaussSeidelSmootherAsymMatrixConstructorToTable_;
00040 }
00041
00042
00043
00044
00045 Foam::GaussSeidelSmoother::GaussSeidelSmoother
00046 (
00047 const word& fieldName,
00048 const lduMatrix& matrix,
00049 const FieldField<Field, scalar>& interfaceBouCoeffs,
00050 const FieldField<Field, scalar>& interfaceIntCoeffs,
00051 const lduInterfaceFieldPtrsList& interfaces
00052 )
00053 :
00054 lduMatrix::smoother
00055 (
00056 fieldName,
00057 matrix,
00058 interfaceBouCoeffs,
00059 interfaceIntCoeffs,
00060 interfaces
00061 )
00062 {}
00063
00064
00065
00066
00067 void Foam::GaussSeidelSmoother::smooth
00068 (
00069 const word& fieldName_,
00070 scalarField& psi,
00071 const lduMatrix& matrix_,
00072 const scalarField& source,
00073 const FieldField<Field, scalar>& interfaceBouCoeffs_,
00074 const lduInterfaceFieldPtrsList& interfaces_,
00075 const direction cmpt,
00076 const label nSweeps
00077 )
00078 {
00079 register scalar* __restrict__ psiPtr = psi.begin();
00080
00081 register const label nCells = psi.size();
00082
00083 scalarField bPrime(nCells);
00084 register scalar* __restrict__ bPrimePtr = bPrime.begin();
00085
00086 register const scalar* const __restrict__ diagPtr = matrix_.diag().begin();
00087 register const scalar* const __restrict__ upperPtr =
00088 matrix_.upper().begin();
00089 register const scalar* const __restrict__ lowerPtr =
00090 matrix_.lower().begin();
00091
00092 register const label* const __restrict__ uPtr =
00093 matrix_.lduAddr().upperAddr().begin();
00094
00095 register const label* const __restrict__ ownStartPtr =
00096 matrix_.lduAddr().ownerStartAddr().begin();
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 FieldField<Field, scalar> mBouCoeffs(interfaceBouCoeffs_.size());
00112
00113 forAll(mBouCoeffs, patchi)
00114 {
00115 if (interfaces_.set(patchi))
00116 {
00117 mBouCoeffs.set(patchi, -interfaceBouCoeffs_[patchi]);
00118 }
00119 }
00120
00121 for (label sweep=0; sweep<nSweeps; sweep++)
00122 {
00123 bPrime = source;
00124
00125 matrix_.initMatrixInterfaces
00126 (
00127 mBouCoeffs,
00128 interfaces_,
00129 psi,
00130 bPrime,
00131 cmpt
00132 );
00133
00134 matrix_.updateMatrixInterfaces
00135 (
00136 mBouCoeffs,
00137 interfaces_,
00138 psi,
00139 bPrime,
00140 cmpt
00141 );
00142
00143 register scalar curPsi;
00144 register label fStart;
00145 register label fEnd = ownStartPtr[0];
00146
00147 for (register label cellI=0; cellI<nCells; cellI++)
00148 {
00149
00150 fStart = fEnd;
00151 fEnd = ownStartPtr[cellI + 1];
00152
00153
00154 curPsi = bPrimePtr[cellI];
00155
00156
00157 for (register label curFace=fStart; curFace<fEnd; curFace++)
00158 {
00159 curPsi -= upperPtr[curFace]*psiPtr[uPtr[curFace]];
00160 }
00161
00162
00163 curPsi /= diagPtr[cellI];
00164
00165
00166 for (register label curFace=fStart; curFace<fEnd; curFace++)
00167 {
00168 bPrimePtr[uPtr[curFace]] -= lowerPtr[curFace]*curPsi;
00169 }
00170
00171 psiPtr[cellI] = curPsi;
00172 }
00173 }
00174 }
00175
00176
00177 void Foam::GaussSeidelSmoother::smooth
00178 (
00179 scalarField& psi,
00180 const scalarField& source,
00181 const direction cmpt,
00182 const label nSweeps
00183 ) const
00184 {
00185 smooth
00186 (
00187 fieldName_,
00188 psi,
00189 matrix_,
00190 source,
00191 interfaceBouCoeffs_,
00192 interfaces_,
00193 cmpt,
00194 nSweeps
00195 );
00196 }
00197
00198
00199
Copyright © 2000-2009 OpenCFD Ltd