meanInletOutletFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2025-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
28 #include "fieldMapper.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
35 (
36  const fvPatch& p,
38  const dictionary& dict
39 )
40 :
41  inletOutletFvPatchScalarField(p, iF)
42 {
43  this->phiName_ = dict.lookupOrDefault<word>("phi", "phi");
44 
45  this->refGrad() = Zero;
46  this->valueFraction() = 0.0;
47 
48  if (dict.found("value"))
49  {
51  (
52  scalarField("value", iF.dimensions(), dict, p.size())
53  );
54  this->refValue() = *this;
55  }
56  else
57  {
59  }
60 }
61 
62 
64 (
66  const fvPatch& p,
68  const fieldMapper& mapper
69 )
70 :
71  inletOutletFvPatchScalarField(ptf, p, iF, mapper)
72 {}
73 
74 
76 (
79 )
80 :
81  inletOutletFvPatchScalarField(tppsf, iF)
82 {}
83 
84 
85 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
86 
88 {
89  if (updated())
90  {
91  return;
92  }
93 
94  const scalar averagePsi
95  (
96  min
97  (
98  max
99  (
100  gSum(patch().magSf()*patchInternalField())
101  /gSum(patch().magSf()),
102  0
103  ),
104  1
105  )
106  );
107 
108  refValue() = averagePsi;
109 
110  inletOutletFvPatchScalarField::updateCoeffs();
111 }
112 
113 
115 const
116 {
118  writeEntryIfDifferent<word>(os, "phi", "phi", this->phiName_);
119  writeEntry(os, "value", *this);
120 }
121 
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 namespace Foam
126 {
128  (
131  );
132 }
133 
134 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:90
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:235
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
This boundary condition provides an outflow condition for scalars where the patch adjacent mean is ap...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
meanInletOutletFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, fvMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
makePatchTypeField(fvPatchScalarField, atmosphericBoundaryLayerTurbulentEpsilonFvPatchScalarField)
Type gSum(const UList< Type > &f, const label comm)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void evaluate(GeometricField< Type, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, GeoMesh > &x)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dictionary dict
volScalarField & p
Foam::surfaceFields.