Function1Expression.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-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
26Class
27 Foam::Function1Types::Function1Expression
28
29Description
30 Function1 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 mag(arg() > start && arg() < stop) * vector(1, 0, 0)
53 #};
54 }
55 }
56 \endverbatim
57
58Very much like '\#eval' but runtime
59
60See also
61 Foam::exprFixedValueFvPatchField
62
63SourceFiles
64 Function1Expression.C
65
66\*---------------------------------------------------------------------------*/
67
68#ifndef Function1Types_expression_H
69#define Function1Types_expression_H
70
71#include "Function1.H"
72#include "fieldExprDriver.H"
73
74// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
75
76namespace Foam
78namespace Function1Types
79{
80
81/*---------------------------------------------------------------------------*\
82 Class Function1Expression Declaration
83\*---------------------------------------------------------------------------*/
84
85template<class Type>
87:
88 public Function1<Type>
89{
90 // Private Data
91
92 //- Dictionary contents for the function
93 const dictionary dict_;
94
95 //- The expression
96 expressions::exprString valueExpr_;
97
98 //- The expression driver
99 mutable expressions::fieldExprDriver driver_;
100
101
102public:
103
104 //- Runtime type information
105 TypeName("expression");
106
107
108 // Generated Methods
109
110 //- No copy assignment
111 void operator=(const Function1Expression<Type>&) = delete;
112
113
114 // Constructors
115
116 //- Construct from entry name, dictionary and optional registry
118 (
119 const word& entryName,
120 const dictionary& dict,
121 const objectRegistry* obrPtr = nullptr
122 );
123
124 //- Copy construct
126
127 //- Construct and return a clone
128 virtual tmp<Function1<Type>> clone() const
129 {
131 }
132
133
134 //- Destructor
135 virtual ~Function1Expression() = default;
136
137
138 // Member Functions
139
140 //- Return value.
141 // The parameter 'x' is accessible as 'arg' in the function
142 virtual Type value(const scalar x) const;
143
144 //- Integrate between two values
145 virtual Type integrate
146 (
147 const scalar x1,
148 const scalar x2
149 ) const;
150
151 //- Write in dictionary format
152 virtual void writeData(Ostream& os) const;
153};
154
155
156// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157
158} // End namespace Function1Types
159} // End namespace Foam
160
161// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162
163#ifdef NoRepository
164 #include "Function1Expression.C"
165#endif
166
167// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168
169#endif
170
171// ************************************************************************* //
Function1 with values supplied by a parsed expression.
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
virtual ~Function1Expression()=default
Destructor.
virtual void writeData(Ostream &os) const
Write in dictionary format.
virtual Type value(const scalar x) const
Return value.
TypeName("expression")
Runtime type information.
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two values.
void operator=(const Function1Expression< Type > &)=delete
No copy assignment.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:96
const word const dictionary & dict
Definition: Function1.H:134
const word const dictionary const objectRegistry * obrPtr
Definition: Function1.H:136
const word & entryName
Definition: Function1.H:133
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Driver for generic primitive field expressions.
Registry of regIOobjects.
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