uniformInletOutletFvPatchField.C
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) 2013-2017 OpenFOAM Foundation
9  Copyright (C) 2015-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const fvPatch& p,
38 )
39 :
41  phiName_("phi")
42 {
43  this->refValue() = Zero;
44  this->refGrad() = Zero;
45  this->valueFraction() = 0.0;
46 }
47 
48 
49 template<class Type>
51 (
52  const fvPatch& p,
54  const dictionary& dict
55 )
56 :
58  phiName_(dict.getOrDefault<word>("phi", "phi")),
59  uniformInletValue_(Function1<Type>::New("uniformInletValue", dict))
60 {
61  this->patchType() = dict.getOrDefault<word>("patchType", word::null);
62  this->refValue() =
63  uniformInletValue_->value(this->db().time().timeOutputValue());
64 
65  if (dict.found("value"))
66  {
68  (
69  Field<Type>("value", dict, p.size())
70  );
71  }
72  else
73  {
74  fvPatchField<Type>::operator=(this->refValue());
75  }
76 
77  this->refGrad() = Zero;
78  this->valueFraction() = 0.0;
79 }
80 
81 
82 template<class Type>
84 (
86  const fvPatch& p,
88  const fvPatchFieldMapper& mapper
89 )
90 :
91  mixedFvPatchField<Type>(p, iF), // Don't map
92  phiName_(ptf.phiName_),
93  uniformInletValue_(ptf.uniformInletValue_.clone())
94 {
95  this->patchType() = ptf.patchType();
96 
97  // Evaluate refValue since not mapped
98  this->refValue() =
99  uniformInletValue_->value(this->db().time().timeOutputValue());
100 
101  this->refGrad() = Zero;
102  this->valueFraction() = 0.0;
103 
104  // Initialize the patch value to the refValue
105  fvPatchField<Type>::operator=(this->refValue());
106 
107  this->map(ptf, mapper);
108 }
109 
110 
111 template<class Type>
113 (
115 )
116 :
118  phiName_(ptf.phiName_),
119  uniformInletValue_(ptf.uniformInletValue_.clone())
120 {}
121 
122 
123 template<class Type>
125 (
128 )
129 :
130  mixedFvPatchField<Type>(ptf, iF),
131  phiName_(ptf.phiName_),
132  uniformInletValue_(ptf.uniformInletValue_.clone())
133 {}
134 
135 
136 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
137 
138 template<class Type>
140 {
141  if (this->updated())
142  {
143  return;
144  }
145 
146  // Update the uniform value as a function of time
147  const scalar t = this->db().time().timeOutputValue();
148  this->refValue() = uniformInletValue_->value(t);
149 
150  const Field<scalar>& phip =
151  this->patch().template lookupPatchField<surfaceScalarField, scalar>
152  (
153  phiName_
154  );
155 
156  this->valueFraction() = 1.0 - pos0(phip);
157 
159 }
160 
161 
162 template<class Type>
164 {
166  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
167  this->uniformInletValue_->writeData(os);
168  this->writeEntry("value", os);
169 }
170 
171 
172 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
173 
174 template<class Type>
176 (
177  const fvPatchFieldMapper& m
178 )
179 {
181 
182  // Override
183  this->refValue() =
184  uniformInletValue_->value(this->db().time().timeOutputValue());
185 }
186 
187 
188 template<class Type>
190 (
191  const fvPatchField<Type>& ptf,
192  const labelList& addr
193 )
194 {
196 
197  // Override
198  this->refValue() =
199  uniformInletValue_->value(this->db().time().timeOutputValue());
200 }
201 
202 
203 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
204 
205 template<class Type>
207 (
208  const fvPatchField<Type>& ptf
209 )
210 {
212  (
213  this->valueFraction()*this->refValue()
214  + (1 - this->valueFraction())*ptf
215  );
216 }
217 
218 
219 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
Foam::Ostream::writeEntryIfDifferent
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Definition: Ostream.H:244
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::uniformInletOutletFvPatchField::uniformInletOutletFvPatchField
uniformInletOutletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: uniformInletOutletFvPatchField.C:35
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::uniformInletOutletFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: uniformInletOutletFvPatchField.C:176
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::pos0
dimensionedScalar pos0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:188
Foam::uniformInletOutletFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: uniformInletOutletFvPatchField.C:163
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:86
Foam::uniformInletOutletFvPatchField::uniformInletValue_
autoPtr< Function1< Type > > uniformInletValue_
Value.
Definition: uniformInletOutletFvPatchField.H:113
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::mixedFvPatchField
This boundary condition provides a base class for 'mixed' type boundary conditions,...
Definition: mixedFvPatchField.H:123
Foam::uniformInletOutletFvPatchField
Variant of inletOutlet boundary condition with uniform inletValue.
Definition: uniformInletOutletFvPatchField.H:100
Foam::uniformInletOutletFvPatchField::phiName_
word phiName_
Name of flux field.
Definition: uniformInletOutletFvPatchField.H:110
Foam::uniformInletOutletFvPatchField::rmap
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: uniformInletOutletFvPatchField.C:190
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::fvPatchField::patchType
const word & patchType() const
Optional patch type.
Definition: fvPatchField.H:361
Foam::List< label >
uniformInletOutletFvPatchField.H
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:35
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::uniformInletOutletFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: uniformInletOutletFvPatchField.C:139
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54