LimitRange.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 -------------------------------------------------------------------------------
10 License
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 Class
27  Foam::Function1Types::LimitRange
28 
29 Description
30  Function1 wrapper that limits the input range of another Function1
31 
32  Example usage for limiting a polynomial:
33  \verbatim
34  limitedPolyTest limitRange;
35  limitedPolyTestCoeffs
36  {
37  min 0.4;
38  max 1.4;
39 
40  value polynomial
41  (
42  (5 1)
43  (-2 2)
44  (-2 3)
45  (1 4)
46  );
47  }
48  \endverbatim
49 
50  Here the return value will be:
51  - poly(0.4) for x <= 0.4;
52  - poly(1.4) for x >= 1.4; and
53  - poly(x) for 0.4 < x < 1.4.
54 
55 
56  Example usage for limiting a table
57  \verbatim
58  limitedTableFileTest limitRange;
59  limitedTableFileTestCoeffs
60  {
61  min 0.4;
62  max 1.4;
63 
64  value tableFile;
65  file "<system>/fanCurve.txt";
66  }
67  \endverbatim
68 
69  Where:
70  \table
71  Property | Description | Required
72  min | Minimum input value | yes
73  max | Maximum input value | yes
74  value | Function of type Function1<Type> | yes
75  \endtable
76 
77 SourceFiles
78  LimitRange.C
79 
80 \*---------------------------------------------------------------------------*/
81 
82 #ifndef LimitRange_H
83 #define LimitRange_H
84 
85 #include "Function1.H"
86 
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 
89 namespace Foam
90 {
91 namespace Function1Types
92 {
93 
94 /*---------------------------------------------------------------------------*\
95  Class LimitRange Declaration
96 \*---------------------------------------------------------------------------*/
97 
98 template<class Type>
99 class LimitRange
100 :
101  public Function1<Type>
102 {
103  // Private Data
104 
105  //- Minimum input value
106  scalar min_;
107 
108  //- Maximum input value
109  scalar max_;
110 
111  //- Value function
112  autoPtr<Function1<Type>> value_;
113 
114 
115  // Private Member Functions
116 
117  //- Read the coefficients from the given dictionary
118  void read(const dictionary& coeffs);
119 
120 
121 public:
122 
123  //- Runtime type information
124  TypeName("limitRange");
125 
126 
127  // Generated Methods
128 
129  //- No copy assignment
130  void operator=(const LimitRange<Type>&) = delete;
131 
132 
133  // Constructors
134 
135  //- Construct from entry name and dictionary
136  LimitRange(const word& entryName, const dictionary& dict);
137 
138  //- Copy construct
139  explicit LimitRange(const LimitRange<Type>& rhs);
140 
141 
142  //- Destructor
143  virtual ~LimitRange() = default;
144 
145 
146  // Member Functions
147 
148  //- Return value for time t
149  virtual inline Type value(const scalar t) const;
150 
151  //- Integrate between two (scalar) values
152  virtual inline Type integrate(const scalar x1, const scalar x2) const;
153 
154  //- Write in dictionary format
155  virtual void writeData(Ostream& os) const;
156 
157  //- Write coefficient entries in dictionary format
158  void writeEntries(Ostream& os) const;
159 };
160 
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 } // End namespace Function1Types
165 } // End namespace Foam
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 #include "LimitRangeI.H"
170 
171 #ifdef NoRepository
172  #include "LimitRange.C"
173 #endif
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
LimitRangeI.H
Foam::Function1Types::LimitRange
Function1 wrapper that limits the input range of another Function1.
Definition: LimitRange.H:114
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
LimitRange.C
Foam::Function1::entryName
const word & entryName
Definition: Function1.H:133
Function1.H
Foam::Function1::dict
const word const dictionary & dict
Definition: Function1.H:135
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:86
Foam::Function1Types::LimitRange::TypeName
TypeName("limitRange")
Runtime type information.
Foam::Function1Types::LimitRange::~LimitRange
virtual ~LimitRange()=default
Destructor.
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::Function1Types::LimitRange::operator=
void operator=(const LimitRange< Type > &)=delete
No copy assignment.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::Function1Types::LimitRange::value
virtual Type value(const scalar t) const
Return value for time t.
Definition: LimitRangeI.H:33
Foam::Function1Types::LimitRange::integrate
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: LimitRangeI.H:43
Foam::Function1Types::LimitRange::writeEntries
void writeEntries(Ostream &os) const
Write coefficient entries in dictionary format.
Definition: LimitRange.C:67
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::Function1Types::LimitRange::LimitRange
LimitRange(const word &entryName, const dictionary &dict)
Construct from entry name and dictionary.
Definition: LimitRange.C:43
Foam::Function1Types::LimitRange::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: LimitRange.C:76