inletOutletFvPatchField.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) 2011-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 
27 #include "surfaceFields.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  const fvPatch& p,
36 )
37 :
38  mixedFvPatchField<Type>(p, iF),
39  phiName_("phi")
40 {
41  this->refValue() = Zero;
42  this->refGrad() = Zero;
43  this->valueFraction() = 0;
45 }
46 
47 
48 template<class Type>
50 (
51  const fvPatch& p,
53  const dictionary& dict,
54  const bool valuesRequired
55 )
56 :
57  mixedFvPatchField<Type>(p, iF, dict, false),
58  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
59 {
60  if (valuesRequired)
61  {
62  this->refValue() =
63  Field<Type>("inletValue", iF.dimensions(), dict, p.size());
64 
65  if (dict.found("value"))
66  {
68  (
69  Field<Type>("value", iF.dimensions(), dict, p.size())
70  );
71  }
72  else
73  {
75  }
76 
77  this->refGrad() = Zero;
78  this->valueFraction() = 0;
79  }
80 }
81 
82 
83 template<class Type>
85 (
87  const fvPatch& p,
89  const fieldMapper& mapper
90 )
91 :
92  mixedFvPatchField<Type>(ptf, p, iF, mapper),
93  phiName_(ptf.phiName_)
94 {}
95 
96 
97 template<class Type>
99 (
102 )
103 :
104  mixedFvPatchField<Type>(ptf, iF),
105  phiName_(ptf.phiName_)
106 {}
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
111 template<class Type>
113 {
114  if (this->updated())
115  {
116  return;
117  }
118 
119  const Field<scalar>& phip =
120  this->patch().template lookupPatchField<surfaceScalarField, scalar>
121  (
122  phiName_
123  );
124 
125  this->valueFraction() = neg(phip);
126 
128 }
129 
130 
131 template<class Type>
133 {
135  if (phiName_ != "phi")
136  {
137  writeEntry(os, "phi", phiName_);
138  }
139  writeEntry(os, "inletValue", this->refValue());
140  writeEntry(os, "value", *this);
141 }
142 
143 
144 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
145 
146 template<class Type>
148 (
149  const fvPatchField<Type>& ptf
150 )
151 {
153  (
154  this->valueFraction()*this->refValue()
155  + (1 - this->valueFraction())*ptf
156  );
157 }
158 
159 
160 // ************************************************************************* //
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
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
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:255
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:208
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
This boundary condition provides a generic outflow condition, with specified inflow for the case of r...
virtual void write(Ostream &) const
Write.
inletOutletFvPatchField(const fvPatch &, const DimensionedField< Type, fvMesh > &)
Construct from patch and internal field.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
This boundary condition provides a base class for 'mixed' type boundary conditions,...
virtual Field< Type > & refValue()
virtual scalarField & valueFraction()
virtual Field< Type > & refGrad()
A class for handling words, derived from string.
Definition: word.H:63
static const zero Zero
Definition: zero.H:97
dimensionedScalar neg(const dimensionedScalar &ds)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dictionary dict
volScalarField & p
Foam::surfaceFields.