inletOutletFaPatchField.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) 2016-2017 Wikki Ltd
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const faPatch& p,
37 )
38 :
40  phiName_("phi")
41 {
42  this->refValue() = pTraits<Type>::zero;
43  this->refGrad() = pTraits<Type>::zero;
44  this->valueFraction() = 0.0;
45 }
46 
47 
48 template<class Type>
50 (
52  const faPatch& p,
54  const faPatchFieldMapper& mapper
55 )
56 :
57  mixedFaPatchField<Type>(ptf, p, iF, mapper),
58  phiName_(ptf.phiName_)
59 {}
60 
61 
62 template<class Type>
64 (
65  const faPatch& p,
67  const dictionary& dict
68 )
69 :
71  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
72 {
73  this->refValue() = Field<Type>("inletValue", dict, p.size());
74 
75  if (dict.found("value"))
76  {
78  (
79  Field<Type>("value", dict, p.size())
80  );
81  }
82  else
83  {
84  faPatchField<Type>::operator=(this->refValue());
85  }
86 
87  this->refGrad() = pTraits<Type>::zero;
88  this->valueFraction() = 0.0;
89 }
90 
91 
92 template<class Type>
94 (
96 )
97 :
99  phiName_(ptf.phiName_)
100 {}
101 
102 
103 template<class Type>
105 (
108 )
109 :
110  mixedFaPatchField<Type>(ptf, iF),
111  phiName_(ptf.phiName_)
112 {}
113 
114 
115 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
116 
117 template<class Type>
119 {
120  if (this->updated())
121  {
122  return;
123  }
124 
125  const Field<scalar>& phip =
126  this->patch(). template lookupPatchField<edgeScalarField, scalar>
127  (
128  phiName_
129  );
130 
131  this->valueFraction() = 1.0 - pos(phip);
132 
134 }
135 
136 
137 template<class Type>
139 {
141  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
142  this->refValue().writeEntry("inletValue", os);
143  this->writeEntry("value", os);
144 }
145 
146 
147 // ************************************************************************* //
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:231
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::faPatchField
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:50
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::faPatchFieldMapper
Definition: faPatchFieldMapper.H:44
Foam::inletOutletFaPatchField::write
virtual void write(Ostream &) const
Write.
Definition: inletOutletFaPatchField.C:138
Foam::inletOutletFaPatchField::phiName_
word phiName_
Definition: inletOutletFaPatchField.H:64
Foam::Field
Generic templated field type.
Definition: Field.H:63
inletOutletFaPatchField.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::mixedFaPatchField
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
Definition: mixedFaPatchField.H:54
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::inletOutletFaPatchField::inletOutletFaPatchField
inletOutletFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
Definition: inletOutletFaPatchField.C:34
Foam::inletOutletFaPatchField
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
Definition: inletOutletFaPatchField.H:55
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::inletOutletFaPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: inletOutletFaPatchField.C:118
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:52
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::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::faPatch
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:65
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:177