normalise.C
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 \*---------------------------------------------------------------------------*/
25 
26 #include "normalise.H"
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 namespace Function1s
33 {
35 }
36 }
37 
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
42 (
43  const word& name,
44  const unitConversions& units,
45  const dictionary& dict
46 )
47 :
48  FieldFunction1<scalar, normalise>(name),
49  bounds_(dict.lookup<Pair<scalar>>("bounds", units.x)),
50  value_(Function1<scalar>::New("value", {units.x, unitAny}, dict)),
51  scale_(1/value_->integral(bounds_[0], bounds_[1]))
52 {}
53 
54 
56 :
57  FieldFunction1<scalar, normalise>(se),
58  bounds_(se.bounds_),
59  value_(se.value_, false),
60  scale_(se.scale_)
61 {}
62 
63 
64 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
65 
67 {}
68 
69 
70 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
71 
73 (
74  Ostream& os,
75  const unitConversions& units
76 ) const
77 {
78  writeEntry(os, units.x, bounds_);
79  writeEntry(os, units, value_());
80 }
81 
82 
83 // ************************************************************************* //
Run-time selectable general function of one variable.
Definition: Function1.H:125
Function1 which scales a given 'value' function so that its integral within specified bounds is equal...
Definition: normalise.H:110
normalise(const word &name, const unitConversions &units, const dictionary &dict)
Construct from name and dictionary.
Definition: normalise.C:42
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
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An ordered pair of two objects of type <Type> with first() and second() elements.
Definition: Pair.H:66
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
void writeEntry(Ostream &os, const omega &a)
Definition: omega1.C:97
addScalarFunction1(laminarBL)
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
Namespace for OpenFOAM.
const unitConversion unitAny
const HashTable< unitConversion > & units()
Get the table of unit conversions.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dictionary dict