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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "LduMatrix.H"
30 #include "lduInterfaceField.H"
31 
32 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
33 
34 template<class Type, class DType, class LUType>
36 (
37  const bool add,
38  const FieldField<Field, LUType>& interfaceCoeffs,
39  const Field<Type>& psiif,
40  Field<Type>& result
41 ) const
42 {
43  const UPstream::commsTypes commsType = UPstream::defaultCommsType;
44 
45  if
46  (
47  commsType == UPstream::commsTypes::blocking
48  || commsType == UPstream::commsTypes::nonBlocking
49  )
50  {
51  forAll(interfaces_, interfacei)
52  {
53  if (interfaces_.set(interfacei))
54  {
55  interfaces_[interfacei].initInterfaceMatrixUpdate
56  (
57  result,
58  add,
59  lduMesh_.lduAddr(),
60  interfacei,
61  psiif,
62  interfaceCoeffs[interfacei],
63  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
64  commsType
65  );
66  }
67  }
68  }
69  else if (commsType == UPstream::commsTypes::scheduled)
70  {
71  const lduSchedule& patchSchedule = this->patchSchedule();
72 
73  // Loop over the "global" patches are on the list of interfaces but
74  // beyond the end of the schedule which only handles "normal" patches
75  for
76  (
77  label interfacei=patchSchedule.size()/2;
78  interfacei<interfaces_.size();
79  interfacei++
80  )
81  {
82  if (interfaces_.set(interfacei))
83  {
84  interfaces_[interfacei].initInterfaceMatrixUpdate
85  (
86  result,
87  add,
88  lduMesh_.lduAddr(),
89  interfacei,
90  psiif,
91  interfaceCoeffs[interfacei],
92  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
93  UPstream::commsTypes::blocking
94  );
95  }
96  }
97  }
98  else
99  {
101  << "Unsupported communications type "
102  << UPstream::commsTypeNames[commsType]
104  }
105 }
106 
107 
108 template<class Type, class DType, class LUType>
110 (
111  const bool add,
112  const FieldField<Field, LUType>& interfaceCoeffs,
113  const Field<Type>& psiif,
114  Field<Type>& result
115 ) const
116 {
117  const UPstream::commsTypes commsType = UPstream::defaultCommsType;
118 
119  if
120  (
121  commsType == UPstream::commsTypes::blocking
122  || commsType == UPstream::commsTypes::nonBlocking
123  )
124  {
125  // Block until all sends/receives have been finished
126  if (commsType == UPstream::commsTypes::nonBlocking)
127  {
128  UPstream::waitRequests();
129  }
130 
131  forAll(interfaces_, interfacei)
132  {
133  if (interfaces_.set(interfacei))
134  {
135  interfaces_[interfacei].updateInterfaceMatrix
136  (
137  result,
138  add,
139  lduMesh_.lduAddr(),
140  interfacei,
141  psiif,
142  interfaceCoeffs[interfacei],
143  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
144  commsType
145  );
146  }
147  }
148  }
149  else if (commsType == UPstream::commsTypes::scheduled)
150  {
151  const lduSchedule& patchSchedule = this->patchSchedule();
152 
153  // Loop over all the "normal" interfaces relating to standard patches
154  for (const auto& schedEval : patchSchedule)
155  {
156  const label interfacei = schedEval.patch;
157 
158  if (interfaces_.set(interfacei))
159  {
160  if (schedEval.init)
161  {
162  interfaces_[interfacei].initInterfaceMatrixUpdate
163  (
164  result,
165  add,
166  lduMesh_.lduAddr(),
167  interfacei,
168  psiif,
169  interfaceCoeffs[interfacei],
170  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
171  commsType
172  );
173  }
174  else
175  {
176  interfaces_[interfacei].updateInterfaceMatrix
177  (
178  result,
179  add,
180  lduMesh_.lduAddr(),
181  interfacei,
182  psiif,
183  interfaceCoeffs[interfacei],
184  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
185  commsType
186  );
187  }
188  }
189  }
190 
191  // Loop over the "global" patches are on the list of interfaces but
192  // beyond the end of the schedule which only handles "normal" patches
193  for
194  (
195  label interfacei=patchSchedule.size()/2;
196  interfacei<interfaces_.size();
197  interfacei++
198  )
199  {
200  if (interfaces_.set(interfacei))
201  {
202  interfaces_[interfacei].updateInterfaceMatrix
203  (
204  result,
205  add,
206  lduMesh_.lduAddr(),
207  interfacei,
208  psiif,
209  interfaceCoeffs[interfacei],
210  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
211  Pstream::commsTypes::blocking
212  );
213  }
214  }
215  }
216  else
217  {
219  << "Unsupported communications type "
220  << UPstream::commsTypeNames[commsType]
221  << exit(FatalError);
222  }
223 }
224 
225 
226 // ************************************************************************* //
void initMatrixInterfaces(const bool add, const FieldField< Field, LUType > &interfaceCoeffs, const Field< Type > &psiif, Field< Type > &result) const
Initialise the update of interfaced interfaces.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:118
void updateMatrixInterfaces(const bool add, const FieldField< Field, LUType > &interfaceCoeffs, const Field< Type > &psiif, Field< Type > &result) const
Update interfaced interfaces for matrix operations.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
commsTypes
Types of communications.
Definition: UPstream.H:66
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:578
List< lduScheduleEntry > lduSchedule
A List of lduSchedule entries.
Definition: lduSchedule.H:46
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:51
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:413
Generic templated field type.
Definition: Field.H:61
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)