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

LUscalarMatrixTemplates.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 "LUscalarMatrix.H"
00028 
00029 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00030 
00031 template<class Type>
00032 void Foam::LUscalarMatrix::solve(Field<Type>& sourceSol) const
00033 {
00034     if (Pstream::parRun())
00035     {
00036         Field<Type> completeSourceSol(n());
00037 
00038         if (Pstream::master())
00039         {
00040             typename Field<Type>::subField
00041             (
00042                 completeSourceSol,
00043                 sourceSol.size()
00044             ).assign(sourceSol);
00045 
00046             for
00047             (
00048                 int slave=Pstream::firstSlave();
00049                 slave<=Pstream::lastSlave();
00050                 slave++
00051             )
00052             {
00053                 IPstream::read
00054                 (
00055                     Pstream::scheduled,
00056                     slave,
00057                     reinterpret_cast<char*>
00058                     (
00059                         &(completeSourceSol[procOffsets_[slave]])
00060                     ),
00061                     (procOffsets_[slave + 1] - procOffsets_[slave])*sizeof(Type)
00062                 );
00063             }
00064         }
00065         else
00066         {
00067             OPstream::write
00068             (
00069                 Pstream::scheduled,
00070                 Pstream::masterNo(),
00071                 reinterpret_cast<const char*>(sourceSol.begin()),
00072                 sourceSol.byteSize()
00073             );
00074         }
00075 
00076         if (Pstream::master())
00077         {
00078             LUBacksubstitute(*this, pivotIndices_, completeSourceSol);
00079 
00080             sourceSol = typename Field<Type>::subField
00081             (
00082                 completeSourceSol,
00083                 sourceSol.size()
00084             );
00085 
00086             for
00087             (
00088                 int slave=Pstream::firstSlave();
00089                 slave<=Pstream::lastSlave();
00090                 slave++
00091             )
00092             {
00093                 OPstream::write
00094                 (
00095                     Pstream::blocking,
00096                     slave,
00097                     reinterpret_cast<const char*>
00098                     (
00099                         &(completeSourceSol[procOffsets_[slave]])
00100                     ),
00101                     (procOffsets_[slave + 1] - procOffsets_[slave])*sizeof(Type)
00102                 );
00103             }
00104         }
00105         else
00106         {
00107             IPstream::read
00108             (
00109                 Pstream::blocking,
00110                 Pstream::masterNo(),
00111                 reinterpret_cast<char*>(sourceSol.begin()),
00112                 sourceSol.byteSize()
00113             );
00114         }
00115     }
00116     else
00117     {
00118         LUBacksubstitute(*this, pivotIndices_, sourceSol);
00119     }
00120 }
00121 
00122 
00123 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd