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 Foam_oversetFvPatchField_H
42 #define Foam_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 as copy setting internal field reference
137  (
140  );
141 
142  //- Return a clone
143  virtual tmp<fvPatchField<Type>> clone() const
144  {
145  return fvPatchField<Type>::Clone(*this);
146  }
147 
148  //- Clone with an internal field reference
150  (
152  ) const
153  {
154  return fvPatchField<Type>::Clone(*this, iF);
155  }
156 
157 
158  // Member Functions
159 
160  // Coupled and adjust flux
161 
162  //- Return neighbour field. Dummy value
163  virtual tmp<Field<Type>> patchNeighbourField() const
164  {
165  return tmp<Field<Type>>::New(this->size(), Foam::zero{});
166  }
167 
168  //- Retrieve neighbour field. Dummy value
169  virtual void patchNeighbourField(UList<Type>& pnf) const
170  {
171  pnf = Foam::zero{};
172  }
173 
174  //- Adjust psi for mass correction. Requires storeFringeCoefficients
175  // to have been called before
176  void adjustPsi
177  (
179  const lduAddressing& lduAddr,
180  solveScalarField& result
181  ) const;
182 
183  //- Store fringe coefficients and faces
184  void storeFringeCoefficients(const fvMatrix<Type>& matrix);
185 
186  //- Calculate patch flux (helper function). Requires
187  // storeFringeCoefficients to have been called before
188  void fringeFlux
189  (
190  const fvMatrix<Type>& m,
191  const surfaceScalarField& phi
192  ) const;
193 
194 
195  // Evaluation
197  //- Initialise the evaluation of the patch field
198  virtual void initEvaluate(const Pstream::commsTypes commsType);
199 
200  //- Return the matrix diagonal coefficients corresponding to the
201  //- evaluation of the value of this patchField with given weights
203  (
205  ) const
206  {
207  return tmp<Field<Type>>::New(this->size(), Foam::zero{});
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>>::New(this->size(), Foam::zero{});
218  }
219 
220  //- Return the matrix diagonal coefficients corresponding to the
221  //- evaluation of the gradient of this patchField
222  tmp<Field<Type>> gradientInternalCoeffs() const
223  {
224  return tmp<Field<Type>>::New(this->size(), Foam::zero{});
225  }
226 
227  //- Return the matrix source coefficients corresponding to the
228  //- evaluation of the gradient of this patchField
229  tmp<Field<Type>> gradientBoundaryCoeffs() const
230  {
231  return tmp<Field<Type>>::New(this->size(), Foam::zero{});
232  }
233 
234  //- Manipulate matrix
235  virtual void manipulateMatrix(fvMatrix<Type>& matrix);
236 
237 
238  // Coupled interface functionality
239 
240  //- Update result field based on interface functionality
241  virtual void updateInterfaceMatrix
242  (
243  solveScalarField& result,
244  const bool add,
245  const lduAddressing& lduAddr,
246  const label patchId,
247  const solveScalarField& psiInternal,
248  const scalarField& coeffs,
249  const direction,
250  const Pstream::commsTypes commsType
251  ) const;
252 
253  //- Update result field based on interface functionality
254  virtual void updateInterfaceMatrix
255  (
256  Field<Type>&,
257  const bool add,
258  const lduAddressing& lduAddr,
259  const label patchId,
260  const Field<Type>&,
261  const scalarField&,
262  const Pstream::commsTypes commsType
263  ) const
264  {
266  }
267 
268  //- Initialise neighbour matrix update
269  virtual void initInterfaceMatrixUpdate
270  (
271  Field<Type>&,
272  const bool add,
274  const label interfacei,
275  const Field<Type>&,
276  const scalarField&,
277  const Pstream::commsTypes commsType
278  ) const
279  {
281  }
283  virtual void initInterfaceMatrixUpdate
284  (
285  solveScalarField& result,
286  const bool add,
287  const lduAddressing&,
288  const label interfacei,
289  const solveScalarField& psiInternal,
290  const scalarField& coeffs,
291  const direction cmpt,
292  const Pstream::commsTypes commsType
293  ) const;
294 
295 
296  // I-O
297 
298  //- Write
299  virtual void write(Ostream& os) const;
300 };
301 
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 } // End namespace Foam
306 
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 
309 #ifdef NoRepository
310 # include "oversetFvPatchField.C"
311 #endif
312 
313 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
315 #endif
316 
317 // ************************************************************************* //
label patchId(-1)
uint8_t direction
Definition: direction.H:46
Field< solveScalar > solveScalarField
commsTypes
Communications types.
Definition: UPstream.H:77
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
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.
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:607
void storeFringeCoefficients(const fvMatrix< Type > &matrix)
Store fringe coefficients and faces.
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour field. Dummy value.
const bool setHoleCellValue_
Flag to set hole cell values.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
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:702
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
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...
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.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
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:688
Abstract base class for overset coupled interface fields.
Namespace for OpenFOAM.
static tmp< fvPatchField< Type > > New(const word &patchFieldType, const fvPatch &, const DimensionedField< Type, volMesh > &)
Return a pointer to a new patchField created on freestore given.
scalarField fringeLowerCoeffs_
Fringe lower coefficients.
Boundary condition for use on overset patches. To be run in combination with special dynamicFvMesh ty...