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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "LduMatrix.H"
29 #include "lduInterfaceField.H"
30 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
33 template<class Type, class DType, class LUType>
35 (
36  const bool add,
37  const FieldField<Field, LUType>& interfaceCoeffs,
38  const Field<Type>& psiif,
39  Field<Type>& result
40 ) const
41 {
42  if
43  (
44  Pstream::defaultCommsType == Pstream::commsTypes::blocking
45  || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
46  )
47  {
48  forAll(interfaces_, interfacei)
49  {
50  if (interfaces_.set(interfacei))
51  {
52  interfaces_[interfacei].initInterfaceMatrixUpdate
53  (
54  result,
55  add,
56  psiif,
57  interfaceCoeffs[interfacei],
58  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
59  Pstream::defaultCommsType
60  );
61  }
62  }
63  }
64  else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
65  {
66  const lduSchedule& patchSchedule = this->patchSchedule();
67 
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  result,
82  add,
83  psiif,
84  interfaceCoeffs[interfacei],
85  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
86  Pstream::commsTypes::blocking
87  );
88  }
89  }
90  }
91  else
92  {
94  << "Unsupported communications type "
95  << Pstream::commsTypeNames[Pstream::defaultCommsType]
96  << exit(FatalError);
97  }
98 }
99 
100 
101 template<class Type, class DType, class LUType>
103 (
104  const bool add,
105  const FieldField<Field, LUType>& interfaceCoeffs,
106  const Field<Type>& psiif,
107  Field<Type>& result
108 ) const
109 {
110  if
111  (
112  Pstream::defaultCommsType == Pstream::commsTypes::blocking
113  || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
114  )
115  {
116  // Block until all sends/receives have been finished
117  if (Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking)
118  {
119  IPstream::waitRequests();
120  OPstream::waitRequests();
121  }
122 
123  forAll(interfaces_, interfacei)
124  {
125  if (interfaces_.set(interfacei))
126  {
127  interfaces_[interfacei].updateInterfaceMatrix
128  (
129  result,
130  add,
131  psiif,
132  interfaceCoeffs[interfacei],
133  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
134  Pstream::defaultCommsType
135  );
136  }
137  }
138  }
139  else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
140  {
141  const lduSchedule& patchSchedule = this->patchSchedule();
142 
143  // Loop over all the "normal" interfaces relating to standard patches
144  forAll(patchSchedule, i)
145  {
146  label interfacei = patchSchedule[i].patch;
147 
148  if (interfaces_.set(interfacei))
149  {
150  if (patchSchedule[i].init)
151  {
152  interfaces_[interfacei].initInterfaceMatrixUpdate
153  (
154  result,
155  add,
156  psiif,
157  interfaceCoeffs[interfacei],
158  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
159  Pstream::commsTypes::scheduled
160  );
161  }
162  else
163  {
164  interfaces_[interfacei].updateInterfaceMatrix
165  (
166  result,
167  add,
168  psiif,
169  interfaceCoeffs[interfacei],
170  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
171  Pstream::commsTypes::scheduled
172  );
173  }
174  }
175  }
176 
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  result,
191  add,
192  psiif,
193  interfaceCoeffs[interfacei],
194  //Amultiplier<Type, LUType>(interfaceCoeffs[interfacei]),
195  Pstream::commsTypes::blocking
196  );
197  }
198  }
199  }
200  else
201  {
203  << "Unsupported communications type "
204  << Pstream::commsTypeNames[Pstream::defaultCommsType]
205  << exit(FatalError);
206  }
207 }
208 
209 
210 // ************************************************************************* //
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:35
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:103
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:381
Foam::List< lduScheduleEntry >
lduInterfaceField.H