specieExponent.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) 2021-2023 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::specieExponent
26 
27 Description
28  Type for exponents of species in reaction. Can take either integer or
29  scalar value, and powers are optimised in the integer case.
30 
31 SourceFiles
32  specieExponentI.H
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef specieExponent_H
37 #define specieExponent_H
38 
39 #include "label.H"
40 #include "scalar.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // Forward declaration of classes
48 class Ostream;
49 
50 // Forward declaration of friend functions and operators
51 class specieExponent;
52 scalar pow(scalar x, const specieExponent& e);
53 specieExponent operator+(const specieExponent& a, const specieExponent& b);
54 specieExponent operator-(const specieExponent& a, const specieExponent& b);
55 Ostream& operator<<(Ostream&, const specieExponent&);
56 
57 
58 /*---------------------------------------------------------------------------*\
59  Class specieExponent Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class specieExponent
63 {
64  // Private Data
65 
66  //- Marker value to indicate that there is no possible integer
67  // representation of this exponent
68  static const label noIntegerExponent_ = labelMax;
69 
70  //- Integer exponent
71  label integerExponent_;
72 
73  //- Scalar exponent
74  scalar scalarExponent_;
75 
76 
77  // Private Member Functions
78 
79  //- Return whether or not this exponent has an integer representation
80  inline bool hasIntegerExponent() const;
81 
82 
83 public:
84 
85  // Constructors
86 
87  //- Construct null
88  inline specieExponent();
89 
90  //- Construct from integer
91  inline specieExponent(const label integerExponent);
92 
93  //- Construct from scalar
94  inline specieExponent(const scalar scalarExponent);
95 
96 
97  // Member Operators
98 
99  //- Cast to scalar
100  inline operator scalar() const;
101 
102  //- Assign to integer
103  inline specieExponent& operator=(const label integerExponent);
104 
105  //- Assign to scalar
106  inline specieExponent& operator=(const scalar scalarExponent);
107 
108  //- Negate a specie exponent
109  inline specieExponent operator-() const;
110 
111 
112  // Friend Functions
113 
114  //- Compute the power of a number to a specie exponent
115  inline friend scalar pow(const scalar x, const specieExponent& e);
116 
117 
118  // Friend Operators
119 
120  //- Sum two specie exponents
121  inline friend specieExponent operator+
122  (
123  const specieExponent& a,
124  const specieExponent& b
125  );
126 
127  //- Subtract two specie exponents
128  inline friend specieExponent operator-
129  (
130  const specieExponent& a,
131  const specieExponent& b
132  );
133 
134 
135  // IOstream Operators
136 
137  //- Write to output stream
138  inline friend Ostream& operator<<(Ostream& os, const specieExponent& e);
139 };
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace Foam
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #include "specieExponentI.H"
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 #endif
153 
154 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Type for exponents of species in reaction. Can take either integer or scalar value,...
friend scalar pow(const scalar x, const specieExponent &e)
Compute the power of a number to a specie exponent.
specieExponent()
Construct null.
friend Ostream & operator<<(Ostream &os, const specieExponent &e)
Write to output stream.
specieExponent & operator=(const label integerExponent)
Assign to integer.
specieExponent operator-() const
Negate a specie exponent.
volScalarField & b
Definition: createFields.H:27
Namespace for OpenFOAM.
const doubleScalar e
Definition: doubleScalar.H:105
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
tmp< fvMatrix< Type > > operator+(const fvMatrix< Type > &, const fvMatrix< Type > &)
static const label labelMax
Definition: label.H:62
Ostream & operator<<(Ostream &, const ensightPart &)
tmp< fvMatrix< Type > > operator-(const fvMatrix< Type > &)