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

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