fixedMeanOutletInletFvPatchField.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) 2018-2024 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 
27 #include "volFields.H"
28 #include "surfaceFields.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const fvPatch& p,
37  const dictionary& dict
38 )
39 :
40  outletInletFvPatchField<Type>(p, iF),
41  meanValue_
42  (
43  Function1<Type>::New
44  (
45  "meanValue",
46  this->db().time().userUnits(),
47  iF.dimensions(),
48  dict
49  )
50  )
51 {
52  this->phiName_ = dict.lookupOrDefault<word>("phi", "phi");
53 
55  (
56  Field<Type>("value", iF.dimensions(), dict, p.size())
57  );
58 
59  this->refValue() = *this;
60  this->refGrad() = Zero;
61  this->valueFraction() = 0.0;
62 }
63 
64 
65 template<class Type>
67 (
69  const fvPatch& p,
71  const fieldMapper& mapper
72 )
73 :
74  outletInletFvPatchField<Type>(ptf, p, iF, mapper),
75  meanValue_(ptf.meanValue_, false)
76 {}
77 
78 
79 template<class Type>
81 (
84 )
85 :
86  outletInletFvPatchField<Type>(ptf, iF),
87  meanValue_(ptf.meanValue_, false)
88 {}
89 
90 
91 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92 
93 template<class Type>
95 {
96  if (this->updated())
97  {
98  return;
99  }
100 
101  Type meanValue = meanValue_->value(this->db().time().value());
102 
103  Field<Type> newValues(this->patchInternalField());
104 
105  Type meanValuePsi =
106  gSum(this->patch().magSf()*newValues)
107  /gSum(this->patch().magSf());
108 
109  if (mag(meanValue) > small && mag(meanValuePsi)/mag(meanValue) > 0.5)
110  {
111  newValues *= mag(meanValue)/mag(meanValuePsi);
112  }
113  else
114  {
115  newValues += (meanValue - meanValuePsi);
116  }
117 
118  this->refValue() = newValues;
119 
121 }
122 
123 
124 template<class Type>
126 {
128  writeEntry
129  (
130  os,
131  this->db().time().userUnits(),
132  this->internalField().dimensions(),
133  meanValue_()
134  );
135  writeEntry(os, "value", *this);
136 }
137 
138 
139 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
Pre-declare SubField and related Field type.
Definition: Field.H:83
Run-time selectable general function of one variable.
Definition: Function1.H:125
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T, if not found return the given default.
Abstract base class for field mapping.
Definition: fieldMapper.H:48
This boundary condition extrapolates field to the patch using the near-cell values and adjusts the di...
fixedMeanOutletInletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:229
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
virtual Field< Type > & refValue()
virtual scalarField & valueFraction()
virtual Field< Type > & refGrad()
This boundary condition provides a generic inflow condition, with specified outflow for the case of r...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A class for handling words, derived from string.
Definition: word.H:62
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
static const zero Zero
Definition: zero.H:97
Type gSum(const FieldField< Field, Type > &f)
const HashTable< dimensionSet > & dimensions()
Get the table of dimension sets.
Definition: dimensionSets.C:96
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
dimensioned< scalar > mag(const dimensioned< Type > &)
dictionary dict
volScalarField & p
Foam::surfaceFields.