ScaleI.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) 2017-2020 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 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 template<class Type>
31 inline Type Foam::Function1s::Scale<Type>::value(const scalar x) const
32 {
33  const scalar sx = xScale_->value(x)*x;
34  return scale_->value(sx)*value_->value(sx);
35 }
36 
37 
38 template<class Type>
40 (
41  const scalar x1,
42  const scalar x2
43 ) const
44 {
45  if (integrableScale_)
46  {
47  const scalar sx = xScale_->value(NaN);
48  return scale_->value(NaN)*value_->integral(sx*x1, sx*x2)/sx;
49  }
50 
51  if (integrableValue_)
52  {
53  const scalar sx = xScale_->value(NaN);
54  return scale_->integral(sx*x1, sx*x2)/sx*value_->value(NaN);
55  }
56 
58  << "Integration is not defined for " << type() << " functions "
59  << "unless x-scaling is constant and either scaling is constant or "
60  << "the value is constant"
61  << exit(FatalError);
62 
63  return Zero;
64 }
65 
66 
67 // ************************************************************************* //
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
static const zero Zero
Definition: zero.H:97
virtual Type integral(const scalar x1, const scalar x2) const
Integrate between two values.
Definition: ScaleI.H:40
virtual Type value(const scalar x) const
Return value.
Definition: ScaleI.H:31
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488