linearEqnI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2017 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 {}
33 
34 
36 :
37  VectorSpace<linearEqn, scalar, 2>(Foam::zero{})
38 {}
39 
40 
41 inline Foam::linearEqn::linearEqn(const scalar a, const scalar b)
42 {
43  this->v_[A] = a;
44  this->v_[B] = b;
45 }
46 
47 
48 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
49 
50 inline Foam::scalar Foam::linearEqn::a() const
51 {
52  return this->v_[A];
53 }
54 
55 
56 inline Foam::scalar Foam::linearEqn::b() const
57 {
58  return this->v_[B];
59 }
60 
61 
62 inline Foam::scalar& Foam::linearEqn::a()
63 {
64  return this->v_[A];
65 }
66 
67 
68 inline Foam::scalar& Foam::linearEqn::b()
69 {
70  return this->v_[B];
71 }
72 
73 
74 inline Foam::scalar Foam::linearEqn::value(const scalar x) const
75 {
76  return x*a() + b();
77 }
78 
79 
80 inline Foam::scalar Foam::linearEqn::derivative(const scalar x) const
81 {
82  return a();
83 }
84 
85 
86 inline Foam::scalar Foam::linearEqn::error(const scalar x) const
87 {
88  return SMALL*(mag(x*a()) + mag(b()));
89 }
90 
91 
93 {
94  const scalar a = this->a();
95  const scalar b = this->b();
96 
97  if (mag(a) < VSMALL)
98  {
99  return Roots<1>(roots::nan, 0);
100  }
101  else if (mag(b/VGREAT) >= mag(a))
102  {
103  return Roots<1>(sign(a) == sign(b) ? roots::negInf : roots::posInf, 0);
104  }
105 
106  return Roots<1>(roots::real, -b/a);
107 }
108 
109 
110 // ************************************************************************* //
Foam::linearEqn::a
scalar a() const
Definition: linearEqnI.H:50
Foam::roots::posInf
Definition: Roots.H:58
Foam::roots::nan
Definition: Roots.H:60
Foam::linearEqn::derivative
scalar derivative(const scalar x) const
Evaluate the derivative of the linear equation at x.
Definition: linearEqnI.H:80
B
static const Foam::dimensionedScalar B("", Foam::dimless, 18.678)
Foam::linearEqn::b
scalar b() const
Definition: linearEqnI.H:56
A
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
Foam::sign
dimensionedScalar sign(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:166
Foam::linearEqn
Container to encapsulate various operations for linear equation of the forms with real coefficients:
Definition: linearEqn.H:60
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:56
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::linearEqn::value
scalar value(const scalar x) const
Evaluate the linear equation at x.
Definition: linearEqnI.H:74
Foam::linearEqn::linearEqn
linearEqn()
Construct null.
Definition: linearEqnI.H:31
Foam::roots::negInf
Definition: Roots.H:59
Foam::roots::real
Definition: Roots.H:56
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::linearEqn::roots
Roots< 1 > roots() const
Return the real root of the linear equation.
Definition: linearEqnI.H:92
Foam::linearEqn::error
scalar error(const scalar x) const
Estimate the error of evaluation of the linear equation at x.
Definition: linearEqnI.H:86
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::Roots
Templated storage for the roots of polynomial equations, plus flags to indicate the nature of the roo...
Definition: Roots.H:70
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62