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

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-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 "DICSmoother.H"
00027 #include <OpenFOAM/DICPreconditioner.H>
00028 
00029 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033     defineTypeNameAndDebug(DICSmoother, 0);
00034 
00035     lduMatrix::smoother::addsymMatrixConstructorToTable<DICSmoother>
00036         addDICSmootherSymMatrixConstructorToTable_;
00037 }
00038 
00039 
00040 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00041 
00042 Foam::DICSmoother::DICSmoother
00043 (
00044     const word& fieldName,
00045     const lduMatrix& matrix,
00046     const FieldField<Field, scalar>& interfaceBouCoeffs,
00047     const FieldField<Field, scalar>& interfaceIntCoeffs,
00048     const lduInterfaceFieldPtrsList& interfaces
00049 )
00050 :
00051     lduMatrix::smoother
00052     (
00053         fieldName,
00054         matrix,
00055         interfaceBouCoeffs,
00056         interfaceIntCoeffs,
00057         interfaces
00058     ),
00059     rD_(matrix_.diag())
00060 {
00061     DICPreconditioner::calcReciprocalD(rD_, matrix_);
00062 }
00063 
00064 
00065 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00066 
00067 void Foam::DICSmoother::smooth
00068 (
00069     scalarField& psi,
00070     const scalarField& source,
00071     const direction cmpt,
00072     const label nSweeps
00073 ) const
00074 {
00075     const scalar* const __restrict__ rDPtr = rD_.begin();
00076     const scalar* const __restrict__ upperPtr = matrix_.upper().begin();
00077     const label* const __restrict__ uPtr = matrix_.lduAddr().upperAddr().begin();
00078     const label* const __restrict__ lPtr = matrix_.lduAddr().lowerAddr().begin();
00079 
00080     // Temporary storage for the residual
00081     scalarField rA(rD_.size());
00082     scalar* __restrict__ rAPtr = rA.begin();
00083 
00084     for (label sweep=0; sweep<nSweeps; sweep++)
00085     {
00086         matrix_.residual
00087         (
00088             rA,
00089             psi,
00090             source,
00091             interfaceBouCoeffs_,
00092             interfaces_,
00093             cmpt
00094         );
00095 
00096         rA *= rD_;
00097 
00098         register label nFaces = matrix_.upper().size();
00099         for (register label face=0; face<nFaces; face++)
00100         {
00101             register label u = uPtr[face];
00102             rAPtr[u] -= rDPtr[u]*upperPtr[face]*rAPtr[lPtr[face]];
00103         }
00104 
00105         register label nFacesM1 = nFaces - 1;
00106         for (register label face=nFacesM1; face>=0; face--)
00107         {
00108             register label l = lPtr[face];
00109             rAPtr[l] -= rDPtr[l]*upperPtr[face]*rAPtr[uPtr[face]];
00110         }
00111 
00112         psi += rA;
00113     }
00114 }
00115 
00116 
00117 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines