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-2022 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 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const fvPatch& p,
35 )
36 :
38  phiName_("phi")
39 {
40  this->refValue() = Zero;
41  this->refGrad() = Zero;
42  this->valueFraction() = 0.0;
43 }
44 
45 
46 template<class Type>
48 (
49  const fvPatch& p,
51  const dictionary& dict
52 )
53 :
55  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
56 {
57  this->refValue() = Field<Type>("inletValue", dict, p.size());
58 
59  if (dict.found("value"))
60  {
62  (
63  Field<Type>("value", dict, p.size())
64  );
65  }
66  else
67  {
68  fvPatchField<Type>::operator=(this->refValue());
69  }
70 
71  this->refGrad() = Zero;
72  this->valueFraction() = 0.0;
73 }
74 
75 
76 template<class Type>
78 (
80  const fvPatch& p,
82  const fvPatchFieldMapper& mapper
83 )
84 :
85  mixedFvPatchField<Type>(ptf, p, iF, mapper),
86  phiName_(ptf.phiName_)
87 {}
88 
89 
90 template<class Type>
92 (
95 )
96 :
97  mixedFvPatchField<Type>(ptf, iF),
98  phiName_(ptf.phiName_)
99 {}
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
104 template<class Type>
106 {
107  if (this->updated())
108  {
109  return;
110  }
111 
112  const Field<scalar>& phip =
113  this->patch().template lookupPatchField<surfaceScalarField, scalar>
114  (
115  phiName_
116  );
117 
118  this->valueFraction() = neg(phip);
119 
121 }
122 
123 
124 template<class Type>
126 {
128  if (phiName_ != "phi")
129  {
130  writeEntry(os, "phi", phiName_);
131  }
132  writeEntry(os, "inletValue", this->refValue());
133  writeEntry(os, "value", *this);
134 }
135 
136 
137 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
138 
139 template<class Type>
140 void Foam::inletOutletFvPatchField<Type>::operator=
141 (
142  const fvPatchField<Type>& ptf
143 )
144 {
146  (
147  this->valueFraction()*this->refValue()
148  + (1 - this->valueFraction())*ptf
149  );
150 }
151 
152 
153 // ************************************************************************* //
dictionary dict
virtual void write(Ostream &) const
Write.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
This boundary condition provides a base class for &#39;mixed&#39; type boundary conditions, i.e. conditions that mix fixed value and patch-normal gradient conditions.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
dimensionedScalar neg(const dimensionedScalar &ds)
Pre-declare SubField and related Field type.
Definition: Field.H:56
A class for handling words, derived from string.
Definition: word.H:59
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Foam::fvPatchFieldMapper.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
static const zero Zero
Definition: zero.H:97
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
volScalarField & p
inletOutletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
This boundary condition provides a generic outflow condition, with specified inflow for the case of r...