Scale.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) 2017-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 "Scale.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const word& name,
34  const Function1<scalar>& scale,
35  const Function1<scalar>& xScale,
36  const Function1<Type>& value
37 )
38 :
39  FieldFunction1<Type, Scale<Type>>(name),
40  scale_(scale.clone().ptr()),
41  xScale_(xScale.clone().ptr()),
42  value_(value.clone().ptr()),
43  integrableScale_(xScale_->constant() && scale_->constant()),
44  integrableValue_(xScale_->constant() && value_->constant())
45 {}
46 
47 
48 template<class Type>
50 (
51  const word& name,
52  const unitConversions& units,
53  const dictionary& dict
54 )
55 :
56  FieldFunction1<Type, Scale<Type>>(name),
57  scale_(Function1<scalar>::New("scale", units.x, unitless, dict)),
58  xScale_
59  (
60  dict.found("xScale")
61  ? Function1<scalar>::New("xScale", units.x, units.x, dict)
62  : autoPtr<Function1<scalar>>(new Constant<scalar>("xScale", 1))
63  ),
64  value_(Function1<Type>::New("value", units, dict)),
65  integrableScale_(xScale_->constant() && scale_->constant()),
66  integrableValue_(xScale_->constant() && value_->constant())
67 {}
68 
69 
70 template<class Type>
72 :
73  FieldFunction1<Type, Scale<Type>>(se),
74  scale_(se.scale_, false),
75  xScale_(se.xScale_, false),
76  value_(se.value_, false),
77  integrableScale_(se.integrableScale_),
78  integrableValue_(se.integrableValue_)
79 {}
80 
81 
82 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
83 
84 template<class Type>
86 {}
87 
88 
89 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90 
91 template<class Type>
93 (
94  Ostream& os,
95  const unitConversions& units
96 ) const
97 {
98  writeEntry(os, units.x, unitless, scale_());
99  writeEntry(os, units.x, units.x, xScale_());
100  writeEntry(os, units, value_());
101 }
102 
103 
104 // ************************************************************************* //
bool found
Templated function that returns a constant value.
Definition: Constant.H:60
Function1 which scales a given 'value' function by a 'scale' scalar function and scales the 'x' argum...
Definition: Scale.H:155
virtual void write(Ostream &os, const unitConversions &units) const
Write data to dictionary stream.
Definition: Scale.C:93
virtual ~Scale()
Destructor.
Definition: Scale.C:85
Scale(const word &name, const Function1< scalar > &scale, const Function1< scalar > &xScale, const Function1< Type > &value)
Construct from name and functions.
Definition: Scale.C:32
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
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
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
const HashTable< unitConversion > & units()
Get the table of unit conversions.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
T clone(const T &t)
Definition: List.H:55
const unitConversion unitless
dictionary dict