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