All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
quadraticEqnI.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<quadraticEqn, scalar, 3>(Foam::zero())
35 {}
36 
37 
39 (
40  const scalar a,
41  const scalar b,
42  const scalar c
43 )
44 {
45  this->v_[coefficient::a] = a;
46  this->v_[coefficient::b] = b;
47  this->v_[coefficient::c] = c;
48 }
49 
50 
51 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52 
53 inline Foam::scalar Foam::quadraticEqn::a() const
54 {
55  return this->v_[coefficient::a];
56 }
57 
58 
59 inline Foam::scalar Foam::quadraticEqn::b() const
60 {
61  return this->v_[coefficient::b];
62 }
63 
64 
65 inline Foam::scalar Foam::quadraticEqn::c() const
66 {
67  return this->v_[coefficient::c];
68 }
69 
70 
71 inline Foam::scalar& Foam::quadraticEqn::a()
72 {
73  return this->v_[coefficient::a];
74 }
75 
76 
77 inline Foam::scalar& Foam::quadraticEqn::b()
78 {
79  return this->v_[coefficient::b];
80 }
81 
82 
83 inline Foam::scalar& Foam::quadraticEqn::c()
84 {
85  return this->v_[coefficient::c];
86 }
87 
88 
89 inline Foam::scalar Foam::quadraticEqn::value(const scalar x) const
90 {
91  return x*(x*a() + b()) + c();
92 }
93 
94 
95 inline Foam::scalar Foam::quadraticEqn::derivative(const scalar x) const
96 {
97  return x*2*a() + b();
98 }
99 
100 
101 inline Foam::scalar Foam::quadraticEqn::error(const scalar x) const
102 {
103  return
104  small*mag(x)*(mag(x*a()) + mag(b()))
105  + small*(mag(x*(x*a() + b())) + mag(c()));
106 }
107 
108 
109 // ************************************************************************* //
scalar error(const scalar x) const
Estimate the error of evaluation at x.
Templated vector space.
Definition: VectorSpace.H:53
scalar c() const
Definition: quadraticEqnI.H:65
scalar a() const
Definition: quadraticEqnI.H:53
quadraticEqn()
Construct null.
Definition: quadraticEqnI.H:28
scalar derivative(const scalar x) const
Evaluate the derivative at x.
Definition: quadraticEqnI.H:95
Quadratic equation of the form a*x^2 + b*x + c = 0.
Definition: quadraticEqn.H:49
scalar b() const
Definition: quadraticEqnI.H:59
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 > &)
scalar v_[Ncmpts]
The components of this vector space.
Definition: VectorSpace.H:84
scalar value(const scalar x) const
Evaluate at x.
Definition: quadraticEqnI.H:89
Namespace for OpenFOAM.