Loading...
Searching...
No Matches
freestreamFvPatchField.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-2020 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)
40 inletOutletFvPatchField<Type>(p, iF),
41 freestreamBCPtr_(nullptr)
42{}
43
44
45template<class Type>
47(
48 const fvPatch& p,
50 const dictionary& dict
51)
52:
53 inletOutletFvPatchField<Type>(p, iF),
54 freestreamBCPtr_(nullptr)
55{
57
58 this->phiName_ = dict.getOrDefault<word>("phi", "phi");
59
60 if
61 (
63 (
64 "freestreamValue", dict, p.size(), IOobjectOption::LAZY_READ
65 )
66 )
67 {
68 if (!this->readValueEntry(dict))
69 {
71 }
72 }
73 else
74 {
75 // Freestream value provided by another patch
76 freestreamBCPtr_ =
77 fvPatchField<Type>::New(p, iF, dict.subDict("freestreamBC"));
78
79 // Force user to supply an initial value
80 // - we do not know if the supplied BC has all dependencies available
82 }
83}
84
85
86template<class Type>
88(
89 const freestreamFvPatchField<Type>& ptf,
90 const fvPatch& p,
91 const DimensionedField<Type, volMesh>& iF,
92 const fvPatchFieldMapper& mapper
93)
94:
95 inletOutletFvPatchField<Type>(ptf, p, iF, mapper),
96 freestreamBCPtr_(nullptr)
97{
98 if (ptf.freestreamBCPtr_)
99 {
100 freestreamBCPtr_ =
101 fvPatchField<Type>::New(ptf.freestreamBCPtr_(), p, iF, mapper);
102 }
103}
104
105
106template<class Type>
108(
110)
111:
112 inletOutletFvPatchField<Type>(ptf),
113 freestreamBCPtr_(nullptr)
114{
115 if (ptf.freestreamBCPtr_)
117 freestreamBCPtr_ = ptf.freestreamBCPtr_->clone();
118 }
119}
120
121
122template<class Type>
124(
127)
128:
129 inletOutletFvPatchField<Type>(ptf, iF),
130 freestreamBCPtr_(nullptr)
131{
132 if (ptf.freestreamBCPtr_)
133 {
134 freestreamBCPtr_ = ptf.freestreamBCPtr_->clone();
136}
137
138
139// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140
141template<class Type>
143{
145 if (freestreamBCPtr_)
147 freestreamBCPtr_->autoMap(m);
148 }
149}
150
151
152template<class Type>
154(
155 const fvPatchField<Type>& ptf,
156 const labelList& addr
157)
158{
160
161 const auto& fsptf = refCast<const freestreamFvPatchField<Type>>(ptf);
162
163 if (freestreamBCPtr_ && fsptf.freestreamBCPtr_)
165 freestreamBCPtr_->rmap(fsptf.freestreamBCPtr_(), addr);
166 }
167}
168
169
170template<class Type>
172{
173 if (this->updated())
174 {
175 return;
176 }
177
178 if (freestreamBCPtr_)
179 {
180 freestreamBCPtr_->evaluate();
181 freestreamValue() = freestreamBCPtr_();
183
185}
186
187
188template<class Type>
190{
192 os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_);
193
194 if (freestreamBCPtr_)
195 {
196 os.beginBlock("freestreamBC");
197 freestreamBCPtr_->write(os);
198 os.endBlock();
199 }
200 else
201 {
202 freestreamValue().writeEntry("freestreamValue", os);
203 }
205}
206
207
208// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
void assign(const entry &e, const label len)
Assign from a primitive dictionary entry with the following behaviour:
Definition Field.C:206
@ 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
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
This boundary condition provides a free-stream condition. It is a 'mixed' condition derived from the ...
const Field< Type > & freestreamValue() const
Same as refValue().
virtual void write(Ostream &) const
Write.
virtual void autoMap(const fvPatchFieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
freestreamFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual void rmap(const fvPatchField< Type > &ptf, const labelList &addr)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void readDict(const dictionary &dict)
Read dictionary entries.
bool updated() const noexcept
True if the boundary condition has already been updated.
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...
static tmp< fvPatchField< Type > > New(const word &patchFieldType, const fvPatch &, const DimensionedField< Type, volMesh > &)
Return a pointer to a new patchField created on freestore given.
virtual void write(Ostream &) const
Write.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
virtual void operator=(const UList< Type > &)
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 generic outflow condition, with specified inflow for the case of r...
inletOutletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
List< label > labelList
A List of labels.
Definition List.H:62
dictionary dict