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 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
163  virtual tmp<Field<Type>> patchNeighbourField() const;
164 
165  //- Adjust psi for mass correction. Requires storeFringeCoefficients
166  // to have been called before
167  void adjustPsi
168  (
170  const lduAddressing& lduAddr,
171  solveScalarField& result
172  ) const;
173 
174  //- Store fringe coefficients and faces
175  void storeFringeCoefficients(const fvMatrix<Type>& matrix);
176 
177  //- Calculate patch flux (helper function). Requires
178  // storeFringeCoefficients to have been called before
179  void fringeFlux
180  (
181  const fvMatrix<Type>& m,
182  const surfaceScalarField& phi
183  ) const;
184 
185 
186  // Evaluation
187 
188  //- Initialise the evaluation of the patch field
189  virtual void initEvaluate(const Pstream::commsTypes commsType);
190 
191  //- Return the matrix diagonal coefficients corresponding to the
192  //- evaluation of the value of this patchField with given weights
194  (
195  const tmp<scalarField>&
196  ) const
197  {
198  return tmp<Field<Type>>::New(this->size(), Foam::zero{});
199  }
200 
201  //- Return the matrix source coefficients corresponding to the
202  //- evaluation of the value of this patchField with given weights
203  virtual tmp<Field<Type>> valueBoundaryCoeffs
204  (
205  const tmp<scalarField>&
206  ) const
207  {
208  return tmp<Field<Type>>::New(this->size(), Foam::zero{});
209  }
210 
211  //- Return the matrix diagonal coefficients corresponding to the
212  //- evaluation of the gradient of this patchField
213  tmp<Field<Type>> gradientInternalCoeffs() const
214  {
215  return tmp<Field<Type>>::New(this->size(), Foam::zero{});
216  }
217 
218  //- Return the matrix source coefficients corresponding to the
219  //- evaluation of the gradient of this patchField
220  tmp<Field<Type>> gradientBoundaryCoeffs() const
221  {
222  return tmp<Field<Type>>::New(this->size(), Foam::zero{});
223  }
224 
225  //- Manipulate matrix
226  virtual void manipulateMatrix(fvMatrix<Type>& matrix);
227 
228 
229  // Coupled interface functionality
230 
231  //- Update result field based on interface functionality
232  virtual void updateInterfaceMatrix
233  (
234  solveScalarField& result,
235  const bool add,
236  const lduAddressing& lduAddr,
237  const label patchId,
238  const solveScalarField& psiInternal,
239  const scalarField& coeffs,
240  const direction,
241  const Pstream::commsTypes commsType
242  ) const;
243 
244  //- Update result field based on interface functionality
245  virtual void updateInterfaceMatrix
246  (
247  Field<Type>&,
248  const bool add,
249  const lduAddressing& lduAddr,
250  const label patchId,
251  const Field<Type>&,
252  const scalarField&,
253  const Pstream::commsTypes commsType
254  ) const
255  {
257  }
258 
259  //- Initialise neighbour matrix update
260  virtual void initInterfaceMatrixUpdate
261  (
263  const bool add,
264  const lduAddressing&,
265  const label interfacei,
266  const Field<Type>&,
267  const scalarField&,
268  const Pstream::commsTypes commsType
269  ) const
270  {
272  }
273 
274  virtual void initInterfaceMatrixUpdate
275  (
276  solveScalarField& result,
277  const bool add,
278  const lduAddressing&,
279  const label interfacei,
280  const solveScalarField& psiInternal,
281  const scalarField& coeffs,
282  const direction cmpt,
283  const Pstream::commsTypes commsType
284  ) const;
285 
286 
287  // I-O
288 
289  //- Write
290  virtual void write(Ostream& os) const;
291 };
292 
293 
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 
296 } // End namespace Foam
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
300 #ifdef NoRepository
301 # include "oversetFvPatchField.C"
302 #endif
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 #endif
307 
308 // ************************************************************************* //
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
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.
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
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:680
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:696
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...