fixedJumpFvPatchField.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-2017 OpenFOAM Foundation
9 Copyright (C) 2021 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
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class Type>
35(
36 const fvPatch& p,
38)
39:
40 jumpCyclicFvPatchField<Type>(p, iF),
41 jump_(this->size(), Zero),
42 jump0_(this->size(), Zero),
43 minJump_(pTraits<Type>::min),
44 relaxFactor_(-1),
45 timeIndex_(-1)
46{}
47
48
49template<class Type>
51(
53 const fvPatch& p,
55 const fvPatchFieldMapper& mapper
56)
57:
58 jumpCyclicFvPatchField<Type>(ptf, p, iF, mapper),
59 jump_(ptf.jump_, mapper),
60 jump0_(ptf.jump0_, mapper),
61 minJump_(ptf.minJump_),
62 relaxFactor_(ptf.relaxFactor_),
63 timeIndex_(ptf.timeIndex_)
64{}
65
66
67template<class Type>
69(
70 const fvPatch& p,
72 const dictionary& dict,
73 const bool valueRequired
74)
75:
76 jumpCyclicFvPatchField<Type>(p, iF, dict, false), // Pass no valueRequired
77 jump_(p.size(), Zero),
78 jump0_(p.size(), Zero),
79 minJump_(dict.getOrDefault<Type>("minJump", pTraits<Type>::min)),
80 relaxFactor_(dict.getOrDefault<scalar>("relax", -1)),
81 timeIndex_(this->db().time().timeIndex())
82{
83 if (this->cyclicPatch().owner())
84 {
85 if (valueRequired)
86 {
87 jump_ = Field<Type>("jump", dict, p.size());
88 }
89
90 if (dict.found("jump0"))
91 {
92 jump0_ = Field<Type>("jump0", dict, p.size());
93 }
94 }
95
96 if (valueRequired)
97 {
98 if (dict.found("value"))
99 {
101 (
102 Field<Type>("value", dict, p.size())
103 );
104 }
105 else
106 {
108 }
109 }
110}
111
112
113template<class Type>
115(
117)
118:
119 jumpCyclicFvPatchField<Type>(ptf),
120 jump_(ptf.jump_),
121 jump0_(ptf.jump0_),
122 minJump_(ptf.minJump_),
123 relaxFactor_(ptf.relaxFactor_),
124 timeIndex_(ptf.timeIndex_)
125{}
126
127
128template<class Type>
130(
133)
134:
135 jumpCyclicFvPatchField<Type>(ptf, iF),
136 jump_(ptf.jump_),
137 jump0_(ptf.jump0_),
138 minJump_(ptf.minJump_),
139 relaxFactor_(ptf.relaxFactor_),
140 timeIndex_(ptf.timeIndex_)
141{}
142
144// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145
146template<class Type>
148{
149 if (this->cyclicPatch().owner())
151 jump_ = max(jump, minJump_);
152 }
153}
154
155
156template<class Type>
158{
159 if (this->cyclicPatch().owner())
161 jump_ = max(jump, minJump_);
162 }
163}
164
165
166template<class Type>
168{
169 if (this->cyclicPatch().owner())
170 {
171 return jump_;
172 }
173 else
174 {
175 return refCast<const fixedJumpFvPatchField<Type>>
176 (
177 this->neighbourPatchField()
178 ).jump();
179 }
180}
181
182
183template<class Type>
185{
186 if (this->cyclicPatch().owner())
187 {
188 return jump0_;
189 }
190 else
191 {
192 return refCast<const fixedJumpFvPatchField<Type>>
193 (
194 this->neighbourPatchField()
195 ).jump0();
196 }
197}
198
199
200template<class Type>
202{
203 return relaxFactor_;
204}
205
206
207template<class Type>
209{
210 if (!this->cyclicPatch().owner() || relaxFactor_ < 0)
212 return;
213 }
215 jump_ = relaxFactor_*jump_ + (1 - relaxFactor_)*jump0_;
216
217 if (timeIndex_ != this->db().time().timeIndex())
218 {
219 jump0_ = jump_;
221 timeIndex_ = this->db().time().timeIndex();
222 }
224
225
226template<class Type>
228(
230)
231{
233 jump_.autoMap(m);
234 jump0_.autoMap(m);
236
237
238template<class Type>
240(
241 const fvPatchField<Type>& ptf,
242 const labelList& addr
244{
246
247 const auto& fjptf = refCast<const fixedJumpFvPatchField<Type>>(ptf);
248 jump_.rmap(fjptf.jump_, addr);
249 jump0_.rmap(fjptf.jump0_, addr);
250}
251
252
253template<class Type>
255{
257
258 // Write patchType if not done already by fvPatchField
259 if (this->patchType().empty())
260 {
261 os.writeEntry("patchType", this->interfaceFieldType());
262 }
263
264 if (this->cyclicPatch().owner())
265 {
266 jump_.writeEntry("jump", os);
267
268 if (relaxFactor_ > 0)
269 {
270 os.writeEntry("relax", relaxFactor_);
271 jump0_.writeEntry("jump0", os);
272 }
273 }
274
275 if (minJump_ != pTraits<Type>::min)
276 {
277 os.writeEntry("minJump", minJump_);
278 }
279
280 this->writeEntry("value", os);
281}
282
283
284// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type.
Definition: Field.H:82
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:239
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
void rmap(const atmBoundaryLayer &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
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:126
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionaryI.H:87
This boundary condition provides a jump condition, using the cyclic condition as a base.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void relax()
Return the relaxed "jump" across the patch.
virtual tmp< Field< Type > > jump0() const
Return the old time "jump" across the patch.
virtual tmp< Field< Type > > jump() const
Return the "jump" across the patch.
virtual void setJump(const Field< Type > &jump)
Set the jump field.
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual scalar relaxFactor() const
Return the under-relaxation factor.
virtual bool write()
Write the output fields.
A FieldMapper for finite-volume patch fields.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:82
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
This boundary condition provides a base class for coupled-cyclic conditions with a specified 'jump' (...
A traits class, which is primarily used for primitives.
Definition: pTraits.H:59
A class for managing temporary objects.
Definition: tmp.H:65
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
label timeIndex
Definition: getTimeIndex.H:30
dictionary dict