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

DICSmoother.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 "DICSmoother.H"
00028 #include "DICPreconditioner.H"
00029 
00030 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034     defineTypeNameAndDebug(DICSmoother, 0);
00035 
00036     lduMatrix::smoother::addsymMatrixConstructorToTable<DICSmoother>
00037         addDICSmootherSymMatrixConstructorToTable_;
00038 }
00039 
00040 
00041 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
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 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
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     // Temporary storage for the residual
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