FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

FDICPreconditioner.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include <OpenFOAM/FDICPreconditioner.H>
00027 
00028 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00029 
00030 namespace Foam
00031 {
00032     defineTypeNameAndDebug(FDICPreconditioner, 0);
00033 
00034     lduMatrix::preconditioner::
00035         addsymMatrixConstructorToTable<FDICPreconditioner>
00036         addFDICPreconditionerSymMatrixConstructorToTable_;
00037 }
00038 
00039 
00040 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00041 
00042 Foam::FDICPreconditioner::FDICPreconditioner
00043 (
00044     const lduMatrix::solver& sol,
00045     const dictionary&
00046 )
00047 :
00048     lduMatrix::preconditioner(sol),
00049     rD_(sol.matrix().diag()),
00050     rDuUpper_(sol.matrix().upper().size()),
00051     rDlUpper_(sol.matrix().upper().size())
00052 {
00053     scalar* __restrict__ rDPtr = rD_.begin();
00054     scalar* __restrict__ rDuUpperPtr = rDuUpper_.begin();
00055     scalar* __restrict__ rDlUpperPtr = rDlUpper_.begin();
00056 
00057     const label* const __restrict__ uPtr =
00058         solver_.matrix().lduAddr().upperAddr().begin();
00059     const label* const __restrict__ lPtr =
00060         solver_.matrix().lduAddr().lowerAddr().begin();
00061     const scalar* const __restrict__ upperPtr = solver_.matrix().upper().begin();
00062 
00063     register label nCells = rD_.size();
00064     register label nFaces = solver_.matrix().upper().size();
00065 
00066     for (register label face=0; face<nFaces; face++)
00067     {
00068         rDPtr[uPtr[face]] -= sqr(upperPtr[face])/rDPtr[lPtr[face]];
00069     }
00070 
00071     // Generate reciprocal FDIC
00072     for (register label cell=0; cell<nCells; cell++)
00073     {
00074         rDPtr[cell] = 1.0/rDPtr[cell];
00075     }
00076 
00077     for (register label face=0; face<nFaces; face++)
00078     {
00079         rDuUpperPtr[face] = rDPtr[uPtr[face]]*upperPtr[face];
00080         rDlUpperPtr[face] = rDPtr[lPtr[face]]*upperPtr[face];
00081     }
00082 }
00083 
00084 
00085 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00086 
00087 void Foam::FDICPreconditioner::precondition
00088 (
00089     scalarField& wA,
00090     const scalarField& rA,
00091     const direction
00092 ) const
00093 {
00094     scalar* __restrict__ wAPtr = wA.begin();
00095     const scalar* __restrict__ rAPtr = rA.begin();
00096     const scalar* __restrict__ rDPtr = rD_.begin();
00097 
00098     const label* const __restrict__ uPtr =
00099         solver_.matrix().lduAddr().upperAddr().begin();
00100     const label* const __restrict__ lPtr =
00101         solver_.matrix().lduAddr().lowerAddr().begin();
00102 
00103     const scalar* const __restrict__ rDuUpperPtr = rDuUpper_.begin();
00104     const scalar* const __restrict__ rDlUpperPtr = rDlUpper_.begin();
00105 
00106     register label nCells = wA.size();
00107     register label nFaces = solver_.matrix().upper().size();
00108     register label nFacesM1 = nFaces - 1;
00109 
00110     for (register label cell=0; cell<nCells; cell++)
00111     {
00112         wAPtr[cell] = rDPtr[cell]*rAPtr[cell];
00113     }
00114 
00115     for (register label face=0; face<nFaces; face++)
00116     {
00117         wAPtr[uPtr[face]] -= rDuUpperPtr[face]*wAPtr[lPtr[face]];
00118     }
00119 
00120     for (register label face=nFacesM1; face>=0; face--)
00121     {
00122         wAPtr[lPtr[face]] -= rDlUpperPtr[face]*wAPtr[uPtr[face]];
00123     }
00124 }
00125 
00126 
00127 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines