normalise.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::Function1s::normalise
26 
27 Description
28  Function1 which scales a given 'value' function so that its integral within
29  specified bounds is equal to one
30 
31 Usage
32  Example of use within a scale function to scale a given profile to a
33  desired total integral value:
34  \verbatim
35  <name>
36  {
37  type scale;
38 
39  scale
40  {
41  type normalise;
42 
43  bounds (0 1.5);
44 
45  value
46  {
47  type table;
48  values
49  (
50  (0 0.1272)
51  (0.25 8.7011)
52  (0.5 8.8882)
53  (0.75 6.7608)
54  (1 4.9547)
55  (1.25 3.9213)
56  (1.5 0 )
57  );
58  }
59  }
60 
61  value constant 6e-6;
62  }
63  \endverbatim
64 
65  Where:
66  \table
67  Property | Description | Data type | Default
68  bounds | Bounds of the integration | Pair<scalar> |
69  value | Function to normalise | Function1<Type> |
70  \endtable
71 
72 SourceFiles
73  normalise.C
74 
75 \*---------------------------------------------------------------------------*/
76 
77 #ifndef normalise_H
78 #define normalise_H
79 
80 #include "Function1.H"
81 
82 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
83 
84 namespace Foam
85 {
86 namespace Function1s
87 {
88 
89 /*---------------------------------------------------------------------------*\
90  Class ScaleIntegral Declaration
91 \*---------------------------------------------------------------------------*/
92 
93 class normalise
94 :
95  public FieldFunction1<scalar, normalise>
96 {
97  // Private Data
98 
99  //- Bounds over which to normalise
100  const Pair<scalar> bounds_;
101 
102  //- Value function
103  const autoPtr<Function1<scalar>> value_;
104 
105  //- Computed scale
106  const scalar scale_;
107 
108 
109 public:
110 
111  // Runtime type information
112  TypeName("normalise");
113 
114 
115  // Constructors
116 
117  //- Construct from name and dictionary
118  normalise
119  (
120  const word& name,
121  const unitConversions& units,
122  const dictionary& dict
123  );
124 
125  //- Copy constructor
126  normalise(const normalise& se);
127 
128 
129  //- Destructor
130  virtual ~normalise();
131 
132 
133  // Member Functions
134 
135  //- Return value
136  virtual inline scalar value(const scalar x) const;
137 
138  //- Integrate between two values
139  virtual inline scalar integral(const scalar x1, const scalar x2) const;
140 
141  //- Write data to dictionary stream
142  virtual void write(Ostream& os, const unitConversions& units) const;
143 
144 
145  // Member Operators
146 
147  //- Disallow default bitwise assignment
148  void operator=(const normalise&) = delete;
149 };
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace Function1s
155 } // End namespace Foam
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 #include "normaliseI.H"
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #endif
164 
165 // ************************************************************************* //
const word & name() const
Return the name of the entry.
Definition: Function1.C:78
Function1 which scales a given 'value' function so that its integral within specified bounds is equal...
Definition: normalise.H:110
void operator=(const normalise &)=delete
Disallow default bitwise assignment.
normalise(const word &name, const unitConversions &units, const dictionary &dict)
Construct from name and dictionary.
Definition: normalise.C:42
virtual scalar value(const scalar x) const
Return value.
Definition: normaliseI.H:30
virtual void write(Ostream &os, const unitConversions &units) const
Write data to dictionary stream.
Definition: normalise.C:73
virtual ~normalise()
Destructor.
Definition: normalise.C:66
virtual scalar integral(const scalar x1, const scalar x2) const
Integrate between two values.
Definition: normaliseI.H:37
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
const HashTable< unitConversion > & units()
Get the table of unit conversions.
quaternion normalise(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
Definition: quaternionI.H:603
dictionary dict