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 :
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 (dict.found("value"))
91  {
93  (
94  Field<Type>("value", dict, p.size())
95  );
96  }
97  else
98  {
99  this->evaluate(Pstream::commsTypes::blocking);
100  }
101 }
102 
103 
104 template<class Type>
106 (
107  const fanFvPatchField<Type>& rhs,
108  const fvPatch& p,
110  const fvPatchFieldMapper& mapper
111 )
112 :
113  uniformJumpFvPatchField<Type>(rhs, p, iF, mapper),
114  phiName_(rhs.phiName_),
115  rhoName_(rhs.rhoName_),
116  uniformJump_(rhs.uniformJump_),
117  nonDimensional_(rhs.nonDimensional_),
118  rpm_(rhs.rpm_.clone()),
119  dm_(rhs.dm_.clone())
120 {}
121 
122 
123 template<class Type>
125 (
126  const fanFvPatchField<Type>& rhs
127 )
128 :
130  phiName_(rhs.phiName_),
131  rhoName_(rhs.rhoName_),
132  uniformJump_(rhs.uniformJump_),
133  nonDimensional_(rhs.nonDimensional_),
134  rpm_(rhs.rpm_.clone()),
135  dm_(rhs.dm_.clone())
136 {}
137 
138 
139 template<class Type>
141 (
142  const fanFvPatchField<Type>& rhs,
144 )
145 :
147  phiName_(rhs.phiName_),
148  rhoName_(rhs.rhoName_),
149  uniformJump_(rhs.uniformJump_),
150  nonDimensional_(rhs.nonDimensional_),
151  rpm_(rhs.rpm_.clone()),
152  dm_(rhs.dm_.clone())
153 {}
154 
155 
156 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
157 
158 template<class Type>
160 {
161  if (this->updated())
162  {
163  return;
164  }
165 
166  calcFanJump();
167 
168  // Call fixedJump variant - uniformJump will overwrite the jump value
170 }
171 
172 
173 template<class Type>
175 {
177  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
178  os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
179 
180  if (uniformJump_)
181  {
182  os.writeEntry("uniformJump", "true");
183  }
184 
185  if (nonDimensional_)
186  {
187  os.writeEntry("nonDimensional", "true");
188  rpm_->writeData(os);
189  dm_->writeData(os);
190  }
191 }
192 
193 
194 // ************************************************************************* //
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::uniformJumpFvPatchField
This boundary condition provides a jump condition, using the cyclic condition as a base....
Definition: uniformJumpFvPatchField.H:102
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: propellerInfo.H:291
Foam::fanFvPatchField::write
virtual void write(Ostream &os) const
Write.
Definition: fanFvPatchField.C:174
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::fixedJumpFvPatchField
This boundary condition provides a jump condition, using the cyclic condition as a base.
Definition: fixedJumpFvPatchField.H:111
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)
fanFvPatchField.H
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::fanFvPatchField
This boundary condition provides a jump condition, using the cyclic condition as a base.
Definition: fanFvPatchField.H:174
Foam::fanFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fanFvPatchField.C:159
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::fanFvPatchField::fanFvPatchField
fanFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: fanFvPatchField.C:47
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::stringOps::evaluate
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
String evaluation with specified (positive, non-zero) field width.
Definition: stringOpsEvaluate.C:37