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-2025 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  constantScale_(scale_->constant()),
42  xScale_(xScale.clone().ptr()),
43  constantXScale_(xScale_->constant()),
44  value_(value.clone().ptr()),
45  constantValue_(value_->constant())
46 {}
47 
48 
49 template<class Type>
51 (
52  const word& name,
53  const unitConversions& units,
54  const dictionary& dict
55 )
56 :
57  FieldFunction1<Type, Scale<Type>>(name),
58  scale_(Function1<scalar>::New("scale", units.x, unitAny, dict)),
59  constantScale_(scale_->constant()),
60  xScale_
61  (
62  dict.found("xScale")
63  ? Function1<scalar>::New("xScale", units.x, unitless, dict)
64  : autoPtr<Function1<scalar>>(new Constant<scalar>("xScale", 1))
65  ),
66  constantXScale_(xScale_->constant()),
67  value_(Function1<Type>::New("value", units.x, unitAny, dict)),
68  constantValue_(value_->constant())
69 {}
70 
71 
72 template<class Type>
74 :
75  FieldFunction1<Type, Scale<Type>>(se),
76  scale_(se.scale_, false),
77  constantScale_(se.constantScale_),
78  xScale_(se.xScale_, false),
79  constantXScale_(se.constantXScale_),
80  value_(se.value_, false),
81  constantValue_(se.constantValue_)
82 {}
83 
84 
85 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
86 
87 template<class Type>
89 {}
90 
91 
92 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
93 
94 template<class Type>
96 (
97  Ostream& os,
98  const unitConversions& units
99 ) const
100 {
101  writeEntry(os, units.x, unitless, scale_());
102  writeEntry(os, units.x, units.x, xScale_());
103  writeEntry(os, units, value_());
104 }
105 
106 
107 // ************************************************************************* //
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:96
virtual ~Scale()
Destructor.
Definition: Scale.C:88
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 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
const unitConversion unitAny
const HashTable< unitConversion > & units()
Get the table of unit conversions.
T clone(const T &t)
Definition: List.H:55
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
const unitConversion unitless
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
dictionary dict