processorGAMGInterfaceField.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-2020 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 
31 #include "lduMatrix.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(processorGAMGInterfaceField, 0);
39  (
40  GAMGInterfaceField,
41  processorGAMGInterfaceField,
42  lduInterface
43  );
45  (
46  GAMGInterfaceField,
47  processorGAMGInterfaceField,
48  lduInterfaceField
49  );
50 }
51 
52 
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 
55 Foam::processorGAMGInterfaceField::processorGAMGInterfaceField
56 (
57  const GAMGInterface& GAMGCp,
58  const lduInterfaceField& fineInterface
59 )
60 :
61  GAMGInterfaceField(GAMGCp, fineInterface),
62  procInterface_(refCast<const processorGAMGInterface>(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::processorGAMGInterfaceField::processorGAMGInterfaceField
75 (
76  const GAMGInterface& GAMGCp,
77  const bool doTransform,
78  const int rank
79 )
80 :
81  GAMGInterfaceField(GAMGCp, doTransform, rank),
82  procInterface_(refCast<const processorGAMGInterface>(GAMGCp)),
83  doTransform_(doTransform),
84  rank_(rank)
85 {}
86 
87 
88 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
89 
91 (
93  const bool,
94  const solveScalarField& psiInternal,
95  const scalarField&,
96  const direction,
97  const Pstream::commsTypes commsType
98 ) const
99 {
100  procInterface_.interfaceInternalField(psiInternal, scalarSendBuf_);
101 
102  if
103  (
104  commsType == Pstream::commsTypes::nonBlocking
105  && !Pstream::floatTransfer
106  )
107  {
108  // Fast path.
109  scalarReceiveBuf_.setSize(scalarSendBuf_.size());
110  outstandingRecvRequest_ = UPstream::nRequests();
112  (
113  Pstream::commsTypes::nonBlocking,
114  procInterface_.neighbProcNo(),
115  reinterpret_cast<char*>(scalarReceiveBuf_.data()),
116  scalarReceiveBuf_.byteSize(),
117  procInterface_.tag(),
118  comm()
119  );
120 
121  outstandingSendRequest_ = UPstream::nRequests();
123  (
124  Pstream::commsTypes::nonBlocking,
125  procInterface_.neighbProcNo(),
126  reinterpret_cast<const char*>(scalarSendBuf_.cdata()),
127  scalarSendBuf_.byteSize(),
128  procInterface_.tag(),
129  comm()
130  );
131  }
132  else
133  {
134  procInterface_.compressedSend(commsType, scalarSendBuf_);
135  }
136 
137  const_cast<processorGAMGInterfaceField&>(*this).updatedMatrix() = false;
138 }
139 
140 
142 (
143  solveScalarField& result,
144  const bool add,
145  const solveScalarField&,
146  const scalarField& coeffs,
147  const direction cmpt,
148  const Pstream::commsTypes commsType
149 ) const
150 {
151  if (updatedMatrix())
152  {
153  return;
154  }
155 
156  if
157  (
158  commsType == Pstream::commsTypes::nonBlocking
159  && !Pstream::floatTransfer
160  )
161  {
162  // Fast path.
163  if
164  (
165  outstandingRecvRequest_ >= 0
166  && outstandingRecvRequest_ < Pstream::nRequests()
167  )
168  {
169  UPstream::waitRequest(outstandingRecvRequest_);
170  }
171  // Recv finished so assume sending finished as well.
172  outstandingSendRequest_ = -1;
173  outstandingRecvRequest_ = -1;
174 
175  // Consume straight from scalarReceiveBuf_
176 
177  // Transform according to the transformation tensor
178  transformCoupleField(scalarReceiveBuf_, cmpt);
179 
180  // Multiply the field by coefficients and add into the result
181  addToInternalField(result, !add, coeffs, scalarReceiveBuf_);
182  }
183  else
184  {
185  solveScalarField pnf
186  (
187  procInterface_.compressedReceive<solveScalar>
188  (
189  commsType,
190  coeffs.size()
191  )
192  );
193  transformCoupleField(pnf, cmpt);
194 
195  addToInternalField(result, !add, coeffs, pnf);
196  }
197 
198  const_cast<processorGAMGInterfaceField&>(*this).updatedMatrix() = true;
199 }
200 
201 
202 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
p
volScalarField & p
Definition: createFieldRefs.H:8
lduMatrix.H
Foam::processorGAMGInterfaceField
GAMG agglomerated processor interface field.
Definition: processorGAMGInterfaceField.H:53
Foam::Field< solveScalar >
Foam::GAMGInterface
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:53
Foam::processorGAMGInterfaceField::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: processorGAMGInterfaceField.C:142
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::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
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
processorGAMGInterfaceField.H
Foam::processorLduInterfaceField
Abstract base class for processor coupled interfaces.
Definition: processorLduInterfaceField.H:52
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::processorGAMGInterfaceField::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: processorGAMGInterfaceField.C:91