Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
33template<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
46template<class Type>
47void Foam::fanFvPatchField<Type>::calcFanJump()
48{
49 if (this->cyclicPatch().owner())
50 {
51 this->jump_ = this->jumpTable_->value(this->db().time().value());
52 }
53}
54
55
56// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
57
58template<class Type>
60(
61 const fvPatch& p,
62 const DimensionedField<Type, volMesh>& iF
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
74template<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))
126 }
127}
128
129
130template<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
148template<class Type>
150(
152)
153:
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
163template<class Type>
165(
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
181template<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
196template<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// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
@ buffered
"buffered" : (MPI_Bsend, MPI_Recv)
Definition UPstream.H:82
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
const cyclicFvPatch & cyclicPatch() const
Return local reference cast into the cyclic patch.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
This boundary condition provides a jump condition, using the cyclic condition as a base.
operatingMode
Enumeration defining the operating modes.
@ NON_DIMENSIONAL
non-dimensional-based lookup
@ UNIFORM_VELOCITY
uniform velocity-based lookup
fanFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual void write(Ostream &os) const
Write.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual tmp< fvPatchField< Type > > clone() const
Return a clone.
static const Enum< operatingMode > operatingModeNames_
Names for the operating modes.
const objectRegistry & db() const
The associated objectRegistry.
bool updated() const noexcept
True if the boundary condition has already been updated.
A FieldMapper for finite-volume patch fields.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
This boundary condition provides a jump condition, using the cyclic condition as a base....
uniformJumpFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual void write(Ostream &os) const
Write.
autoPtr< Function1< Type > > jumpTable_
The "jump" table.
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
dictionary dict