Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / foam / matrices / blockLduMatrix / BlockLduMatrix / scalarBlockLduMatrixUpdateInterfaces.C
blobce1e80e47ce93d1c730fd6c5002b6f3e25e5818a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Description
25     Update of block interfaces
27 \*---------------------------------------------------------------------------*/
29 #include "BlockLduMatrix.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 // TODO - This code is currently not called so we have specialized
34 // initInterfaceMatrixUpdate in processorFvPatchScalarfield
35 // This needs to be fixed
37 template<>
38 void Foam::BlockLduMatrix<scalar>::initInterfaces
40     const FieldField<CoeffField, scalar>& coupleCoeffs,
41     scalarField& result,
42     const scalarField& psi,
43     const bool switchToLhs
44 ) const
46     if
47     (
48         Pstream::defaultCommsType() == Pstream::blocking
49      || Pstream::defaultCommsType() == Pstream::nonBlocking
50     )
51     {
52         forAll (interfaces, interfaceI)
53         {
54             if (interfaces.set(interfaceI))
55             {
56                 interfaces[interfaceI].initInterfaceMatrixUpdate
57                 (
58                     psi,
59                     result,
60                     *this,
61                     coupleCoeffs[interfaceI].asScalar(),
62                     Pstream::defaultCommsType,
63                     switchToLhs
64                 );
65             }
66         }
67     }
68     else if (Pstream::defaultCommsType() == Pstream::scheduled)
69     {
70         const lduSchedule& patchSchedule = this->patchSchedule();
72         // Loop over the "global" patches are on the list of interfaces but
73         // beyond the end of the schedule which only handles "normal" patches
74         for
75         (
76             label interfaceI=patchSchedule.size()/2;
77             interfaceI<interfaces.size();
78             interfaceI++
79         )
80         {
81             if (interfaces.set(interfaceI))
82             {
83                 interfaces[interfaceI].initInterfaceMatrixUpdate
84                 (
85                     psi,
86                     result,
87                     *this,
88                     coupleCoeffs[interfaceI].asScalar(),
89                     Pstream::blocking,
90                     switchToLhs
91                 );
92             }
93         }
94     }
95     else
96     {
97         FatalErrorIn("BlockLduMatrix<scalar>::initMatrixInterfaces")
98             << "Unsuported communications type "
99             << Pstream::commsTypeNames[Pstream::defaultCommsType]
100             << exit(FatalError);
101     }
105 template<>
106 void Foam::BlockLduMatrix<scalar>::updateInterfaces
108     const FieldField<CoeffField, scalar>& coupleCoeffs,
109     scalarField& result,
110     const scalarField& psi,
111     const bool switchToLhs
112 ) const
114     if
115     (
116         Pstream::defaultCommsType() == Pstream::blocking
117      || Pstream::defaultCommsType() == Pstream::nonBlocking
118     )
119     {
120         // Block until all sends/receives have been finished
121         if (Pstream::defaultCommsType() == Pstream::nonBlocking)
122         {
123             IPstream::waitRequests();
124             OPstream::waitRequests();
125         }
127         forAll (interfaces, interfaceI)
128         {
129             if (interfaces.set(interfaceI))
130             {
131                 interfaces[interfaceI].updateInterfaceMatrix
132                 (
133                     psi,
134                     result,
135                     *this,
136                     coupleCoeffs[interfaceI].asScalar(),
137                     Pstream::defaultCommsType,
138                     switchToLhs
139                 );
140             }
141         }
142     }
143     else if (Pstream::defaultCommsType() == Pstream::scheduled)
144     {
145         const lduSchedule& patchSchedule = this->patchSchedule();
147         // Loop over all the "normal" interfaces relating to standard patches
148         forAll (patchSchedule, i)
149         {
150             label interfaceI = patchSchedule[i].patch;
152             if (interfaces.set(interfaceI))
153             {
154                 if (patchSchedule[i].init)
155                 {
156                     interfaces[interfaceI].initInterfaceMatrixUpdate
157                     (
158                         psi,
159                         result,
160                         *this,
161                         coupleCoeffs[interfaceI].asScalar(),
162                         Pstream::scheduled,
163                         switchToLhs
164                     );
165                 }
166                 else
167                 {
168                     interfaces[interfaceI].updateInterfaceMatrix
169                     (
170                         psi,
171                         result,
172                         *this,
173                         coupleCoeffs[interfaceI].asScalar(),
174                         Pstream::scheduled,
175                         switchToLhs
176                     );
177                 }
178             }
179         }
181         // Loop over the "global" patches are on the list of interfaces but
182         // beyond the end of the schedule which only handles "normal" patches
183         for
184         (
185             label interfaceI=patchSchedule.size()/2;
186             interfaceI<interfaces.size();
187             interfaceI++
188         )
189         {
190             if (interfaces.set(interfaceI))
191             {
192                 interfaces[interfaceI].updateInterfaceMatrix
193                 (
194                     psi,
195                     result,
196                     *this,
197                     coupleCoeffs[interfaceI].asScalar(),
198                     Pstream::blocking,
199                     switchToLhs
200                 );
201             }
202         }
203     }
204     else
205     {
206         FatalErrorIn("BlockLduMatrix<scalar>::updateMatrixInterfaces")
207             << "Unsuported communications type "
208             << Pstream::commsTypeNames[Pstream::defaultCommsType]
209             << exit(FatalError);
210     }
214 // ************************************************************************* //