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 (dict.found("value"))
91  {
93  (
94  Field<Type>("value", dict, p.size())
95  );
96  }
97  else
98  {
100  }
101 }
102 
103 
104 template<class Type>
106 (
107  const fanFvPatchField<Type>& rhs,
108  const fvPatch& p,
109  const DimensionedField<Type, volMesh>& iF,
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 :
129  uniformJumpFvPatchField<Type>(rhs),
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 :
146  uniformJumpFvPatchField<Type>(rhs, iF),
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:47
Foam::Ostream::writeEntryIfDifferent
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Definition: Ostream.H:244
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::dictionary::found
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryI.H:80
Foam::fvPatchField< Type >::operator
friend Ostream & operator(Ostream &, const fvPatchField< Type > &)
Foam::uniformJumpFvPatchField
This boundary condition provides a jump condition, using the cyclic condition as a base....
Definition: uniformJumpFvPatchField.H:98
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: propellerInfo.H:287
Foam::fanFvPatchField::write
virtual void write(Ostream &os) const
Definition: fanFvPatchField.C:167
Foam::uniformJumpFvPatchField::jumpTable_
autoPtr< Function1< Type > > jumpTable_
Definition: uniformJumpFvPatchField.H:108
Foam::Field< Type >
Foam::fixedJumpFvPatchField
This boundary condition provides a jump condition, using the cyclic condition as a base.
Definition: fixedJumpFvPatchField.H:107
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::cyclicFvPatchField::cyclicPatch
const cyclicFvPatch & cyclicPatch() const
Definition: cyclicFvPatchField.H:163
Foam::coupledFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType)
Definition: coupledFvPatchField.C:126
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:119
os
OBJstream os(runTime.globalPath()/outputName)
fanFvPatchField.H
Foam::uniformJumpFvPatchField::write
virtual void write(Ostream &os) const
Definition: uniformJumpFvPatchField.C:129
Foam::fvPatchField< Type >::updateCoeffs
virtual void updateCoeffs()
Definition: fvPatchField.C:314
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Definition: DimensionedFieldReuseFunctions.H:100
Foam::fanFvPatchField
This boundary condition provides a jump condition, using the cyclic condition as a base.
Definition: fanFvPatchField.H:170
Foam::fvPatchField< Type >::db
const objectRegistry & db() const
Definition: fvPatchField.C:199
Foam::fanFvPatchField::updateCoeffs
virtual void updateCoeffs()
Definition: fanFvPatchField.C:152
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Definition: Ostream.H:232
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Definition: foamVtkOutputTemplates.C:29
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:41
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::fanFvPatchField::fanFvPatchField
fanFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Definition: fanFvPatchField.C:40
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:50
Foam::UPstream::commsTypes::blocking
@ blocking
Foam::stringOps::evaluate
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
Definition: stringOpsEvaluate.C:30