cubicEqnI.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-2018 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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
27 
29 {}
30 
31 
33 :
34  VectorSpace<cubicEqn, scalar, 4>(Foam::zero())
35 {}
36 
37 
39 (
40  const scalar a,
41  const scalar b,
42  const scalar c,
43  const scalar d
44 )
45 {
46  this->v_[A] = a;
47  this->v_[B] = b;
48  this->v_[C] = c;
49  this->v_[D] = d;
50 }
51 
52 
53 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
54 
55 inline Foam::scalar Foam::cubicEqn::a() const
56 {
57  return this->v_[A];
58 }
59 
60 
61 inline Foam::scalar Foam::cubicEqn::b() const
62 {
63  return this->v_[B];
64 }
65 
66 
67 inline Foam::scalar Foam::cubicEqn::c() const
68 {
69  return this->v_[C];
70 }
71 
72 
73 inline Foam::scalar Foam::cubicEqn::d() const
74 {
75  return this->v_[D];
76 }
77 
78 
79 inline Foam::scalar& Foam::cubicEqn::a()
80 {
81  return this->v_[A];
82 }
83 
84 
85 inline Foam::scalar& Foam::cubicEqn::b()
86 {
87  return this->v_[B];
88 }
89 
90 
91 inline Foam::scalar& Foam::cubicEqn::c()
92 {
93  return this->v_[C];
94 }
95 
96 
97 inline Foam::scalar& Foam::cubicEqn::d()
98 {
99  return this->v_[D];
100 }
101 
102 
103 inline Foam::scalar Foam::cubicEqn::value(const scalar x) const
104 {
105  return x*(x*(x*a() + b()) + c()) + d();
106 }
107 
108 
109 inline Foam::scalar Foam::cubicEqn::derivative(const scalar x) const
110 {
111  return x*(x*3*a() + 2*b()) + c();
112 }
113 
114 
115 inline Foam::scalar Foam::cubicEqn::error(const scalar x) const
116 {
117  return mag(small*x*(x*(x*3*a() + 2*b()) + c()));
118 }
119 
120 
121 // ************************************************************************* //
scalar c() const
Definition: cubicEqnI.H:67
Templated vector space.
Definition: VectorSpace.H:53
scalar d() const
Definition: cubicEqnI.H:73
scalar error(const scalar x) const
Estimate the error of evaluation at x.
Definition: cubicEqnI.H:115
Cubic equation of the form a*x^3 + b*x^2 + c*x + d = 0.
Definition: cubicEqn.H:49
scalar b() const
Definition: cubicEqnI.H:61
scalar derivative(const scalar x) const
Evaluate the derivative at x.
Definition: cubicEqnI.H:109
scalar a() const
Definition: cubicEqnI.H:55
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:49
dimensioned< scalar > mag(const dimensioned< Type > &)
cubicEqn()
Construct null.
Definition: cubicEqnI.H:28
scalar value(const scalar x) const
Evaluate at x.
Definition: cubicEqnI.H:103
scalar v_[Ncmpts]
The components of this vector space.
Definition: VectorSpace.H:81
Namespace for OpenFOAM.