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) 2011-2012 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::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  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::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::blocking
82  );
83  }
84  }
85  }
86  else
87  {
88  FatalErrorIn("LduMatrix<Type, DType, LUType>::initMatrixInterfaces")
89  << "Unsuported 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::blocking
107  || Pstream::defaultCommsType == Pstream::nonBlocking
108  )
109  {
110  // Block until all sends/receives have been finished
111  if (Pstream::defaultCommsType == Pstream::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::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::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::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::blocking
186  );
187  }
188  }
189  }
190  else
191  {
192  FatalErrorIn("LduMatrix<Type, DType, LUType>::updateMatrixInterfaces")
193  << "Unsuported communications type "
194  << Pstream::commsTypeNames[Pstream::defaultCommsType]
195  << exit(FatalError);
196  }
197 }
198 
199 
200 // ************************************************************************* //
Generic field type.
Definition: FieldField.H:51
void updateMatrixInterfaces(const FieldField< Field, LUType > &interfaceCoeffs, const Field< Type > &psiif, Field< Type > &result) const
Update interfaced interfaces for matrix operations.
void initMatrixInterfaces(const FieldField< Field, LUType > &interfaceCoeffs, const Field< Type > &psiif, Field< Type > &result) const
Initialise the update of interfaced interfaces.
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
#define forAll(list, i)
Definition: UList.H:421
Pre-declare SubField and related Field type.
Definition: Field.H:57
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
error FatalError