fanFvPatchField.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-2015 OpenFOAM Foundation
9  Copyright (C) 2017-2021 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 
29 #include "fanFvPatchField.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 template<class Type>
35 {
36  if (this->cyclicPatch().owner())
37  {
38  this->jump_ = this->jumpTable_->value(this->db().time().value());
39  }
40 }
41 
42 
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 
45 template<class Type>
47 (
48  const fvPatch& p,
50 )
51 :
52  uniformJumpFvPatchField<Type>(p, iF),
53  phiName_("phi"),
54  rhoName_("rho"),
55  uniformJump_(false),
56  nonDimensional_(false),
57  rpm_(nullptr),
58  dm_(nullptr)
59 {}
60 
61 
62 template<class Type>
64 (
65  const fvPatch& p,
67  const dictionary& dict
68 )
69 :
70  uniformJumpFvPatchField<Type>(p, iF, dict, false), // Pass no valueRequired
71  phiName_(dict.getOrDefault<word>("phi", "phi")),
72  rhoName_(dict.getOrDefault<word>("rho", "rho")),
73  uniformJump_(dict.getOrDefault("uniformJump", false)),
74  nonDimensional_(dict.getOrDefault("nonDimensional", false)),
75  rpm_(nullptr),
76  dm_(nullptr)
77 {
78  // Note that we've not read jumpTable_ etc
79  if (nonDimensional_)
80  {
81  rpm_.reset(Function1<scalar>::New("rpm", dict, &this->db()));
82  dm_.reset(Function1<scalar>::New("dm", dict, &this->db()));
83  }
84 
85  if (this->cyclicPatch().owner())
86  {
87  this->jumpTable_ = Function1<Type>::New("jumpTable", dict, &this->db());
88  }
89 
90  if (!this->readValueEntry(dict))
91  {
93  }
94 }
95 
96 
97 template<class Type>
99 (
100  const fanFvPatchField<Type>& rhs,
101  const fvPatch& p,
102  const DimensionedField<Type, volMesh>& iF,
103  const fvPatchFieldMapper& mapper
104 )
105 :
106  uniformJumpFvPatchField<Type>(rhs, p, iF, mapper),
107  phiName_(rhs.phiName_),
108  rhoName_(rhs.rhoName_),
109  uniformJump_(rhs.uniformJump_),
110  nonDimensional_(rhs.nonDimensional_),
111  rpm_(rhs.rpm_.clone()),
112  dm_(rhs.dm_.clone())
113 {}
114 
115 
116 template<class Type>
118 (
119  const fanFvPatchField<Type>& rhs
120 )
121 :
122  uniformJumpFvPatchField<Type>(rhs),
123  phiName_(rhs.phiName_),
124  rhoName_(rhs.rhoName_),
125  uniformJump_(rhs.uniformJump_),
126  nonDimensional_(rhs.nonDimensional_),
127  rpm_(rhs.rpm_.clone()),
128  dm_(rhs.dm_.clone())
129 {}
130 
131 
132 template<class Type>
134 (
135  const fanFvPatchField<Type>& rhs,
137 )
138 :
139  uniformJumpFvPatchField<Type>(rhs, iF),
140  phiName_(rhs.phiName_),
141  rhoName_(rhs.rhoName_),
142  uniformJump_(rhs.uniformJump_),
143  nonDimensional_(rhs.nonDimensional_),
144  rpm_(rhs.rpm_.clone()),
145  dm_(rhs.dm_.clone())
146 {}
147 
148 
149 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
150 
151 template<class Type>
153 {
154  if (this->updated())
155  {
156  return;
157  }
158 
159  calcFanJump();
161  // Call fixedJump variant - uniformJump will overwrite the jump value
163 }
164 
165 
166 template<class Type>
168 {
170  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
171  os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
172 
173  if (uniformJump_)
174  {
175  os.writeEntry("uniformJump", "true");
176  }
177 
178  if (nonDimensional_)
179  {
180  os.writeEntry("nonDimensional", "true");
181  rpm_->writeData(os);
182  dm_->writeData(os);
183  }
184 }
185 
186 
187 // ************************************************************************* //
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
Definition: fvPatchField.C:32
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
dictionary dict
const objectRegistry & db() const
The associated objectRegistry.
"blocking" : (MPI_Bsend, MPI_Recv)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:321
autoPtr< Function1< Type > > jumpTable_
The "jump" table.
This boundary condition provides a jump condition, using the cyclic condition as a base...
virtual void write(Ostream &os) const
Write.
const cyclicFvPatch & cyclicPatch() const
Return local reference cast into the cyclic patch.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void write(Ostream &os) const
Write.
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
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:336
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
fanFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:309
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
volScalarField & p
This boundary condition provides a jump condition, using the cyclic condition as a base...