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 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  if
44  (
45  Pstream::defaultCommsType == Pstream::commsTypes::blocking
46  || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
47  )
48  {
49  forAll(interfaces_, interfacei)
50  {
51  if (interfaces_.set(interfacei))
52  {
53  interfaces_[interfacei].initInterfaceMatrixUpdate
54  (
55  result,
56  add,
57  lduMesh_.lduAddr(),
58  interfacei,
59  psiif,
60  interfaceCoeffs[interfacei],
61  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
62  Pstream::defaultCommsType
63  );
64  }
65  }
66  }
67  else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
68  {
69  const lduSchedule& patchSchedule = this->patchSchedule();
70 
71  // Loop over the "global" patches are on the list of interfaces but
72  // beyond the end of the schedule which only handles "normal" patches
73  for
74  (
75  label interfacei=patchSchedule.size()/2;
76  interfacei<interfaces_.size();
77  interfacei++
78  )
79  {
80  if (interfaces_.set(interfacei))
81  {
82  interfaces_[interfacei].initInterfaceMatrixUpdate
83  (
84  result,
85  add,
86  lduMesh_.lduAddr(),
87  interfacei,
88  psiif,
89  interfaceCoeffs[interfacei],
90  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
91  Pstream::commsTypes::blocking
92  );
93  }
94  }
95  }
96  else
97  {
99  << "Unsupported communications type "
100  << Pstream::commsTypeNames[Pstream::defaultCommsType]
101  << exit(FatalError);
102  }
103 }
104 
105 
106 template<class Type, class DType, class LUType>
108 (
109  const bool add,
110  const FieldField<Field, LUType>& interfaceCoeffs,
111  const Field<Type>& psiif,
112  Field<Type>& result
113 ) const
114 {
115  if
116  (
117  Pstream::defaultCommsType == Pstream::commsTypes::blocking
118  || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
119  )
120  {
121  // Block until all sends/receives have been finished
122  if (Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking)
123  {
124  IPstream::waitRequests();
125  OPstream::waitRequests();
126  }
127 
128  forAll(interfaces_, interfacei)
129  {
130  if (interfaces_.set(interfacei))
131  {
132  interfaces_[interfacei].updateInterfaceMatrix
133  (
134  result,
135  add,
136  lduMesh_.lduAddr(),
137  interfacei,
138  psiif,
139  interfaceCoeffs[interfacei],
140  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
141  Pstream::defaultCommsType
142  );
143  }
144  }
145  }
146  else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
147  {
148  const lduSchedule& patchSchedule = this->patchSchedule();
149 
150  // Loop over all the "normal" interfaces relating to standard patches
151  forAll(patchSchedule, i)
152  {
153  label interfacei = patchSchedule[i].patch;
154 
155  if (interfaces_.set(interfacei))
156  {
157  if (patchSchedule[i].init)
158  {
159  interfaces_[interfacei].initInterfaceMatrixUpdate
160  (
161  result,
162  add,
163  lduMesh_.lduAddr(),
164  interfacei,
165  psiif,
166  interfaceCoeffs[interfacei],
167  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
168  Pstream::commsTypes::scheduled
169  );
170  }
171  else
172  {
173  interfaces_[interfacei].updateInterfaceMatrix
174  (
175  result,
176  add,
177  lduMesh_.lduAddr(),
178  interfacei,
179  psiif,
180  interfaceCoeffs[interfacei],
181  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
182  Pstream::commsTypes::scheduled
183  );
184  }
185  }
186  }
187 
188  // Loop over the "global" patches are on the list of interfaces but
189  // beyond the end of the schedule which only handles "normal" patches
190  for
191  (
192  label interfacei=patchSchedule.size()/2;
193  interfacei<interfaces_.size();
194  interfacei++
195  )
196  {
197  if (interfaces_.set(interfacei))
198  {
199  interfaces_[interfacei].updateInterfaceMatrix
200  (
201  result,
202  add,
203  lduMesh_.lduAddr(),
204  interfacei,
205  psiif,
206  interfaceCoeffs[interfacei],
207  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
208  Pstream::commsTypes::blocking
209  );
210  }
211  }
212  }
213  else
214  {
216  << "Unsupported communications type "
217  << Pstream::commsTypeNames[Pstream::defaultCommsType]
218  << exit(FatalError);
219  }
220 }
221 
222 
223 // ************************************************************************* //
Foam::FieldField
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:53
Foam::LduMatrix::initMatrixInterfaces
void initMatrixInterfaces(const bool add, const FieldField< Field, LUType > &interfaceCoeffs, const Field< Type > &psiif, Field< Type > &result) const
Initialise the update of interfaced interfaces.
Definition: LduMatrixUpdateMatrixInterfaces.C:36
Foam::LduMatrix::updateMatrixInterfaces
void updateMatrixInterfaces(const bool add, const FieldField< Field, LUType > &interfaceCoeffs, const Field< Type > &psiif, Field< Type > &result) const
Update interfaced interfaces for matrix operations.
Definition: LduMatrixUpdateMatrixInterfaces.C:108
LduMatrix.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::Field
Generic templated field type.
Definition: Field.H:63
init
mesh init(true)
Foam::FatalError
error FatalError
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:939
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::List< lduScheduleEntry >
lduInterfaceField.H