All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
quadraticEqn.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 Class
25  Foam::quadraticEqn
26 
27 Description
28  Quadratic equation of the form a*x^2 + b*x + c = 0
29 
30 SourceFiles
31  quadraticEqnI.H
32  quadraticEqn.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef quadraticEqn_H
37 #define quadraticEqn_H
38 
39 #include "Roots.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class quadraticEqn Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class quadraticEqn
51 :
52  public VectorSpace<quadraticEqn, scalar, 3>
53 {
54 public:
55 
56  //- Coefficient indexing enumeration
57  struct coefficient
58  {
59  enum {a, b, c};
60  };
61 
62 
63  // Constructors
64 
65  //- Construct null
66  inline quadraticEqn();
67 
68  //- Construct initialized to zero
69  inline quadraticEqn(const Foam::zero);
70 
71  //- Construct from components
72  inline quadraticEqn(const scalar a, const scalar b, const scalar c);
73 
74 
75  // Member Functions
76 
77  // Access
78 
79  inline scalar a() const;
80  inline scalar b() const;
81  inline scalar c() const;
82 
83  inline scalar& a();
84  inline scalar& b();
85  inline scalar& c();
86 
87  //- Evaluate at x
88  inline scalar value(const scalar x) const;
89 
90  //- Evaluate the derivative at x
91  inline scalar derivative(const scalar x) const;
92 
93  //- Estimate the error of evaluation at x
94  inline scalar error(const scalar x) const;
95 
96  //- Get the roots
97  Roots<2> roots() const;
98 };
99 
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 } // End namespace Foam
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 #include "quadraticEqnI.H"
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 #endif
112 
113 // ************************************************************************* //
Coefficient indexing enumeration.
Definition: quadraticEqn.H:56
Roots< 2 > roots() const
Get the roots.
Definition: quadraticEqn.C:31
scalar error(const scalar x) const
Estimate the error of evaluation at x.
Templated vector space.
Definition: VectorSpace.H:53
Templated storage for the roots of polynomial equations, plus flags to indicate the nature of the roo...
Definition: Roots.H:64
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
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:49
scalar value(const scalar x) const
Evaluate at x.
Definition: quadraticEqnI.H:89
Namespace for OpenFOAM.