FreeFOAM The Cross-Platform CFD Toolkit
lduMatrixUpdateMatrixInterfaces.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include <OpenFOAM/lduMatrix.H>
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
31 (
32  const FieldField<Field, scalar>& coupleCoeffs,
33  const lduInterfaceFieldPtrsList& interfaces,
34  const scalarField& psiif,
35  scalarField& result,
36  const direction cmpt
37 ) const
38 {
39  if
40  (
41  Pstream::defaultCommsType == Pstream::blocking
42  || Pstream::defaultCommsType == Pstream::nonBlocking
43  )
44  {
45  forAll (interfaces, interfaceI)
46  {
47  if (interfaces.set(interfaceI))
48  {
49  interfaces[interfaceI].initInterfaceMatrixUpdate
50  (
51  psiif,
52  result,
53  *this,
54  coupleCoeffs[interfaceI],
55  cmpt,
56  Pstream::defaultCommsType
57  );
58  }
59  }
60  }
61  else if (Pstream::defaultCommsType == Pstream::scheduled)
62  {
63  const lduSchedule& patchSchedule = this->patchSchedule();
64 
65  // Loop over the "global" patches are on the list of interfaces but
66  // beyond the end of the schedule which only handles "normal" patches
67  for
68  (
69  label interfaceI=patchSchedule.size()/2;
70  interfaceI<interfaces.size();
71  interfaceI++
72  )
73  {
74  if (interfaces.set(interfaceI))
75  {
76  interfaces[interfaceI].initInterfaceMatrixUpdate
77  (
78  psiif,
79  result,
80  *this,
81  coupleCoeffs[interfaceI],
82  cmpt,
83  Pstream::blocking
84  );
85  }
86  }
87  }
88  else
89  {
90  FatalErrorIn("lduMatrix::initMatrixInterfaces")
91  << "Unsuported communications type "
92  << Pstream::commsTypeNames[Pstream::defaultCommsType]
93  << exit(FatalError);
94  }
95 }
96 
97 
99 (
100  const FieldField<Field, scalar>& coupleCoeffs,
101  const lduInterfaceFieldPtrsList& interfaces,
102  const scalarField& psiif,
103  scalarField& result,
104  const direction cmpt
105 ) const
106 {
107  if
108  (
109  Pstream::defaultCommsType == Pstream::blocking
110  || Pstream::defaultCommsType == Pstream::nonBlocking
111  )
112  {
113  // Block until all sends/receives have been finished
114  if (Pstream::defaultCommsType == Pstream::nonBlocking)
115  {
116  IPstream::waitRequests();
117  OPstream::waitRequests();
118  }
119 
120  forAll (interfaces, interfaceI)
121  {
122  if (interfaces.set(interfaceI))
123  {
124  interfaces[interfaceI].updateInterfaceMatrix
125  (
126  psiif,
127  result,
128  *this,
129  coupleCoeffs[interfaceI],
130  cmpt,
131  Pstream::defaultCommsType
132  );
133  }
134  }
135  }
136  else if (Pstream::defaultCommsType == Pstream::scheduled)
137  {
138  const lduSchedule& patchSchedule = this->patchSchedule();
139 
140  // Loop over all the "normal" interfaces relating to standard patches
141  forAll (patchSchedule, i)
142  {
143  label interfaceI = patchSchedule[i].patch;
144 
145  if (interfaces.set(interfaceI))
146  {
147  if (patchSchedule[i].init)
148  {
149  interfaces[interfaceI].initInterfaceMatrixUpdate
150  (
151  psiif,
152  result,
153  *this,
154  coupleCoeffs[interfaceI],
155  cmpt,
156  Pstream::scheduled
157  );
158  }
159  else
160  {
161  interfaces[interfaceI].updateInterfaceMatrix
162  (
163  psiif,
164  result,
165  *this,
166  coupleCoeffs[interfaceI],
167  cmpt,
168  Pstream::scheduled
169  );
170  }
171  }
172  }
173 
174  // Loop over the "global" patches are on the list of interfaces but
175  // beyond the end of the schedule which only handles "normal" patches
176  for
177  (
178  label interfaceI=patchSchedule.size()/2;
179  interfaceI<interfaces.size();
180  interfaceI++
181  )
182  {
183  if (interfaces.set(interfaceI))
184  {
185  interfaces[interfaceI].updateInterfaceMatrix
186  (
187  psiif,
188  result,
189  *this,
190  coupleCoeffs[interfaceI],
191  cmpt,
192  Pstream::blocking
193  );
194  }
195  }
196  }
197  else
198  {
199  FatalErrorIn("lduMatrix::updateMatrixInterfaces")
200  << "Unsuported communications type "
201  << Pstream::commsTypeNames[Pstream::defaultCommsType]
202  << exit(FatalError);
203  }
204 }
205 
206 
207 // ************************ vim: set sw=4 sts=4 et: ************************ //