Loading...
Searching...
No Matches
exprValuePointPatchField.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) 2010-2018 Bernhard Gschaider
9 Copyright (C) 2019-2022 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
31#include "facePointPatch.H"
32#include "dictionaryContent.H"
33
34// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35
36template<class Type>
38(
39 const pointPatch& p,
41)
42:
43 parent_bctype(p, iF),
45 dict_(),
47 (
48 fvPatch::lookupPatch
49 (
51 )
52 )
53{}
54
55
56template<class Type>
58(
60 const pointPatch& p,
62 const pointPatchFieldMapper& mapper
63)
64:
65 parent_bctype(rhs, p, iF, mapper),
66 expressions::patchExprFieldBase(rhs),
67 dict_(rhs.dict_), // Deep copy
68 driver_
69 (
70 fvPatch::lookupPatch
71 (
72 refCast<const facePointPatch>(this->patch()).patch()
73 ),
75 dict_
76 )
77{}
78
79
80template<class Type>
82(
83 const pointPatch& p,
85 const dictionary& dict
86)
87:
88 parent_bctype(p, iF), // bypass dictionary constructor
89 expressions::patchExprFieldBase
90 (
91 dict,
92 expressions::patchExprFieldBase::expectedTypes::VALUE_TYPE,
93 true // pointValue
94 ),
95 dict_
96 (
97 // Copy dictionary without "heavy" data chunks
98 dictionaryContent::copyDict
99 (
100 dict,
101 wordList(), // allow
102 wordList // deny
103 ({
104 "type", // redundant
105 "value"
106 })
107 )
108 ),
109 driver_
110 (
112 (
113 refCast<const facePointPatch>(this->patch()).patch()
114 ),
115 dict_
116 )
117{
118 //FUTURE?
119 //DeprecatedInFunction(2212)
120 // << "Use uniformFixedValue with an expression Function1 instead." << nl
121 // << " This boundary condition will be removed in the future" << endl;
122
123 // Require valueExpr
124 if (this->valueExpr_.empty())
125 {
127 << "The valueExpr was not defined!" << nl
128 << exit(FatalIOError);
129 }
130
131 driver_.readDict(dict_);
132
133 if (!this->readValueEntry(dict))
134 {
135 // Ensure field has reasonable initial values
136 this->extrapolateInternal();
137 }
138
139 if (this->evalOnConstruct_)
140 {
141 // For potentialFoam or other solvers that don't evaluate
142 this->evaluate();
143 }
144}
145
146
147template<class Type>
149(
150 const exprValuePointPatchField<Type>& rhs,
151 const DimensionedField<Type, pointMesh>& iF
152)
153:
154 parent_bctype(rhs, iF),
155 expressions::patchExprFieldBase(rhs),
156 dict_(rhs.dict_), // Deep copy
157 driver_
158 (
159 fvPatch::lookupPatch
160 (
161 refCast<const facePointPatch>(this->patch()).patch()
162 ),
164 dict_
165 )
166{}
167
168
169template<class Type>
171(
173)
174:
175 parent_bctype(rhs),
176 expressions::patchExprFieldBase(rhs),
177 dict_(rhs.dict_), // Deep copy
178 driver_
179 (
180 fvPatch::lookupPatch
181 (
182 refCast<const facePointPatch>(this->patch()).patch()
183 ),
184 rhs.driver_,
185 dict_
187{}
188
189
190// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
191
192template<class Type>
194{
195 if (this->updated())
196 {
197 return;
198 }
199
200 if (debug)
201 {
203 << "Value: " << this->valueExpr_ << nl
204 << "Variables: ";
205 driver_.writeVariableStrings(Info) << nl;
206 Info<< "... updating" << endl;
207 }
208
209
210 // Expression evaluation
211 {
212 bool evalValue = (!this->valueExpr_.empty() && this->valueExpr_ != "0");
213
214
215 driver_.clearVariables();
216
217 if (evalValue)
218 {
220 (
221 driver_.evaluate<Type>(this->valueExpr_, true)
222 );
223 }
224 else
225 {
226 (*this) == Zero;
227 }
229
230 this->parent_bctype::updateCoeffs();
231}
232
233
234template<class Type>
236{
237 this->parent_bctype::write(os);
239
240 this->writeValueEntry(os);
241
242 driver_.writeCommon(os, this->debug_ || debug);
243}
244
245
246// ************************************************************************* //
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
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A wrapper for dictionary content, without operators that could affect inheritance patterns.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A fixed value point boundary condition with expressions.
dictionary dict_
Dictionary contents for the boundary condition.
expressions::patchExpr::parseDriver driver_
The expression driver.
exprValuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
virtual void write(Ostream &os) const
Write.
virtual void updateCoeffs()
Update the patch field.
void write(Ostream &os) const
Write.
expectedTypes
Enumeration of expected expressions.
A pointPatch based on a polyPatch.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
static const fvPatch & lookupPatch(const polyPatch &p)
Lookup the polyPatch index on corresponding fvMesh.
Definition fvPatch.C:42
const pointPatch & patch() const noexcept
Return the patch.
bool updated() const noexcept
True if the boundary condition has already been updated.
Foam::pointPatchFieldMapper.
Basic pointPatch represents a set of points from the mesh.
Definition pointPatch.H:67
virtual void write(Ostream &) const
Write.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
volScalarField & p
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
OBJstream os(runTime.globalPath()/outputName)
#define InfoInFunction
Report an information message using Foam::Info.
Namespace for handling debugging switches.
Definition debug.C:45
A namespace for expression-related classes/traits etc.
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.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
List< word > wordList
List of word.
Definition fileName.H:60
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict