phasePairKey.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) 2014-2016 OpenFOAM Foundation
9 Copyright (C) 2017-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::phasePairKey
29
30Description
31 An ordered or unorder pair of phase names.
32 Typically specified as follows.
33 \verbatim
34 (phase1 and phase2) // unordered
35 (phase1 in phase2) // ordered
36 \endverbatim
37
38SourceFiles
39 phasePairKey.C
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef phasePairKey_H
44#define phasePairKey_H
45
46#include "Pair.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52
53// Forward Declarations
54class phasePairKey;
55
56bool operator==(const phasePairKey& a, const phasePairKey& b);
57bool operator!=(const phasePairKey& a, const phasePairKey& b);
58
59Istream& operator>>(Istream& is, phasePairKey& key);
60Ostream& operator<<(Ostream& os, const phasePairKey& key);
61
62/*---------------------------------------------------------------------------*\
63 Class phasePairKey Declaration
64\*---------------------------------------------------------------------------*/
65
66class phasePairKey
67:
68 public Pair<word>
69{
70 // Private Data
71
72 //- Flag to indicate whether ordering is important
73 bool ordered_;
74
75
76public:
77
78 // Constructors
79
80 //- Default construct
81 phasePairKey() = default;
82
83 //- Construct from names and (optional) ordering flag
85 (
86 const word& name1,
87 const word& name2,
88 const bool ordered = false
89 );
90
91
92 //- Destructor
93 virtual ~phasePairKey() = default;
94
95
96 // Member Functions
97
98 //- Return the ordered flag
99 bool ordered() const noexcept
100 {
101 return ordered_;
102 }
103
104
105 // Friend Operators
106
107 //- Test for equality
108 friend bool operator==(const phasePairKey& a, const phasePairKey& b);
109
110 //- Test for inequality
111 friend bool operator!=(const phasePairKey& a, const phasePairKey& b);
112
113 //- Read from Istream
114 friend Istream& operator>>(Istream& is, phasePairKey& key);
115
116 //- Write to Ostream
117 friend Ostream& operator<<(Ostream& os, const phasePairKey& key);
118
119
120 // Hashing
121
122 //- Hashing functor for phasePairKey
123 struct hasher
125 unsigned operator()(const phasePairKey& key) const
126 {
127 if (key.ordered())
128 {
129 return Pair<word>::hasher()(key);
130 }
131 else
132 {
133 return Pair<word>::symmHasher()(key);
134 }
135 }
136 };
137
138 //- Alternative name for functor
140};
141
142
143// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144
145//- Hashing for phasePairKey
146template<> struct Hash<phasePairKey> : phasePairKey::hasher {};
147
148
149// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150
151} // End namespace Foam
152
153// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154
155#endif
156
157// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
An ordered or unorder pair of phase names. Typically specified as follows.
Definition: phasePairKey.H:68
friend Ostream & operator<<(Ostream &os, const phasePairKey &key)
Write to Ostream.
bool ordered() const noexcept
Return the ordered flag.
Definition: phasePairKey.H:98
phasePairKey(const word &name1, const word &name2, const bool ordered=false)
Construct from names and (optional) ordering flag.
friend Istream & operator>>(Istream &is, phasePairKey &key)
Read from Istream.
friend bool operator==(const phasePairKey &a, const phasePairKey &b)
Test for equality.
phasePairKey()=default
Default construct.
friend bool operator!=(const phasePairKey &a, const phasePairKey &b)
Test for inequality.
virtual ~phasePairKey()=default
Destructor.
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
bool operator!=(const eddy &a, const eddy &b)
Definition: eddy.H:239
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Istream & operator>>(Istream &, directionInfo &)
const direction noexcept
Definition: Scalar.H:223
volScalarField & b
Definition: createFields.H:27
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...
Definition: Hash.H:54
Hashing functor for PackedList.
Definition: PackedList.H:533
Symmetric hashing functor for Pair, hashes lower value first.
Definition: Pair.H:152
Hashing functor for phasePairKey.
Definition: phasePairKey.H:123
unsigned operator()(const phasePairKey &key) const
Definition: phasePairKey.H:124