DICPreconditioner.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 "DICPreconditioner.H"
00028
00029
00030
00031 namespace Foam
00032 {
00033 defineTypeNameAndDebug(DICPreconditioner, 0);
00034
00035 lduMatrix::preconditioner::
00036 addsymMatrixConstructorToTable<DICPreconditioner>
00037 addDICPreconditionerSymMatrixConstructorToTable_;
00038 }
00039
00040
00041
00042
00043 Foam::DICPreconditioner::DICPreconditioner
00044 (
00045 const lduMatrix::solver& sol,
00046 const dictionary&
00047 )
00048 :
00049 lduMatrix::preconditioner(sol),
00050 rD_(sol.matrix().diag())
00051 {
00052 calcReciprocalD(rD_, sol.matrix());
00053 }
00054
00055
00056
00057
00058 void Foam::DICPreconditioner::calcReciprocalD
00059 (
00060 scalarField& rD,
00061 const lduMatrix& matrix
00062 )
00063 {
00064 scalar* __restrict__ rDPtr = rD.begin();
00065
00066 const label* const __restrict__ uPtr = matrix.lduAddr().upperAddr().begin();
00067 const label* const __restrict__ lPtr = matrix.lduAddr().lowerAddr().begin();
00068 const scalar* const __restrict__ upperPtr = matrix.upper().begin();
00069
00070
00071 register const label nFaces = matrix.upper().size();
00072 for (register label face=0; face<nFaces; face++)
00073 {
00074 rDPtr[uPtr[face]] -= upperPtr[face]*upperPtr[face]/rDPtr[lPtr[face]];
00075 }
00076
00077
00078
00079 register const label nCells = rD.size();
00080
00081 for (register label cell=0; cell<nCells; cell++)
00082 {
00083 rDPtr[cell] = 1.0/rDPtr[cell];
00084 }
00085 }
00086
00087
00088 void Foam::DICPreconditioner::precondition
00089 (
00090 scalarField& wA,
00091 const scalarField& rA,
00092 const direction
00093 ) const
00094 {
00095 scalar* __restrict__ wAPtr = wA.begin();
00096 const scalar* __restrict__ rAPtr = rA.begin();
00097 const scalar* __restrict__ rDPtr = rD_.begin();
00098
00099 const label* const __restrict__ uPtr =
00100 solver_.matrix().lduAddr().upperAddr().begin();
00101 const label* const __restrict__ lPtr =
00102 solver_.matrix().lduAddr().lowerAddr().begin();
00103 const scalar* const __restrict__ upperPtr = solver_.matrix().upper().begin();
00104
00105 register label nCells = wA.size();
00106 register label nFaces = solver_.matrix().upper().size();
00107 register label nFacesM1 = nFaces - 1;
00108
00109 for (register label cell=0; cell<nCells; cell++)
00110 {
00111 wAPtr[cell] = rDPtr[cell]*rAPtr[cell];
00112 }
00113
00114 for (register label face=0; face<nFaces; face++)
00115 {
00116 wAPtr[uPtr[face]] -= rDPtr[uPtr[face]]*upperPtr[face]*wAPtr[lPtr[face]];
00117 }
00118
00119 for (register label face=nFacesM1; face>=0; face--)
00120 {
00121 wAPtr[lPtr[face]] -= rDPtr[lPtr[face]]*upperPtr[face]*wAPtr[uPtr[face]];
00122 }
00123 }
00124
00125
00126
Copyright © 2000-2009 OpenCFD Ltd