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-2024 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 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 template<class Type>
36 ({
37  { operatingMode::VELOCITY, "velocity" },
38  { operatingMode::UNIFORM_VELOCITY, "uniformVelocity" },
39  { operatingMode::VOL_FLOW_RATE, "volumeFlowRate" },
40  { operatingMode::NON_DIMENSIONAL, "nonDimensional" },
41 });
42 
43 
44 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
45 
46 template<class Type>
48 {
49  if (this->cyclicPatch().owner())
50  {
51  this->jump_ = this->jumpTable_->value(this->db().time().value());
52  }
53 }
54 
55 
56 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
57 
58 template<class Type>
60 (
61  const fvPatch& p,
63 )
64 :
65  uniformJumpFvPatchField<Type>(p, iF),
66  operatingMode_(operatingMode::VELOCITY),
67  phiName_("phi"),
68  rhoName_("rho"),
69  rpm_(nullptr),
70  dm_(nullptr)
71 {}
72 
73 
74 template<class Type>
76 (
77  const fvPatch& p,
79  const dictionary& dict
80 )
81 :
82  uniformJumpFvPatchField<Type>(p, iF, dict, false), // needValue = false
83  operatingMode_
84  (
85  operatingModeNames_.getOrDefault("mode", dict, operatingMode::VELOCITY)
86  ),
87  phiName_(dict.getOrDefault<word>("phi", "phi")),
88  rhoName_(dict.getOrDefault<word>("rho", "rho")),
89  rpm_(nullptr),
90  dm_(nullptr)
91 {
92  // Backwards compatibility
93  if (operatingMode_ == operatingMode::VELOCITY)
94  {
95  bool nonDimCompat = dict.getOrDefault("nonDimensional", false);
96  if (nonDimCompat)
97  {
98  // Warn?
99  operatingMode_ = operatingMode::NON_DIMENSIONAL;
100  }
101 
102  bool uniformCompat = dict.getOrDefault("uniformJump", false);
103  if (uniformCompat)
104  {
105  // Warn?
106  operatingMode_ = operatingMode::UNIFORM_VELOCITY;
107  }
108  }
109 
110 
111  // Note that we've not read jumpTable_ etc
112  if (operatingMode_ == operatingMode::NON_DIMENSIONAL)
113  {
114  rpm_.reset(Function1<scalar>::New("rpm", dict, &this->db()));
115  dm_.reset(Function1<scalar>::New("dm", dict, &this->db()));
116  }
117 
118  if (this->cyclicPatch().owner())
119  {
120  this->jumpTable_ = Function1<Type>::New("jumpTable", dict, &this->db());
121  }
122 
123  if (!this->readValueEntry(dict))
124  {
126  }
127 }
128 
129 
130 template<class Type>
132 (
133  const fanFvPatchField<Type>& rhs,
134  const fvPatch& p,
135  const DimensionedField<Type, volMesh>& iF,
136  const fvPatchFieldMapper& mapper
137 )
138 :
139  uniformJumpFvPatchField<Type>(rhs, p, iF, mapper),
140  operatingMode_(rhs.operatingMode_),
141  phiName_(rhs.phiName_),
142  rhoName_(rhs.rhoName_),
143  rpm_(rhs.rpm_.clone()),
144  dm_(rhs.dm_.clone())
145 {}
146 
147 
148 template<class Type>
150 (
151  const fanFvPatchField<Type>& rhs
152 )
153 :
154  uniformJumpFvPatchField<Type>(rhs),
155  operatingMode_(rhs.operatingMode_),
156  phiName_(rhs.phiName_),
157  rhoName_(rhs.rhoName_),
158  rpm_(rhs.rpm_.clone()),
159  dm_(rhs.dm_.clone())
160 {}
161 
162 
163 template<class Type>
165 (
166  const fanFvPatchField<Type>& rhs,
168 )
169 :
170  uniformJumpFvPatchField<Type>(rhs, iF),
171  operatingMode_(rhs.operatingMode_),
172  phiName_(rhs.phiName_),
173  rhoName_(rhs.rhoName_),
174  rpm_(rhs.rpm_.clone()),
175  dm_(rhs.dm_.clone())
176 {}
177 
178 
179 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
180 
181 template<class Type>
183 {
184  if (this->updated())
185  {
186  return;
187  }
188 
189  calcFanJump();
191  // Call fixedJump variant - uniformJump will overwrite the jump value
193 }
194 
195 
196 template<class Type>
198 {
200  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
201  os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
202 
203  os.writeEntry("mode", operatingModeNames_[operatingMode_]);
204 
205  if (operatingMode_ == operatingMode::NON_DIMENSIONAL)
206  {
207  rpm_->writeData(os);
208  dm_->writeData(os);
209  }
210 }
211 
212 
213 // ************************************************************************* //
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.
dictionary dict
const objectRegistry & db() const
The associated objectRegistry.
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.
static const Enum< operatingMode > operatingModeNames_
Names for the operating modes.
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.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: error.H:64
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...
volScalarField & p
"buffered" : (MPI_Bsend, MPI_Recv)
This boundary condition provides a jump condition, using the cyclic condition as a base...