DICSmoother.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 "DICSmoother.H"
00028 #include "DICPreconditioner.H"
00029
00030
00031
00032 namespace Foam
00033 {
00034 defineTypeNameAndDebug(DICSmoother, 0);
00035
00036 lduMatrix::smoother::addsymMatrixConstructorToTable<DICSmoother>
00037 addDICSmootherSymMatrixConstructorToTable_;
00038 }
00039
00040
00041
00042
00043 Foam::DICSmoother::DICSmoother
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 DICPreconditioner::calcReciprocalD(rD_, matrix_);
00063 }
00064
00065
00066
00067
00068 void Foam::DICSmoother::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 const scalar* const __restrict__ upperPtr = matrix_.upper().begin();
00078 const label* const __restrict__ uPtr = matrix_.lduAddr().upperAddr().begin();
00079 const label* const __restrict__ lPtr = matrix_.lduAddr().lowerAddr().begin();
00080
00081
00082 scalarField rA(rD_.size());
00083 scalar* __restrict__ rAPtr = rA.begin();
00084
00085 for (label sweep=0; sweep<nSweeps; sweep++)
00086 {
00087 matrix_.residual
00088 (
00089 rA,
00090 psi,
00091 source,
00092 interfaceBouCoeffs_,
00093 interfaces_,
00094 cmpt
00095 );
00096
00097 rA *= rD_;
00098
00099 register label nFaces = matrix_.upper().size();
00100 for (register label face=0; face<nFaces; face++)
00101 {
00102 register label u = uPtr[face];
00103 rAPtr[u] -= rDPtr[u]*upperPtr[face]*rAPtr[lPtr[face]];
00104 }
00105
00106 register label nFacesM1 = nFaces - 1;
00107 for (register label face=nFacesM1; face>=0; face--)
00108 {
00109 register label l = lPtr[face];
00110 rAPtr[l] -= rDPtr[l]*upperPtr[face]*rAPtr[uPtr[face]];
00111 }
00112
00113 psi += rA;
00114 }
00115 }
00116
00117
00118
Copyright © 2000-2009 OpenCFD Ltd