LduMatrixUpdateMatrixInterfaces.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
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 "LduMatrix.H"
27 #include "lduInterfaceField.H"
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
31 template<class Type, class DType, class LUType>
33 (
34  const FieldField<Field, LUType>& interfaceCoeffs,
35  const Field<Type>& psiif,
36  Field<Type>& result
37 ) const
38 {
39  if
40  (
41  Pstream::defaultCommsType == Pstream::commsTypes::blocking
42  || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
43  )
44  {
45  forAll(interfaces_, interfacei)
46  {
47  if (interfaces_.set(interfacei))
48  {
49  interfaces_[interfacei].initInterfaceMatrixUpdate
50  (
51  result,
52  psiif,
53  interfaceCoeffs[interfacei],
54  // Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
55  Pstream::defaultCommsType
56  );
57  }
58  }
59  }
60  else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
61  {
62  const lduSchedule& patchSchedule = this->patchSchedule();
63 
64  // Loop over the "global" patches are on the list of interfaces but
65  // beyond the end of the schedule which only handles "normal" patches
66  for
67  (
68  label interfacei=patchSchedule.size()/2;
69  interfacei<interfaces_.size();
70  interfacei++
71  )
72  {
73  if (interfaces_.set(interfacei))
74  {
75  interfaces_[interfacei].initInterfaceMatrixUpdate
76  (
77  result,
78  psiif,
79  interfaceCoeffs[interfacei],
80  // Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
81  Pstream::commsTypes::blocking
82  );
83  }
84  }
85  }
86  else
87  {
89  << "Unsupported communications type "
90  << Pstream::commsTypeNames[Pstream::defaultCommsType]
91  << exit(FatalError);
92  }
93 }
94 
95 
96 template<class Type, class DType, class LUType>
98 (
99  const FieldField<Field, LUType>& interfaceCoeffs,
100  const Field<Type>& psiif,
101  Field<Type>& result
102 ) const
103 {
104  if
105  (
106  Pstream::defaultCommsType == Pstream::commsTypes::blocking
107  || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
108  )
109  {
110  // Block until all sends/receives have been finished
111  if (Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking)
112  {
113  IPstream::waitRequests();
114  OPstream::waitRequests();
115  }
116 
117  forAll(interfaces_, interfacei)
118  {
119  if (interfaces_.set(interfacei))
120  {
121  interfaces_[interfacei].updateInterfaceMatrix
122  (
123  result,
124  psiif,
125  interfaceCoeffs[interfacei],
126  // Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
127  Pstream::defaultCommsType
128  );
129  }
130  }
131  }
132  else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
133  {
134  const lduSchedule& patchSchedule = this->patchSchedule();
135 
136  // Loop over all the "normal" interfaces relating to standard patches
137  forAll(patchSchedule, i)
138  {
139  label interfacei = patchSchedule[i].patch;
140 
141  if (interfaces_.set(interfacei))
142  {
143  if (patchSchedule[i].init)
144  {
145  interfaces_[interfacei].initInterfaceMatrixUpdate
146  (
147  result,
148  psiif,
149  interfaceCoeffs[interfacei],
150  // Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
151  Pstream::commsTypes::scheduled
152  );
153  }
154  else
155  {
156  interfaces_[interfacei].updateInterfaceMatrix
157  (
158  result,
159  psiif,
160  interfaceCoeffs[interfacei],
161  // Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
162  Pstream::commsTypes::scheduled
163  );
164  }
165  }
166  }
167 
168  // Loop over the "global" patches are on the list of interfaces but
169  // beyond the end of the schedule which only handles "normal" patches
170  for
171  (
172  label interfacei=patchSchedule.size()/2;
173  interfacei<interfaces_.size();
174  interfacei++
175  )
176  {
177  if (interfaces_.set(interfacei))
178  {
179  interfaces_[interfacei].updateInterfaceMatrix
180  (
181  result,
182  psiif,
183  interfaceCoeffs[interfacei],
184  // Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
185  Pstream::commsTypes::blocking
186  );
187  }
188  }
189  }
190  else
191  {
193  << "Unsupported communications type "
194  << Pstream::commsTypeNames[Pstream::defaultCommsType]
195  << exit(FatalError);
196  }
197 }
198 
199 
200 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
Generic field type.
Definition: FieldField.H:51
void initMatrixInterfaces(const FieldField< Field, LUType > &interfaceCoeffs, const Field< Type > &psiif, Field< Type > &result) const
Initialise the update of interfaced interfaces.
Pre-declare SubField and related Field type.
Definition: Field.H:56
void updateMatrixInterfaces(const FieldField< Field, LUType > &interfaceCoeffs, const Field< Type > &psiif, Field< Type > &result) const
Update interfaced interfaces for matrix operations.