PatchFunction1Expression.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) 2020-2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
29#include "fvPatch.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class Type>
35(
36 const polyPatch& pp,
37 const word& redirectType,
38 const word& entryName,
39 const dictionary& dict,
40 const bool faceValues
41)
42:
43 PatchFunction1<Type>(pp, entryName, dict, faceValues),
44 dict_(dict), // Deep copy
45 valueExpr_(),
46 driver_(fvPatch::lookupPatch(this->patch()), dict_)
47{
48 if (dict.getOrDefault("debug", false))
49 {
50 debug |= 1;
51 }
52
53 valueExpr_.readEntry("expression", dict_);
54
55 // Basic sanity
56 if (valueExpr_.empty())
57 {
59 << "The expression was not defined!" << nl
61 }
62
63 driver_.readDict(dict_);
64}
65
66
67template<class Type>
69(
70 const PatchExprField<Type>& rhs
71)
72:
73 PatchExprField<Type>(rhs, rhs.patch())
74{}
75
76
77template<class Type>
79(
80 const PatchExprField<Type>& rhs,
81 const polyPatch& pp
82)
83:
84 PatchFunction1<Type>(rhs, pp),
85 dict_(rhs.dict_), // Deep copy
86 valueExpr_(rhs.valueExpr_),
87 driver_(fvPatch::lookupPatch(this->patch()), rhs.driver_, dict_)
88{}
89
90
91// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92
93template<class Type>
96(
97 const scalar x
98) const
99{
100 // Expression evaluation
101 driver_.clearVariables();
102
103 driver_.setArgument(x);
104
105 tmp<Field<Type>> tresult(driver_.evaluate<Type>(this->valueExpr_));
106
108 << "Evaluated: " << tresult() << nl;
109
110 return tresult;
111}
112
113
114template<class Type>
117(
118 const scalar x1,
119 const scalar x2
120) const
121{
123 return nullptr;
124}
125
126
127template<class Type>
129(
130 const FieldMapper& mapper
131)
132{
134}
135
136
137template<class Type>
139(
140 const PatchFunction1<Type>& pf1,
141 const labelList& addr
142)
143{
145}
146
147
148template<class Type>
150(
151 Ostream& os
152) const
153{
154 // PatchFunction1-from-subdict so output dictionary contains
155 // only the relevant entries.
156 dict_.writeEntry(this->name(), os);
157}
158
159
160// ************************************************************************* //
Abstract base class to hold the Field mapping addressing and weights.
Definition: FieldMapper.H:50
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
PatchFunction1 with values supplied by a parsed expression.
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two values.
virtual void rmap(const PatchFunction1< Type > &pf1, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
virtual void rmap(const PatchFunction1< Type > &rhs, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
const polyPatch const word const word const dictionary & dict
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool readEntry(const word &keyword, const dictionary &dict, bool mandatory=true, const bool stripComments=true)
Definition: exprString.C:103
virtual bool readDict(const dictionary &dict)
Read variables, tables etc.
Definition: fvExprDriver.C:153
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
OBJstream os(runTime.globalPath()/outputName)
#define DebugInfo
Report an information message using Foam::Info.
IOerror FatalIOError
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict