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 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 lduInterfaceField_H
40 #define lduInterfaceField_H
41 
42 #include "lduInterface.H"
43 #include "primitiveFieldsFwd.H"
44 #include "Pstream.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 class lduMatrix;
54 
55 /*---------------------------------------------------------------------------*\
56  Class lduInterfaceField Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 {
61  // Private data
62 
63  //- Reference to the coupled patch this field is defined for
64  const lduInterface& interface_;
65 
66  //- Update index used so that updateInterfaceMatrix is called only once
67  // during the construction of the matrix
68  bool updatedMatrix_;
69 
70 
71  // Private Member Functions
72 
73  //- No copy construct
74  lduInterfaceField(const lduInterfaceField&) = delete;
75 
76  //- No copy assignment
77  void operator=(const lduInterfaceField&) = delete;
78 
79 
80 public:
81 
82  //- Runtime type information
83  TypeName("lduInterfaceField");
84 
85 
86  // Constructors
87 
88  //- Construct given coupled patch
89  explicit lduInterfaceField(const lduInterface& patch)
90  :
91  interface_(patch),
92  updatedMatrix_(false)
93  {}
94 
95 
96  //- Destructor
97  virtual ~lduInterfaceField() = default;
98 
99 
100  // Member Functions
101 
102  // Access
103 
104  //- Return the interface
105  const lduInterface& interface() const
106  {
107  return interface_;
108  }
109 
110  //- Return the interface type
111  virtual const word& interfaceFieldType() const
112  {
113  return type();
114  }
115 
116 
117  // Coupled interface matrix update
118 
119  //- Whether matrix has been updated
120  bool updatedMatrix() const
121  {
122  return updatedMatrix_;
123  }
124 
125  //- Whether matrix has been updated
126  bool& updatedMatrix()
127  {
128  return updatedMatrix_;
129  }
130 
131  //- Is all data available
132  virtual bool ready() const
133  {
134  return true;
135  }
136 
137  //- Initialise neighbour matrix update.
138  //- Add/subtract coupled contributions to matrix
140  (
141  solveScalarField& result,
142  const bool add,
143  const solveScalarField& psiInternal,
144  const scalarField& coeffs,
145  const direction cmpt,
146  const Pstream::commsTypes commsType
147  ) const
148  {}
149 
150  //- Update result field based on interface functionality.
151  //- Add/subtract coupled contributions to matrix
152  virtual void updateInterfaceMatrix
153  (
154  solveScalarField& result,
155  const bool add,
156  const solveScalarField& psiInternal,
157  const scalarField& coeffs,
158  const direction cmpt,
159  const Pstream::commsTypes commsType
160  ) const = 0;
161 
162  //- Add/subtract weighted contributions to internal field
163  template<class Type>
164  void addToInternalField
165  (
166  Field<Type>& result,
167  const bool add,
168  const scalarField& coeffs,
169  const Field<Type>& vals
170  ) const;
171 };
172 
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 } // End namespace Foam
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 #ifdef NoRepository
182 #endif
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 #endif
187 
188 // ************************************************************************* //
Foam::lduInterfaceField::addToInternalField
void addToInternalField(Field< Type > &result, const bool add, const scalarField &coeffs, const Field< Type > &vals) const
Add/subtract weighted contributions to internal field.
Definition: lduInterfaceFieldTemplates.C:32
primitiveFieldsFwd.H
Forward declarations of the specialisations of Field<T> for scalar, vector and tensor.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::lduInterface
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
Definition: lduInterface.H:54
Foam::lduInterfaceField::initInterfaceMatrixUpdate
virtual void initInterfaceMatrixUpdate(solveScalarField &result, const bool add, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Definition: lduInterfaceField.H:139
Foam::lduInterfaceField::TypeName
TypeName("lduInterfaceField")
Runtime type information.
Foam::Field< solveScalar >
Foam::lduInterfaceField::lduInterfaceField
lduInterfaceField(const lduInterface &patch)
Construct given coupled patch.
Definition: lduInterfaceField.H:88
Foam::lduInterfaceField::~lduInterfaceField
virtual ~lduInterfaceField()=default
Destructor.
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
Pstream.H
Foam::lduInterfaceField::updateInterfaceMatrix
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const =0
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::lduInterfaceField::updatedMatrix
bool & updatedMatrix()
Whether matrix has been updated.
Definition: lduInterfaceField.H:125
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::lduInterfaceField::ready
virtual bool ready() const
Is all data available.
Definition: lduInterfaceField.H:131
lduInterfaceFieldTemplates.C
lduInterface.H
Foam::lduInterfaceField::interfaceFieldType
virtual const word & interfaceFieldType() const
Return the interface type.
Definition: lduInterfaceField.H:110
Foam::lduInterfaceField::interface
const lduInterface & interface() const
Return the interface.
Definition: lduInterfaceField.H:104