PatchFunction1Expression.H
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 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
26Class
27 Foam::PatchFunction1Types::PatchExprField
28
29Description
30 PatchFunction1 with values supplied by a parsed expression.
31
32Usage
33 Example:
34 \verbatim
35 <patchName>
36 {
37 type uniformFixedValue;
38 uniformValue
39 {
40 type expression;
41
42 // optional variables for use within the expression
43 variables
44 (
45 "start = 0.5"
46 "stop = 1"
47 );
48
49 // A step function
50 expression
51 #{
52 scalar(arg() > start && arg() < stop) * vector(1, 0, 0)
53 #};
54 }
55 }
56 \endverbatim
57
58See also
59 Foam::exprFixedValueFvPatchField
60
61SourceFiles
62 PatchFunction1Expression.C
63
64\*---------------------------------------------------------------------------*/
65
66#ifndef PatchFunction1Types_expression_H
67#define PatchFunction1Types_expression_H
68
69#include "PatchFunction1.H"
70#include "patchExprDriver.H"
71
72// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73
74namespace Foam
76namespace PatchFunction1Types
77{
78
79/*---------------------------------------------------------------------------*\
80 Class PatchExprField Declaration
81\*---------------------------------------------------------------------------*/
82
83template<class Type>
85:
86 public PatchFunction1<Type>
87{
88 // Private Data
89
90 //- Dictionary contents for the function
91 const dictionary dict_;
92
93 //- The expression
94 expressions::exprString valueExpr_;
95
96 //- The expression driver
98
99
100public:
101
102 //- Runtime type information
103 TypeName("expression");
104
105
106 // Generated Methods
107
108 //- No copy assignment
109 void operator=(const PatchExprField<Type>&) = delete;
110
111
112 // Constructors
113
114 //- Construct from patch, entry name and dictionary
115 // The patch must correspond to an fvPatch!
117 (
118 const polyPatch& pp,
119 const word& redirectType,
120 const word& entryName,
121 const dictionary& dict,
122 const bool faceValues = true
123 );
124
125 //- Copy construct
126 explicit PatchExprField(const PatchExprField<Type>& rhs);
127
128 //- Copy construct setting patch
129 explicit PatchExprField
130 (
131 const PatchExprField<Type>& rhs,
132 const polyPatch& pp
133 );
134
135 //- Construct and return a clone
136 virtual tmp<PatchFunction1<Type>> clone() const
137 {
139 (
140 new PatchExprField<Type>(*this)
141 );
142 }
143
144 //- Construct and return a clone setting patch
145 virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const
146 {
148 (
149 new PatchExprField<Type>(*this, pp)
150 );
151 }
152
153
154 //- Destructor
155 virtual ~PatchExprField() = default;
156
157
158 // Member Functions
159
160 // Evaluation
161
162 //- Return value.
163 // The parameter 'x' is accessible as 'arg' in the function
164 virtual tmp<Field<Type>> value(const scalar x) const;
165
166 //- Is value constant (i.e. independent of x)
167 virtual inline bool constant() const
168 {
169 return false;
170 }
171
172 //- Is value uniform (i.e. independent of coordinate)
173 virtual inline bool uniform() const
174 {
175 return false;
176 }
177
178 //- Integrate between two values
180 (
181 const scalar x1,
182 const scalar x2
183 ) const;
184
185
186 // Mapping
187
188 //- Map (and resize as needed) from self given a mapping object
189 virtual void autoMap(const FieldMapper& mapper);
190
191 //- Reverse map the given PatchFunction1 onto this PatchFunction1
192 virtual void rmap
193 (
194 const PatchFunction1<Type>& pf1,
195 const labelList& addr
196 );
197
198
199 // IO
200
201 //- Write in dictionary format
202 virtual void writeData(Ostream& os) const;
203};
204
205
206// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207
208} // End namespace PatchFunction1Types
209} // End namespace Foam
210
211// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212
213#ifdef NoRepository
215#endif
216
217// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218
219#endif
220
221// ************************************************************************* //
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 bool uniform() const
Is value uniform (i.e. independent of coordinate)
virtual ~PatchExprField()=default
Destructor.
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.
virtual void writeData(Ostream &os) const
Write in dictionary format.
virtual tmp< PatchFunction1< Type > > clone(const polyPatch &pp) const
Construct and return a clone setting patch.
virtual bool constant() const
Is value constant (i.e. independent of x)
virtual tmp< Field< Type > > value(const scalar x) const
Return value.
virtual tmp< PatchFunction1< Type > > clone() const
Construct and return a clone.
TypeName("expression")
Runtime type information.
void operator=(const PatchExprField< Type > &)=delete
No copy assignment.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
const polyPatch const word const word & entryName
const polyPatch const word const word const dictionary & dict
const polyPatch & pp
const polyPatch const word const word const dictionary const bool faceValues
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
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
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73