inletOutletFvPatchField.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) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2017-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 (
53  const fvPatch& p,
55  const fvPatchFieldMapper& mapper
56 )
57 :
58  mixedFvPatchField<Type>(ptf, p, iF, mapper),
59  phiName_(ptf.phiName_)
60 {}
61 
62 
63 template<class Type>
65 (
66  const fvPatch& p,
68  const dictionary& dict
69 )
70 :
72  phiName_(dict.getOrDefault<word>("phi", "phi"))
73 {
74  this->patchType() = dict.getOrDefault<word>("patchType", word::null);
75 
76  this->refValue() = Field<Type>("inletValue", dict, p.size());
77 
78  if (dict.found("value"))
79  {
81  (
82  Field<Type>("value", dict, p.size())
83  );
84  }
85  else
86  {
87  fvPatchField<Type>::operator=(this->refValue());
88  }
89 
90  this->refGrad() = Zero;
91  this->valueFraction() = 0.0;
92 }
93 
94 
95 template<class Type>
97 (
99 )
100 :
102  phiName_(ptf.phiName_)
103 {}
104 
105 
106 template<class Type>
108 (
111 )
112 :
113  mixedFvPatchField<Type>(ptf, iF),
114  phiName_(ptf.phiName_)
115 {}
116 
117 
118 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119 
120 template<class Type>
122 {
123  if (this->updated())
124  {
125  return;
126  }
127 
128  const Field<scalar>& phip =
129  this->patch().template lookupPatchField<surfaceScalarField, scalar>
130  (
131  phiName_
132  );
133 
134  this->valueFraction() = 1.0 - pos0(phip);
135 
137 }
138 
139 
140 template<class Type>
142 {
144  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
145  this->refValue().writeEntry("inletValue", os);
146  this->writeEntry("value", os);
147 }
148 
149 
150 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
151 
152 template<class Type>
154 (
155  const fvPatchField<Type>& ptf
156 )
157 {
159  (
160  this->valueFraction()*this->refValue()
161  + (1 - this->valueFraction())*ptf
162  );
163 }
164 
165 
166 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
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::inletOutletFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: inletOutletFvPatchField.C:141
Foam::inletOutletFvPatchField::phiName_
word phiName_
Name of flux field.
Definition: inletOutletFvPatchField.H:111
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::inletOutletFvPatchField
This boundary condition provides a generic outflow condition, with specified inflow for the case of r...
Definition: inletOutletFvPatchField.H:101
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:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::mixedFvPatchField
This boundary condition provides a base class for 'mixed' type boundary conditions,...
Definition: mixedFvPatchField.H:123
Foam::inletOutletFvPatchField::inletOutletFvPatchField
inletOutletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: inletOutletFvPatchField.C:35
Foam::inletOutletFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: inletOutletFvPatchField.C:121
inletOutletFvPatchField.H
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
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:36
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::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54