lduInterfaceField.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) 2011-2013 OpenFOAM Foundation
9  Copyright (C) 2019-2023 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 Class
28  Foam::lduInterfaceField
29 
30 Description
31  An abstract base class for implicitly-coupled interface fields
32  e.g. processor and cyclic patch fields.
33 
34 SourceFiles
35  lduInterfaceField.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_lduInterfaceField_H
40 #define Foam_lduInterfaceField_H
41 
42 #include "lduInterface.H"
43 #include "lduAddressing.H"
44 #include "primitiveFieldsFwd.H"
45 #include "Pstream.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward Declarations
53 class lduMatrix;
54 class lduInterfaceField;
55 
56 /*---------------------------------------------------------------------------*\
57  Class lduInterfaceField Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 {
62  // Private Data
63 
64  //- Reference to the coupled patch this field is defined for
65  const lduInterface& interface_;
66 
67  //- Update index used so that updateInterfaceMatrix is called only once
68  //- during the construction of the matrix
69  mutable bool updatedMatrix_;
70 
71 
72 public:
73 
74  //- Runtime type information
75  TypeName("lduInterfaceField");
76 
77 
78  // Generated Methods
79 
80  //- No copy construct
81  lduInterfaceField(const lduInterfaceField&) = delete;
82 
83  //- No copy assignment
84  void operator=(const lduInterfaceField&) = delete;
85 
86 
87  // Constructors
88 
89  //- Construct given coupled patch
90  explicit lduInterfaceField(const lduInterface& patch)
91  :
92  interface_(patch),
93  updatedMatrix_(false)
94  {}
95 
96 
97  //- Destructor
98  virtual ~lduInterfaceField() = default;
99 
100 
101  // Member Functions
102 
103  //- Return the interface
104  const lduInterface& interface() const noexcept
105  {
106  return interface_;
107  }
108 
109  //- Return the interface type
110  virtual const word& interfaceFieldType() const
111  {
112  return type();
113  }
114 
116  // Coupled Interface
117 
118  //- Are all (receive) data available?
119  virtual bool ready() const
120  {
121  return true;
122  }
124  //- Whether matrix has been updated
125  bool updatedMatrix() const noexcept
126  {
127  return updatedMatrix_;
128  }
129 
130  //- Set matrix as update-to-date, return the previous value
131  bool updatedMatrix(bool flag) const noexcept
132  {
133  bool old(updatedMatrix_);
134  updatedMatrix_ = flag;
135  return old;
136  }
137 
138 
139  // Coupled interface matrix update
140 
141  //- Initialise neighbour matrix update.
142  //- Add/subtract coupled contributions to matrix
143  virtual void initInterfaceMatrixUpdate
144  (
145  solveScalarField& result,
146  const bool add,
147  const lduAddressing&,
148  const label interfacei,
149  const solveScalarField& psiInternal,
150  const scalarField& coeffs,
151  const direction cmpt,
152  const Pstream::commsTypes commsType
153  ) const
154  {}
155 
156  //- Update result field based on interface functionality.
157  //- Add/subtract coupled contributions to matrix
158  virtual void updateInterfaceMatrix
159  (
160  solveScalarField& result,
161  const bool add,
162  const lduAddressing&,
163  const label interfacei,
164  const solveScalarField& psiInternal,
165  const scalarField& coeffs,
166  const direction cmpt,
167  const Pstream::commsTypes commsType
168  ) const = 0;
169 
170  //- Add/subtract weighted contributions to internal field
171  template<class Type>
172  void addToInternalField
173  (
174  Field<Type>& result,
175  const bool add,
176  const labelUList& faceCells,
177  const scalarField& coeffs,
178  const Field<Type>& vals
179  ) const;
180 
181 
182  // Housekeeping
183 
184  //- Adjust whether matrix has been updated.
185  // \deprecated Prefer the updatedMatrix(bool) setter (JAN-2023)
186  bool& updatedMatrix() noexcept
187  {
188  return updatedMatrix_;
189  }
190 };
191 
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 } // End namespace Foam
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #ifdef NoRepository
201 #endif
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #endif
206 
207 // ************************************************************************* //
virtual void initInterfaceMatrixUpdate(solveScalarField &result, const bool add, const lduAddressing &, const label interfacei, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update. Add/subtract coupled contributions to matrix. ...
uint8_t direction
Definition: direction.H:46
commsTypes
Communications types.
Definition: UPstream.H:72
bool updatedMatrix() const noexcept
Whether matrix has been updated.
virtual const word & interfaceFieldType() const
Return the interface type.
virtual ~lduInterfaceField()=default
Destructor.
const lduInterface & interface() const noexcept
Return the interface.
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:52
TypeName("lduInterfaceField")
Runtime type information.
An abstract base class for implicitly-coupled interface fields e.g. processor and cyclic patch fields...
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const lduAddressing &, const label interfacei, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const =0
Update result field based on interface functionality. Add/subtract coupled contributions to matrix...
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
Forward declarations of the specialisations of Field<T> for scalar, vector and tensor.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual bool ready() const
Are all (receive) data available?
void addToInternalField(Field< Type > &result, const bool add, const labelUList &faceCells, const scalarField &coeffs, const Field< Type > &vals) const
Add/subtract weighted contributions to internal field.
const direction noexcept
Definition: Scalar.H:258
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
lduInterfaceField(const lduInterfaceField &)=delete
No copy construct.
const std::string patch
OpenFOAM patch number as a std::string.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches...
Definition: lduInterface.H:53
void operator=(const lduInterfaceField &)=delete
No copy assignment.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Namespace for OpenFOAM.