ThermoRefPair.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) 2023-2025 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::ThermoRefPair
26 
27 Description
28  Class containing a pair of thermo references. Handles down-casting to more
29  specific thermo types by constructing one pair from another (e.g.,
30  constructing a multicomponentThermo reference pair from a basicThermo
31  pair). Tracks validity of the references.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef ThermoRefPair_H
36 #define ThermoRefPair_H
37 
38 #include "fvModel.H"
39 #include "objectRegistry.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class ThermoRefPair Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 template<class ThermoType>
51 class ThermoRefPair
52 {
53  // Private Member Data
54 
55  //- Validity flags
56  const Pair<bool> valid_;
57 
58  //- The first thermo
59  const ThermoType& first_;
60 
61  //- The second thermo
62  const ThermoType& second_;
63 
64 
65  // Private Constructors
66 
67  //- Construct from components
68  inline ThermoRefPair
69  (
71  const ThermoType& first,
72  const ThermoType& second
73  );
74 
75 
76 public:
77 
78  //- Declare friendship with other thermo reference pairs
79  template<class OtherThermoType>
80  friend class ThermoRefPair;
81 
82 
83  // Constructors
84 
85  //- Construct from a database and phase names
86  inline ThermoRefPair
87  (
88  const objectRegistry& db,
89  const Pair<word>& phaseNames
90  );
91 
92 
93  // Member Functions
94 
95  //- Access the validity flags
96  inline const Pair<bool>& valid() const;
97 
98  //- Return if either validity flag is set
99  inline bool either() const;
100 
101  //- Return if both validity flags are set
102  inline bool both() const;
103 
104  //- Access the first thermo
105  inline const ThermoType& first() const;
106 
107  //- Access the second thermo
108  inline const ThermoType& second() const;
109 
110  //- Cast to a different thermo type, with error checking
111  template<class OtherThermoType>
113 
114  //- Cast to a different thermo type, with error checking
115  template<class OtherThermoType>
117  (
118  const Pair<bool> required,
119  const fvModel& model,
120  const word& thermoType
121  ) const;
122 
123 
124  // Member Operators
125 
126  //- Access a thermo by index
127  inline const ThermoType& operator[](const label i) const;
128 };
129 
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 } // End namespace Foam
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 #include "ThermoRefPairI.H"
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 #endif
142 
143 // ************************************************************************* //
Class containing a pair of thermo references. Handles down-casting to more specific thermo types by c...
Definition: ThermoRefPair.H:51
const Pair< bool > & valid() const
Access the validity flags.
const ThermoType & operator[](const label i) const
Access a thermo by index.
bool either() const
Return if either validity flag is set.
ThermoRefPair< OtherThermoType > thermos() const
Cast to a different thermo type, with error checking.
const ThermoType & first() const
Access the first thermo.
const ThermoType & second() const
Access the second thermo.
bool both() const
Return if both validity flags are set.
friend class ThermoRefPair
Declare friendship with other thermo reference pairs.
Definition: ThermoRefPair.H:79
Finite volume model abstract base class.
Definition: fvModel.H:60
Registry of regIOobjects.
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
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