Loading...
Searching...
No Matches
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 needValue
74)
75:
76 jumpCyclicFvPatchField<Type>(p, iF, dict, false), // needValue = false
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 (needValue)
86 {
87 jump_.assign("jump", dict, p.size(), IOobjectOption::MUST_READ);
88 }
89
90 jump0_.assign("jump0", dict, p.size(), IOobjectOption::LAZY_READ);
91 }
92
93 if (needValue)
94 {
95 if (!this->readValueEntry(dict))
96 {
98 }
99 }
100}
101
102
103template<class Type>
105(
107)
108:
109 jumpCyclicFvPatchField<Type>(ptf),
110 jump_(ptf.jump_),
111 jump0_(ptf.jump0_),
112 minJump_(ptf.minJump_),
113 relaxFactor_(ptf.relaxFactor_),
114 timeIndex_(ptf.timeIndex_)
115{}
116
117
118template<class Type>
120(
123)
124:
125 jumpCyclicFvPatchField<Type>(ptf, iF),
126 jump_(ptf.jump_),
127 jump0_(ptf.jump0_),
128 minJump_(ptf.minJump_),
129 relaxFactor_(ptf.relaxFactor_),
130 timeIndex_(ptf.timeIndex_)
131{}
132
133
134// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
135
136template<class Type>
138{
139 if (this->cyclicPatch().owner())
141 jump_ = max(jump, minJump_);
142 }
143}
144
145
146template<class Type>
148{
149 if (this->cyclicPatch().owner())
151 jump_ = max(jump, minJump_);
152 }
154
155
156template<class Type>
158{
159 if (this->cyclicPatch().owner())
160 {
161 return jump_;
162 }
163 else
164 {
166 (
168 ).jump();
169 }
170}
171
172
173template<class Type>
175{
176 if (this->cyclicPatch().owner())
177 {
178 return jump0_;
179 }
180 else
181 {
183 (
185 ).jump0();
186 }
187}
188
189
190template<class Type>
192{
193 return relaxFactor_;
194}
195
196
197template<class Type>
199{
200 if (!this->cyclicPatch().owner() || relaxFactor_ < 0)
201 {
202 return;
203 }
204
205 jump_ = lerp(jump0_, jump_, relaxFactor_);
206
207 if (timeIndex_ != this->db().time().timeIndex())
208 {
209 jump0_ = jump_;
211 timeIndex_ = this->db().time().timeIndex();
212 }
213}
214
215
216template<class Type>
218(
219 const fvPatchFieldMapper& m
220)
221{
223 jump_.autoMap(m);
224 jump0_.autoMap(m);
225}
226
228template<class Type>
230(
231 const fvPatchField<Type>& ptf,
232 const labelList& addr
233)
234{
236
238 jump_.rmap(fjptf.jump_, addr);
239 jump0_.rmap(fjptf.jump0_, addr);
240}
241
243template<class Type>
245{
248 // Write patchType if not done already by fvPatchField
249 if (this->patchType().empty())
250 {
251 os.writeEntry("patchType", this->interfaceFieldType());
253
254 if (this->cyclicPatch().owner())
255 {
256 jump_.writeEntry("jump", os);
257
258 if (relaxFactor_ > 0)
259 {
260 os.writeEntry("relax", relaxFactor_);
261 jump0_.writeEntry("jump0", os);
262 }
263 }
264
265 if (minJump_ != pTraits<Type>::min)
266 {
267 os.writeEntry("minJump", minJump_);
269
271}
272
273
274// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
@ MUST_READ
Reading required.
@ LAZY_READ
Reading is optional [identical to READ_IF_PRESENT].
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
bool empty() const noexcept
Definition UList.H:701
void size(const label n)
Definition UList.H:118
@ buffered
"buffered" : (MPI_Bsend, MPI_Recv)
Definition UPstream.H:82
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
const cyclicFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
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.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void write(Ostream &) const
Write.
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.
fixedJumpFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual scalar relaxFactor() const
Return the under-relaxation factor.
const objectRegistry & db() const
The associated objectRegistry.
const word & patchType() const noexcept
The optional patch type.
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...
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void write(Ostream &) const
Write.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
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 base class for coupled-cyclic conditions with a specified 'jump' (...
virtual const word & interfaceFieldType() const
jumpCyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
A class for managing temporary objects.
Definition tmp.H:75
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
List< label > labelList
A List of labels.
Definition List.H:62
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:26
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
label timeIndex
dictionary dict