phasePairKey.C
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-2015 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
27\*---------------------------------------------------------------------------*/
28
29#include "phasePairKey.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
34(
35 const word& name1,
36 const word& name2,
37 const bool ordered
38)
39:
40 Pair<word>(name1, name2),
41 ordered_(ordered)
42{}
43
44
45// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
46
47bool Foam::operator==
48(
49 const phasePairKey& a,
50 const phasePairKey& b
51)
52{
53 const int cmp = Pair<word>::compare(a, b);
54 return
55 (
56 (a.ordered() == b.ordered())
57 && (a.ordered() ? (cmp == 1) : cmp)
58 );
59}
60
61
62bool Foam::operator!=
63(
64 const phasePairKey& a,
65 const phasePairKey& b
66)
67{
68 return !(a == b);
69}
70
71
72// * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * * //
73
75{
76 const FixedList<word, 3> toks(is);
77
78 key.first() = toks[0];
79 key.second() = toks[2];
80 const word& order = toks[1];
81
82 if (order == "to")
83 {
84 key.ordered_ = true;
85 }
86 else if (order == "and")
87 {
88 key.ordered_ = false;
89 }
90 else
91 {
93 << "Phase pair type is not recognised. " << toks
94 << "Use (phaseDispersed to phaseContinuous) for an ordered pair,"
95 " or (phase1 and phase2) for an unordered pair.\n"
96 << exit(FatalError);
97 }
98
99 return is;
100}
101
102
103// * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * * //
104
106{
108 << key.first()
109 << token::SPACE
110 << (key.ordered() ? "to" : "and")
111 << token::SPACE
112 << key.second()
114
115 return os;
116}
117
118
119// ************************************************************************* //
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: FixedList.H:81
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 pair of two objects of type <T> with first() and second() elements.
Definition: Pair.H:69
static int compare(const Pair< T > &a, const Pair< T > &b)
Compare Pairs.
Definition: PairI.H:31
An ordered or unorder pair of phase names. Typically specified as follows.
Definition: phasePairKey.H:68
bool ordered() const noexcept
Return the ordered flag.
Definition: phasePairKey.H:98
phasePairKey()=default
Default construct.
@ BEGIN_LIST
Begin list [isseparator].
Definition: token.H:155
@ END_LIST
End list [isseparator].
Definition: token.H:156
@ SPACE
Space [isspace].
Definition: token.H:125
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
volScalarField & b
Definition: createFields.H:27