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-2021 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 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class Type>
31 void Foam::Function1s::Scale<Type>::read(const dictionary& dict)
32 {
33  scale_ = Function1<scalar>::New("scale", dict);
34  xScale_ =
35  dict.found("xScale")
36  ? Function1<scalar>::New("xScale", dict)
37  : autoPtr<Function1<scalar>>(new Constant<scalar>("xScale", 1));
38  value_ = Function1<Type>::New("value", dict);
39 
40  integrableScale_ =
41  isA<Constant<scalar>>(xScale_())
42  && isA<Constant<scalar>>(scale_());
43 
44  integrableValue_ =
45  isA<Constant<scalar>>(xScale_())
46  && isA<Constant<Type>>(value_());
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
52 template<class Type>
54 (
55  const word& name,
56  const Function1<scalar>& scale,
57  const Function1<scalar>& xScale,
58  const Function1<Type>& value
59 )
60 :
62  scale_(scale.clone().ptr()),
63  xScale_(xScale.clone().ptr()),
64  value_(value.clone().ptr()),
65  integrableScale_
66  (
67  isA<Constant<scalar>>(xScale_())
68  && isA<Constant<scalar>>(scale_())
69  ),
70  integrableValue_
71  (
72  isA<Constant<scalar>>(xScale_())
73  && isA<Constant<Type>>(value_())
74  )
75 {}
76 
77 
78 template<class Type>
80 (
81  const word& name,
82  const dictionary& dict
83 )
84 :
86 {
87  read(dict);
88 }
89 
90 
91 template<class Type>
93 :
94  FieldFunction1<Type, Scale<Type>>(se),
95  scale_(se.scale_, false),
96  xScale_(se.xScale_, false),
97  value_(se.value_, false),
98  integrableScale_(se.integrableScale_),
99  integrableValue_(se.integrableValue_)
100 {}
101 
102 
103 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
104 
105 template<class Type>
107 {}
108 
109 
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 
112 template<class Type>
114 {
115  writeEntry(os, scale_());
116  writeEntry(os, xScale_());
117  writeEntry(os, value_());
118 }
119 
120 
121 // ************************************************************************* //
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
Definition: typeInfo.H:134
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
virtual ~Scale()
Destructor.
Definition: Scale.C:106
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
Function1 which scales a given &#39;value&#39; function by a &#39;scale&#39; scalar function and scales the &#39;x&#39; argum...
Definition: Scale.H:152
A class for handling words, derived from string.
Definition: word.H:59
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
virtual tmp< Function1< Type > > clone() const =0
Construct and return a clone.
Templated function that returns a constant value.
Definition: Constant.H:57
Scale(const word &name, const Function1< scalar > &scale, const Function1< scalar > &xScale, const Function1< Type > &value)
Construct from name and functions.
Definition: Scale.C:54
virtual void write(Ostream &os) const
Write data to dictionary stream.
Definition: Scale.C:113