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

lduMatrixUpdateMatrixInterfaces.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 "lduMatrix.H"
00028 
00029 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00030 
00031 void Foam::lduMatrix::initMatrixInterfaces
00032 (
00033     const FieldField<Field, scalar>& coupleCoeffs,
00034     const lduInterfaceFieldPtrsList& interfaces,
00035     const scalarField& psiif,
00036     scalarField& result,
00037     const direction cmpt
00038 ) const
00039 {
00040     if
00041     (
00042         Pstream::defaultCommsType == Pstream::blocking
00043      || Pstream::defaultCommsType == Pstream::nonBlocking
00044     )
00045     {
00046         forAll (interfaces, interfaceI)
00047         {
00048             if (interfaces.set(interfaceI))
00049             {
00050                 interfaces[interfaceI].initInterfaceMatrixUpdate
00051                 (
00052                     psiif,
00053                     result,
00054                     *this,
00055                     coupleCoeffs[interfaceI],
00056                     cmpt,
00057                     Pstream::defaultCommsType
00058                 );
00059             }
00060         }
00061     }
00062     else if (Pstream::defaultCommsType == Pstream::scheduled)
00063     {
00064         const lduSchedule& patchSchedule = this->patchSchedule();
00065 
00066         // Loop over the "global" patches are on the list of interfaces but
00067         // beyond the end of the schedule which only handles "normal" patches
00068         for
00069         (
00070             label interfaceI=patchSchedule.size()/2;
00071             interfaceI<interfaces.size();
00072             interfaceI++
00073         )
00074         {
00075             if (interfaces.set(interfaceI))
00076             {
00077                 interfaces[interfaceI].initInterfaceMatrixUpdate
00078                 (
00079                     psiif,
00080                     result,
00081                     *this,
00082                     coupleCoeffs[interfaceI],
00083                     cmpt,
00084                     Pstream::blocking
00085                 );
00086             }
00087         }
00088     }
00089     else
00090     {
00091         FatalErrorIn("lduMatrix::initMatrixInterfaces")
00092             << "Unsuported communications type "
00093             << Pstream::commsTypeNames[Pstream::defaultCommsType]
00094             << exit(FatalError);
00095     }
00096 }
00097 
00098 
00099 void Foam::lduMatrix::updateMatrixInterfaces
00100 (
00101     const FieldField<Field, scalar>& coupleCoeffs,
00102     const lduInterfaceFieldPtrsList& interfaces,
00103     const scalarField& psiif,
00104     scalarField& result,
00105     const direction cmpt
00106 ) const
00107 {
00108     if
00109     (
00110         Pstream::defaultCommsType == Pstream::blocking
00111      || Pstream::defaultCommsType == Pstream::nonBlocking
00112     )
00113     {
00114         // Block until all sends/receives have been finished
00115         if (Pstream::defaultCommsType == Pstream::nonBlocking)
00116         {
00117             IPstream::waitRequests();
00118             OPstream::waitRequests();
00119         }
00120 
00121         forAll (interfaces, interfaceI)
00122         {
00123             if (interfaces.set(interfaceI))
00124             {
00125                 interfaces[interfaceI].updateInterfaceMatrix
00126                 (
00127                     psiif,
00128                     result,
00129                     *this,
00130                     coupleCoeffs[interfaceI],
00131                     cmpt,
00132                     Pstream::defaultCommsType
00133                 );
00134             }
00135         }
00136     }
00137     else if (Pstream::defaultCommsType == Pstream::scheduled)
00138     {
00139         const lduSchedule& patchSchedule = this->patchSchedule();
00140 
00141         // Loop over all the "normal" interfaces relating to standard patches
00142         forAll (patchSchedule, i)
00143         {
00144             label interfaceI = patchSchedule[i].patch;
00145 
00146             if (interfaces.set(interfaceI))
00147             {
00148                 if (patchSchedule[i].init)
00149                 {
00150                     interfaces[interfaceI].initInterfaceMatrixUpdate
00151                     (
00152                         psiif,
00153                         result,
00154                         *this,
00155                         coupleCoeffs[interfaceI],
00156                         cmpt,
00157                         Pstream::scheduled
00158                     );
00159                 }
00160                 else
00161                 {
00162                     interfaces[interfaceI].updateInterfaceMatrix
00163                     (
00164                         psiif,
00165                         result,
00166                         *this,
00167                         coupleCoeffs[interfaceI],
00168                         cmpt,
00169                         Pstream::scheduled
00170                     );
00171                 }
00172             }
00173         }
00174 
00175         // Loop over the "global" patches are on the list of interfaces but
00176         // beyond the end of the schedule which only handles "normal" patches
00177         for
00178         (
00179             label interfaceI=patchSchedule.size()/2;
00180             interfaceI<interfaces.size();
00181             interfaceI++
00182         )
00183         {
00184             if (interfaces.set(interfaceI))
00185             {
00186                 interfaces[interfaceI].updateInterfaceMatrix
00187                 (
00188                     psiif,
00189                     result,
00190                     *this,
00191                     coupleCoeffs[interfaceI],
00192                     cmpt,
00193                     Pstream::blocking
00194                 );
00195             }
00196         }
00197     }
00198     else
00199     {
00200         FatalErrorIn("lduMatrix::updateMatrixInterfaces")
00201             << "Unsuported communications type "
00202             << Pstream::commsTypeNames[Pstream::defaultCommsType]
00203             << exit(FatalError);
00204     }
00205 }
00206 
00207 
00208 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd