calculatedProcessorGAMGInterfaceField.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) 2019-2020 OpenCFD Ltd.
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 
30 #include "lduMatrix.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(calculatedProcessorGAMGInterfaceField, 0);
38  (
39  GAMGInterfaceField,
40  calculatedProcessorGAMGInterfaceField,
41  lduInterface
42  );
44  (
45  GAMGInterfaceField,
46  calculatedProcessorGAMGInterfaceField,
47  lduInterfaceField
48  );
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
54 Foam::calculatedProcessorGAMGInterfaceField::
55 calculatedProcessorGAMGInterfaceField
56 (
57  const GAMGInterface& GAMGCp,
58  const lduInterfaceField& fineInterface
59 )
60 :
61  GAMGInterfaceField(GAMGCp, fineInterface),
62  procInterface_(refCast<const calculatedProcessorGAMGInterface>(GAMGCp)),
63  doTransform_(false),
64  rank_(0)
65 {
67  refCast<const processorLduInterfaceField>(fineInterface);
68 
69  doTransform_ = p.doTransform();
70  rank_ = p.rank();
71 }
72 
73 
74 Foam::calculatedProcessorGAMGInterfaceField::
75 calculatedProcessorGAMGInterfaceField
76 (
77  const GAMGInterface& GAMGCp,
78  const bool doTransform,
79  const int rank
80 )
81 :
82  GAMGInterfaceField(GAMGCp, doTransform, rank),
83  procInterface_(refCast<const calculatedProcessorGAMGInterface>(GAMGCp)),
84  doTransform_(doTransform),
85  rank_(rank)
86 {}
87 
88 
89 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90 
92 (
94  const bool add,
95  const solveScalarField& psiInternal,
96  const scalarField&,
97  const direction,
98  const Pstream::commsTypes commsType
99 ) const
100 {
101  procInterface_.interfaceInternalField(psiInternal, scalarSendBuf_);
102 
103  if
104  (
105  commsType == Pstream::commsTypes::nonBlocking
106  && !Pstream::floatTransfer
107  )
108  {
109  // Fast path.
110  scalarReceiveBuf_.setSize(scalarSendBuf_.size());
111  outstandingRecvRequest_ = UPstream::nRequests();
113  (
114  Pstream::commsTypes::nonBlocking,
115  procInterface_.neighbProcNo(),
116  reinterpret_cast<char*>(scalarReceiveBuf_.data()),
117  scalarReceiveBuf_.byteSize(),
118  procInterface_.tag(),
119  comm()
120  );
121 
122  outstandingSendRequest_ = UPstream::nRequests();
124  (
125  Pstream::commsTypes::nonBlocking,
126  procInterface_.neighbProcNo(),
127  reinterpret_cast<const char*>(scalarSendBuf_.cdata()),
128  scalarSendBuf_.byteSize(),
129  procInterface_.tag(),
130  comm()
131  );
132  }
133  else
134  {
135  procInterface_.compressedSend(commsType, scalarSendBuf_);
136  }
137 
139  = false;
140 }
141 
142 
144 (
145  solveScalarField& result,
146  const bool add,
147  const solveScalarField&,
148  const scalarField& coeffs,
149  const direction cmpt,
150  const Pstream::commsTypes commsType
151 ) const
152 {
153  if (updatedMatrix())
154  {
155  return;
156  }
157 
158  if
159  (
160  commsType == Pstream::commsTypes::nonBlocking
161  && !Pstream::floatTransfer
162  )
163  {
164  // Fast path.
165  if
166  (
167  outstandingRecvRequest_ >= 0
168  && outstandingRecvRequest_ < Pstream::nRequests()
169  )
170  {
171  UPstream::waitRequest(outstandingRecvRequest_);
172  }
173  // Recv finished so assume sending finished as well.
174  outstandingSendRequest_ = -1;
175  outstandingRecvRequest_ = -1;
176 
177  // Consume straight from scalarReceiveBuf_
178 
179  // Transform according to the transformation tensor
180  transformCoupleField(scalarReceiveBuf_, cmpt);
181 
182  // Multiply the field by coefficients and add into the result
183  addToInternalField(result, !add, coeffs, scalarReceiveBuf_);
184  }
185  else
186  {
187  solveScalarField pnf
188  (
189  procInterface_.compressedReceive<solveScalar>
190  (
191  commsType,
192  this->size()
193  )()
194  );
195  transformCoupleField(pnf, cmpt);
196 
197  addToInternalField(result, !add, coeffs, pnf);
198  }
199 
201  = true;
202 }
203 
204 
205 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
p
volScalarField & p
Definition: createFieldRefs.H:8
lduMatrix.H
calculatedProcessorGAMGInterfaceField.H
Foam::Field< solveScalar >
Foam::GAMGInterface
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:53
Foam::blockMeshTools::read
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:33
Foam::GAMGInterfaceField
Abstract base class for GAMG agglomerated interface fields.
Definition: GAMGInterfaceField.H:53
Foam::lduInterfaceField::updatedMatrix
bool updatedMatrix() const
Whether matrix has been updated.
Definition: lduInterfaceField.H:119
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
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::lduInterfaceField
An abstract base class for implicitly-coupled interface fields e.g. processor and cyclic patch fields...
Definition: lduInterfaceField.H:58
Foam::calculatedProcessorGAMGInterfaceField
GAMG agglomerated processor interface field.
Definition: calculatedProcessorGAMGInterfaceField.H:52
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::calculatedProcessorGAMGInterfaceField::updateInterfaceMatrix
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
Definition: calculatedProcessorGAMGInterfaceField.C:144
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:35
Foam::processorLduInterfaceField
Abstract base class for processor coupled interfaces.
Definition: processorLduInterfaceField.H:52
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::calculatedProcessorGAMGInterfaceField::initInterfaceMatrixUpdate
virtual void initInterfaceMatrixUpdate(solveScalarField &result, const bool add, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update.
Definition: calculatedProcessorGAMGInterfaceField.C:92