lduCalculatedProcessorField.H
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) 2022-2023 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 Class
27  Foam::lduCalculatedProcessorField
28 
29 Group
30  grpGenericBoundaryConditions
31 
32 Description
33  A lduProcessorField type bypassing coupledFvPatchField
34 
35  Used to add updateInterfaceMatrix capabilities to a lduMatrix
36  which is fully uncoupled from the fvMesh.
37 
38  Its functionality is purely to init and update the processor interfaces.
39 
40 SourceFiles
41  lduCalculatedProcessorField.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef Foam_lduCalculatedProcessorField_H
46 #define Foam_lduCalculatedProcessorField_H
47 
50 #include "LduInterfaceField.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 /*---------------------------------------------------------------------------*\
58  Class lduCalculatedProcessorField Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 template<class Type>
63 :
64  public LduInterfaceField<Type>,
66 {
67 protected:
68 
69  // Protected Data
70 
71  //- Local reference cast into the interface
73 
74 
75  // Sending and receiving
76 
77  //- Current (non-blocking) send request
78  mutable label sendRequest_;
79 
80  //- Current (non-blocking) recv request
81  mutable label recvRequest_;
82 
83  //- Send buffer
84  mutable Field<Type> sendBuf_;
85 
86  //- Receive buffer
88 
89  //- Scalar send buffer
91 
92  //- Scalar recv buffer
94 
95 
96  // Protected Member Functions
97 
99  (
100  solveScalarField& result,
101  const bool add,
102  const scalarField& coeffs,
103  const solveScalarField& vals
104  ) const;
105 
106  //- Receive and send requests have both completed
107  virtual bool all_ready() const;
108 
109 
110 public:
111 
112  //- Runtime type information
113  ClassName("lduCalculatedProcessorField");
114 
115 
116  // Constructors
117 
118  //- Construct from ldu interface
120  (
121  const lduInterface& interface
122  );
123 
124  //- Copy construct
126  (
128  );
129 
130 
131  //- Destructor
132  virtual ~lduCalculatedProcessorField() = default;
133 
134 
135  // Member Functions
136 
137  // Evaluation
138 
139  //- Are all (receive) data available?
140  virtual bool ready() const;
141 
142  //- Initialise neighbour matrix update
143  virtual void initInterfaceMatrixUpdate
144  (
145  solveScalarField& result,
146  const bool add,
147  const lduAddressing& lduAddr,
148  const label patchId,
149  const solveScalarField& psiInternal,
150  const scalarField& coeffs,
151  const direction cmpt,
152  const Pstream::commsTypes commsType
153  ) const;
154 
155  //- Update result field based on interface functionality
156  virtual void updateInterfaceMatrix
157  (
158  solveScalarField& result,
159  const bool add,
160  const lduAddressing& lduAddr,
161  const label patchId,
162  const solveScalarField& psiInternal,
163  const scalarField& coeffs,
164  const direction cmpt,
165  const Pstream::commsTypes commsType
166  ) const;
167 
168  //- Initialise neighbour matrix update
169  virtual void initInterfaceMatrixUpdate
170  (
171  Field<scalar>& result,
172  const bool add,
173  const lduAddressing& lduAddr,
174  const label patchId,
175  const Field<scalar>& psiInternal,
176  const scalarField& coeffs,
177  const Pstream::commsTypes commsType
178  ) const
179  {
181  }
182 
183  //- Update result field based on interface functionality
184  virtual void updateInterfaceMatrix
185  (
186  Field<scalar>& result,
187  const bool add,
188  const lduAddressing& lduAddr,
189  const label patchId,
190  const Field<scalar>& psiInternal,
191  const scalarField& coeffs,
192  const Pstream::commsTypes commsType
193  ) const
194  {
196  }
198 
199  // Processor coupled interface functions
200 
201  //- Return communicator used for communication
202  virtual label comm() const
203  {
204  return procInterface_.comm();
205  }
206 
207  //- Return processor number
208  virtual int myProcNo() const
209  {
210  return procInterface_.myProcNo();
211  }
212 
213  //- Return neighbour processor number
214  virtual int neighbProcNo() const
215  {
216  return procInterface_.myProcNo();
217  }
218 
219  //- Is the transform required
220  virtual bool doTransform() const
221  {
222  return false;
223  }
224 
225  //- Return face transformation tensor
226  virtual const tensorField& forwardT() const
227  {
228  return procInterface_.forwardT();
229  }
230 
231  //- Return rank of component for transform
232  virtual int rank() const
233  {
234  return pTraits<Type>::rank;
235  }
236 };
237 
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 } // End namespace Foam
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 #ifdef NoRepository
247 #endif
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 #endif
252 
253 // ************************************************************************* //
virtual label comm() const
Return communicator used for sending.
label patchId(-1)
virtual int myProcNo() const
Return processor number (rank in communicator)
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
virtual int neighbProcNo() const
Return neighbour processor number.
uint8_t direction
Definition: direction.H:46
virtual const tensorField & forwardT() const
Return face transformation tensor.
virtual int rank() const
Return rank of component for transform.
commsTypes
Communications types.
Definition: UPstream.H:72
label recvRequest_
Current (non-blocking) recv request.
label sendRequest_
Current (non-blocking) send request.
virtual bool doTransform() const
Is the transform required.
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:75
An abstract base class for implicitly-coupled interface fields e.g. processor and cyclic patch fields...
const lduInterface & interface() const noexcept
Return the interface.
Field< Type > recvBuf_
Receive buffer.
virtual const tensorField & forwardT() const
Return face transformation tensor.
solveScalarField scalarSendBuf_
Scalar send buffer.
solveScalarField scalarRecvBuf_
Scalar recv buffer.
virtual void initInterfaceMatrixUpdate(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update.
virtual bool all_ready() const
Receive and send requests have both completed.
lduCalculatedProcessorField(const lduInterface &interface)
Construct from ldu interface.
void addToInternalField(solveScalarField &result, const bool add, const scalarField &coeffs, const solveScalarField &vals) const
Abstract base class for processor coupled interfaces.
Generic templated field type.
Definition: Field.H:62
virtual ~lduCalculatedProcessorField()=default
Destructor.
virtual bool ready() const
Are all (receive) data available?
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Concrete implementation of processor interface. Used to temporarily store settings.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches...
Definition: lduInterface.H:53
A lduProcessorField type bypassing coupledFvPatchField.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
const lduPrimitiveProcessorInterface & procInterface_
Local reference cast into the interface.
virtual label comm() const
Return communicator used for communication.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
ClassName("lduCalculatedProcessorField")
Runtime type information.
Namespace for OpenFOAM.
virtual int myProcNo() const
Return processor number.