linearEqn.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 Class
28  Foam::linearEqn
29 
30 Description
31  Container to encapsulate various operations for
32  linear equation of the forms with real coefficients:
33 
34  \f[
35  a*x + b = 0
36  x + B = 0
37  \f]
38 
39 See also
40  Test-linearEqn.C
41 
42 SourceFiles
43  linearEqnI.H
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef Foam_linearEqn_H
48 #define Foam_linearEqn_H
49 
50 #include "Roots.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 /*---------------------------------------------------------------------------*\
58  Class linearEqn Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class linearEqn
62 :
63  public VectorSpace<linearEqn, scalar, 2>
64 {
65 public:
66 
67  //- Component labeling enumeration
68  enum components { A, B };
69 
70 
71  // Constructors
72 
73  //- Default construct
74  linearEqn() = default;
75 
76  //- Construct initialized to zero
77  inline linearEqn(const Foam::zero);
78 
79  //- Construct from components
80  inline linearEqn(const scalar a, const scalar b);
81 
82 
83  // Member Functions
84 
85  // Access
86 
87  scalar a() const noexcept { return this->v_[A]; }
88  scalar b() const noexcept { return this->v_[B]; }
89 
90  scalar& a() noexcept { return this->v_[A]; }
91  scalar& b() noexcept { return this->v_[B]; }
92 
93 
94  // Evaluate
95 
96  //- Evaluate the linear equation at x
97  inline scalar value(const scalar x) const;
98 
99  //- Evaluate the derivative of the linear equation at x
100  inline scalar derivative(const scalar x) const;
101 
102  //- Estimate the error of evaluation of the linear equation at x
103  inline scalar error(const scalar x) const;
104 
105  //- Return the real root of the linear equation
106  inline Roots<1> roots() const;
107 };
108 
109 
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 
112 } // End namespace Foam
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 
116 #include "linearEqnI.H"
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 #endif
121 
122 // ************************************************************************* //
Templated vector space.
Definition: VectorSpace.H:52
Templated storage for the roots of polynomial equations, plus flags to indicate the nature of the roo...
Definition: Roots.H:68
scalar a() const noexcept
Definition: linearEqn.H:90
components
Component labeling enumeration.
Definition: linearEqn.H:65
scalar b() const noexcept
Definition: linearEqn.H:91
scalar value(const scalar x) const
Evaluate the linear equation at x.
Definition: linearEqnI.H:39
scalar error(const scalar x) const
Estimate the error of evaluation of the linear equation at x.
Definition: linearEqnI.H:51
const direction noexcept
Definition: Scalar.H:258
Container to encapsulate various operations for linear equation of the forms with real coefficients: ...
Definition: linearEqn.H:56
linearEqn()=default
Default construct.
Roots< 1 > roots() const
Return the real root of the linear equation.
Definition: linearEqnI.H:57
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
scalar derivative(const scalar x) const
Evaluate the derivative of the linear equation at x.
Definition: linearEqnI.H:45
scalar v_[Ncmpts]
The components of this vector space.
Definition: VectorSpace.H:81
Namespace for OpenFOAM.