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
74Foam::Istream& Foam::operator>>(Istream& is, phasePairKey& key)
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 == "in")
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 in 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
105Foam::Ostream& Foam::operator<<(Ostream& os, const phasePairKey& key)
106{
107 os << token::BEGIN_LIST
108 << key.first()
109 << token::SPACE
110 << (key.ordered() ? "in" : "and")
111 << token::SPACE
112 << key.second()
113 << token::END_LIST;
114
115 return os;
116}
117
118
119// ************************************************************************* //
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
phasePairKey()=default
Default construct.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:108
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
volScalarField & b
Definition: createFields.H:27