oversetFvPatchField.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) 2016-2022 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::oversetFvPatchField
28 
29 Group
30  grpCoupledBoundaryConditions
31 
32 Description
33  Boundary condition for use on overset patches. To be run in combination
34  with special dynamicFvMesh type that inserts interpolation into the matrix.
35 
36 SourceFiles
37  oversetFvPatchField.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef oversetFvPatchField_H
42 #define oversetFvPatchField_H
43 
44 #include "oversetFvPatch.H"
45 #include "coupledFvPatchFields.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class oversetFvPatchField Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 template<class Type>
59 :
61  public coupledFvPatchField<Type>
62 {
63 protected:
64 
65  // Protected Data
66 
67  //- Local reference cast into the overset patch
69 
70  //- Master patch ID
71  mutable label masterPatchID_;
72 
73  // Hole cell controls
74 
75  //- Flag to set hole cell values
76  const bool setHoleCellValue_;
77 
78  //- Flag to correct fluxes
79  const bool fluxCorrection_;
80 
81  //- Flag to interpolate hole cell values (from nearby non-hole cell)
83 
84  //- Hole cell value
85  const Type holeCellValue_;
86 
87  //- Fringe upper coefficients
89 
90  //- Fringe lower coefficients
92 
93  //- Fringe faces
94  mutable labelField fringeFaces_;
95 
96  //- Zone to sum flux for mass conservation
97  label zoneId_;
98 
99 
100 public:
101 
102  //- Runtime type information
103  TypeName(oversetFvPatch::typeName_());
104 
105 
106  // Constructors
108  //- Construct from patch and internal field
110  (
111  const fvPatch&,
113  );
114 
115  //- Construct from patch, internal field and dictionary
117  (
118  const fvPatch&,
120  const dictionary&
121  );
122 
123  //- Construct by mapping given oversetFvPatchField onto a new patch
125  (
127  const fvPatch&,
129  const fvPatchFieldMapper&
130  );
131 
132  //- Construct as copy
134 
135  //- Construct and return a clone
136  virtual tmp<fvPatchField<Type>> clone() const
137  {
138  return tmp<fvPatchField<Type>>
139  (
140  new oversetFvPatchField<Type>(*this)
141  );
142  }
143 
144  //- Construct as copy setting internal field reference
146  (
149  );
150 
151  //- Construct and return a clone setting internal field reference
153  (
155  ) const
156  {
157  return tmp<fvPatchField<Type>>
158  (
159  new oversetFvPatchField<Type>(*this, iF)
160  );
161  }
162 
164  // Member Functions
165 
166  // Coupled and adjust flux
167 
168  //- Return neighbour field. Dummy
169  virtual tmp<Field<Type>> patchNeighbourField() const;
170 
171  //- Adjust psi for mass correction. Requires storeFringeCoefficients
172  // to have been called before
173  void adjustPsi
174  (
176  const lduAddressing& lduAddr,
177  solveScalarField& result
178  ) const;
179 
180  //- Store fringe coefficients and faces
181  void storeFringeCoefficients(const fvMatrix<Type>& matrix);
182 
183  //- Calculate patch flux (helper function). Requires
184  // storeFringeCoefficients to have been called before
185  void fringeFlux
186  (
187  const fvMatrix<Type>& m,
188  const surfaceScalarField& phi
189  ) const;
190 
191 
192  // Evaluation
193 
194  //- Initialise the evaluation of the patch field
195  virtual void initEvaluate(const Pstream::commsTypes commsType);
196 
197  //- Return the matrix diagonal coefficients corresponding to the
198  //- evaluation of the value of this patchField with given weights
200  (
201  const tmp<scalarField>&
202  ) const
203  {
204  return tmp<Field<Type>>
205  (
206  new Field<Type>(this->size(), Zero)
207  );
208  }
209 
210  //- Return the matrix source coefficients corresponding to the
211  //- evaluation of the value of this patchField with given weights
213  (
214  const tmp<scalarField>&
215  ) const
216  {
217  return tmp<Field<Type>>
218  (
219  new Field<Type>(this->size(), Zero)
220  );
221  }
222 
223  //- Return the matrix diagonal coefficients corresponding to the
224  //- evaluation of the gradient of this patchField
225  tmp<Field<Type>> gradientInternalCoeffs() const
226  {
227  return tmp<Field<Type>>
228  (
229  new Field<Type>(this->size(), Zero)
230  );
231  }
232 
233  //- Return the matrix source coefficients corresponding to the
234  //- evaluation of the gradient of this patchField
235  tmp<Field<Type>> gradientBoundaryCoeffs() const
236  {
237  return tmp<Field<Type>>
238  (
239  new Field<Type>(this->size(), Zero)
240  );
241  }
242 
243  //- Manipulate matrix
244  virtual void manipulateMatrix(fvMatrix<Type>& matrix);
246 
247  // Coupled interface functionality
248 
249  //- Update result field based on interface functionality
250  virtual void updateInterfaceMatrix
251  (
252  solveScalarField& result,
253  const bool add,
254  const lduAddressing& lduAddr,
255  const label patchId,
256  const solveScalarField& psiInternal,
257  const scalarField& coeffs,
258  const direction,
259  const Pstream::commsTypes commsType
260  ) const;
261 
262  //- Update result field based on interface functionality
263  virtual void updateInterfaceMatrix
264  (
265  Field<Type>&,
266  const bool add,
267  const lduAddressing& lduAddr,
268  const label patchId,
269  const Field<Type>&,
270  const scalarField&,
271  const Pstream::commsTypes commsType
272  ) const
273  {
275  }
276 
277  //- Initialise neighbour matrix update
278  virtual void initInterfaceMatrixUpdate
279  (
280  Field<Type>&,
281  const bool add,
282  const lduAddressing&,
283  const label interfacei,
284  const Field<Type>&,
285  const scalarField&,
286  const Pstream::commsTypes commsType
287  ) const
288  {
290  }
291 
292  virtual void initInterfaceMatrixUpdate
293  (
294  solveScalarField& result,
295  const bool add,
296  const lduAddressing&,
297  const label interfacei,
298  const solveScalarField& psiInternal,
299  const scalarField& coeffs,
300  const direction cmpt,
301  const Pstream::commsTypes commsType
302  ) const;
303 
304 
305  // I-O
306 
307  //- Write
308  virtual void write(Ostream& os) const;
309 };
310 
311 
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 
314 } // End namespace Foam
315 
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317 
318 #ifdef NoRepository
319 # include "oversetFvPatchField.C"
320 #endif
322 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
323 
324 #endif
325 
326 // ************************************************************************* //
label patchId(-1)
uint8_t direction
Definition: direction.H:46
commsTypes
Communications types.
Definition: UPstream.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
void fringeFlux(const fvMatrix< Type > &m, const surfaceScalarField &phi) const
Calculate patch flux (helper function). Requires.
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
const bool interpolateHoleCellValue_
Flag to interpolate hole cell values (from nearby non-hole cell)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour field. Dummy.
Patch for indicating interpolated boundaries (in overset meshes).
tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the evaluation of the gradient of this patch...
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the evaluation of the value of this patchField...
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
void storeFringeCoefficients(const fvMatrix< Type > &matrix)
Store fringe coefficients and faces.
const bool setHoleCellValue_
Flag to set hole cell values.
A FieldMapper for finite-volume patch fields.
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:64
virtual void initInterfaceMatrixUpdate(Field< Type > &, const bool add, const lduAddressing &, const label interfacei, const Field< Type > &, const scalarField &, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update.
Abstract base class for coupled patches.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
oversetFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
void adjustPsi(solveScalarField &psi, const lduAddressing &lduAddr, solveScalarField &result) const
Adjust psi for mass correction. Requires storeFringeCoefficients.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
label size() const noexcept
The number of elements in the container.
Definition: UList.H:671
OBJstream os(runTime.globalPath()/outputName)
label zoneId_
Zone to sum flux for mass conservation.
tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the evaluation of the gradient of this patchFi...
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
const oversetFvPatch & oversetPatch_
Local reference cast into the overset patch.
label masterPatchID_
Master patch ID.
const Type holeCellValue_
Hole cell value.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the evaluation of the value of this patchFie...
scalarField fringeUpperCoeffs_
Fringe upper coefficients.
labelField fringeFaces_
Fringe faces.
const volScalarField & psi
The class contains the addressing required by the lduMatrix: upper, lower and losort.
const bool fluxCorrection_
Flag to correct fluxes.
virtual void manipulateMatrix(fvMatrix< Type > &matrix)
Manipulate matrix.
virtual void write(Ostream &os) const
Write.
TypeName(oversetFvPatch::typeName_())
Runtime type information.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
Abstract base class for overset coupled interface fields.
Namespace for OpenFOAM.
scalarField fringeLowerCoeffs_
Fringe lower coefficients.
Boundary condition for use on overset patches. To be run in combination with special dynamicFvMesh ty...
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127