Merge remote-tracking branch 'origin/BUGFIX/signInHerschelBuckley'
[foam-extend-3.0.git] / src / foam / matrices / blockLduMatrix / BlockLduMatrix / BlockLduMatrixUpdateInterfaces.C
blob3e48bd62966b82c796cd596431406845c39533fe
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     |
5     \\  /    A nd           | For copyright notice see file Copyright
6      \\/     M anipulation  |
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 template<class Type>
34 void Foam::BlockLduMatrix<Type>::initInterfaces
36     const FieldField<CoeffField, Type>& interfaceCoeffs,
37     TypeField& result,
38     const TypeField& psi,
39     const bool switchToLhs
40 ) const
42     if
43     (
44         Pstream::defaultCommsType == Pstream::blocking
45      || Pstream::defaultCommsType == Pstream::nonBlocking
46     )
47     {
48         forAll (interfaces_, interfaceI)
49         {
50             if (interfaces_.set(interfaceI))
51             {
52                 interfaces_[interfaceI].initInterfaceMatrixUpdate
53                 (
54                     psi,
55                     result,
56                     *this,
57                     interfaceCoeffs[interfaceI],
58                     Pstream::defaultCommsType,
59                     switchToLhs
60                 );
61             }
62         }
63     }
64     else if (Pstream::defaultCommsType == Pstream::scheduled)
65     {
66         const lduSchedule& patchSchedule = this->patchSchedule();
68         // Loop over the "global" patches are on the list of interfaces but
69         // beyond the end of the schedule which only handles "normal" patches
70         for
71         (
72             label interfaceI = patchSchedule.size()/2;
73             interfaceI < interfaces_.size();
74             interfaceI++
75         )
76         {
77             if (interfaces_.set(interfaceI))
78             {
79                 interfaces_[interfaceI].initInterfaceMatrixUpdate
80                 (
81                     psi,
82                     result,
83                     *this,
84                     interfaceCoeffs[interfaceI],
85                     Pstream::blocking,
86                     switchToLhs
87                 );
88             }
89         }
90     }
91     else
92     {
93         FatalErrorIn("BlockLduMatrix<Type>::initMatrixInterfaces")
94             << "Unsuported communications type "
95             << Pstream::commsTypeNames[Pstream::defaultCommsType]
96             << exit(FatalError);
97     }
101 template<class Type>
102 void Foam::BlockLduMatrix<Type>::updateInterfaces
104     const FieldField<CoeffField, Type>& interfaceCoeffs,
105     TypeField& result,
106     const TypeField& psi,
107     const bool switchToLhs
108 ) const
110     if
111     (
112         Pstream::defaultCommsType == Pstream::blocking
113      || Pstream::defaultCommsType == Pstream::nonBlocking
114     )
115     {
116         // Block until all sends/receives have been finished
117         if (Pstream::defaultCommsType == Pstream::nonBlocking)
118         {
119             IPstream::waitRequests();
120             OPstream::waitRequests();
121         }
123         forAll (interfaces_, interfaceI)
124         {
125             if (interfaces_.set(interfaceI))
126             {
127                 interfaces_[interfaceI].updateInterfaceMatrix
128                 (
129                     psi,
130                     result,
131                     *this,
132                     interfaceCoeffs[interfaceI],
133                     Pstream::defaultCommsType,
134                     switchToLhs
135                 );
136             }
137         }
138     }
139     else if (Pstream::defaultCommsType == Pstream::scheduled)
140     {
141         const lduSchedule& patchSchedule = this->patchSchedule();
143         // Loop over all the "normal" interfaces relating to standard patches
144         forAll (patchSchedule, i)
145         {
146             label interfaceI = patchSchedule[i].patch;
148             if (interfaces_.set(interfaceI))
149             {
150                 if (patchSchedule[i].init)
151                 {
152                     interfaces_[interfaceI].initInterfaceMatrixUpdate
153                     (
154                         psi,
155                         result,
156                         *this,
157                         interfaceCoeffs[interfaceI],
158                         Pstream::scheduled,
159                         switchToLhs
160                     );
161                 }
162                 else
163                 {
164                     interfaces_[interfaceI].updateInterfaceMatrix
165                     (
166                         psi,
167                         result,
168                         *this,
169                         interfaceCoeffs[interfaceI],
170                         Pstream::scheduled,
171                         switchToLhs
172                     );
173                 }
174             }
175         }
177         // Loop over the "global" patches are on the list of interfaces but
178         // beyond the end of the schedule which only handles "normal" patches
179         for
180         (
181             label interfaceI = patchSchedule.size()/2;
182             interfaceI < interfaces_.size();
183             interfaceI++
184         )
185         {
186             if (interfaces_.set(interfaceI))
187             {
188                 interfaces_[interfaceI].updateInterfaceMatrix
189                 (
190                     psi,
191                     result,
192                     *this,
193                     interfaceCoeffs[interfaceI],
194                     Pstream::blocking,
195                     switchToLhs
196                 );
197             }
198         }
199     }
200     else
201     {
202         FatalErrorIn("BlockLduMatrix<Type>::updateInterfaces")
203             << "Unsuported communications type "
204             << Pstream::commsTypeNames[Pstream::defaultCommsType]
205             << exit(FatalError);
206     }
209 // ************************************************************************* //