OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

DILUSmoother.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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "DILUSmoother.H"
00028 #include "DILUPreconditioner.H"
00029 
00030 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034     defineTypeNameAndDebug(DILUSmoother, 0);
00035 
00036     lduMatrix::smoother::addasymMatrixConstructorToTable<DILUSmoother>
00037         addDILUSmootherAsymMatrixConstructorToTable_;
00038 }
00039 
00040 
00041 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00042 
00043 Foam::DILUSmoother::DILUSmoother
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     DILUPreconditioner::calcReciprocalD(rD_, matrix_);
00063 }
00064 
00065 
00066 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00067 
00068 void Foam::DILUSmoother::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 
00078     const label* const __restrict__ uPtr =
00079         matrix_.lduAddr().upperAddr().begin();
00080     const label* const __restrict__ lPtr =
00081         matrix_.lduAddr().lowerAddr().begin();
00082 
00083     const scalar* const __restrict__ upperPtr = matrix_.upper().begin();
00084     const scalar* const __restrict__ lowerPtr = matrix_.lower().begin();
00085 
00086     // Temporary storage for the residual
00087     scalarField rA(rD_.size());
00088     scalar* __restrict__ rAPtr = rA.begin();
00089 
00090     for (label sweep=0; sweep<nSweeps; sweep++)
00091     {
00092         matrix_.residual
00093         (
00094             rA,
00095             psi,
00096             source,
00097             interfaceBouCoeffs_,
00098             interfaces_,
00099             cmpt
00100         );
00101 
00102         rA *= rD_;
00103 
00104         register label nFaces = matrix_.upper().size();
00105         for (register label face=0; face<nFaces; face++)
00106         {
00107             register label u = uPtr[face];
00108             rAPtr[u] -= rDPtr[u]*lowerPtr[face]*rAPtr[lPtr[face]];
00109         }
00110 
00111         register label nFacesM1 = nFaces - 1;
00112         for (register label face=nFacesM1; face>=0; face--)
00113         {
00114             register label l = lPtr[face];
00115             rAPtr[l] -= rDPtr[l]*upperPtr[face]*rAPtr[uPtr[face]];
00116         }
00117 
00118         psi += rA;
00119     }
00120 }
00121 
00122 
00123 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd