phasePairI.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) 2014-2018 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 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
27 
29 {
30  return phase1_;
31 }
32 
33 
35 {
36  return phase2_;
37 }
38 
39 
40 inline bool Foam::phasePair::contains(const phaseModel& phase) const
41 {
42  return &phase1_ == &phase || & phase2_ == &phase;
43 }
44 
45 
47 (
48  const phaseModel& phase
49 ) const
50 {
51  if (&phase1_ == &phase)
52  {
53  return phase2_;
54  }
55  else if (&phase2_ == &phase)
56  {
57  return phase1_;
58  }
59  else
60  {
62  << "this phasePair does not contain phase " << phase.name()
63  << exit(FatalError);
64 
65  return phase;
66  }
67 }
68 
69 
70 inline Foam::label Foam::phasePair::index(const phaseModel& phase) const
71 {
72  if (&phase1_ == &phase)
73  {
74  return 0;
75  }
76  else if (&phase2_ == &phase)
77  {
78  return 1;
79  }
80  else
81  {
83  << "this phasePair does not contain phase " << phase.name()
84  << exit(FatalError);
85 
86  return -1;
87  }
88 }
89 
90 
92 {
93  return g_;
94 }
95 
96 
97 // * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
98 
99 inline Foam::phasePair::const_iterator::const_iterator
100 (
101  const phasePair& pair,
102  const label index
103 )
104 :
105  pair_(pair),
106  index_(index)
107 {}
108 
109 
110 inline Foam::phasePair::const_iterator::const_iterator(const phasePair& pair)
111 :
112  const_iterator(pair, 0)
113 {}
114 
115 
117 {
118  return index_;
119 }
120 
121 
122 inline bool Foam::phasePair::const_iterator::operator==
123 (
124  const const_iterator& iter
125 ) const
126 {
127  return (this->index_ == iter.index_);
128 }
129 
130 
131 inline bool Foam::phasePair::const_iterator::operator!=
132 (
133  const const_iterator& iter
134 ) const
135 {
136  return !(this->operator==(iter));
137 }
138 
139 
140 inline const Foam::phaseModel&
142 {
143  if (index_ == 0)
144  {
145  return pair_.phase1_;
146  }
147  else
148  {
149  return pair_.phase2_;
150  }
151 }
152 
153 
154 inline const Foam::phaseModel&
156 {
157  return operator*();
158 }
159 
160 
161 inline const Foam::phaseModel&
163 {
164  if (index_ == 0)
165  {
166  return pair_.phase2_;
167  }
168  else
169  {
170  return pair_.phase1_;
171  }
172 }
173 
174 
177 {
178  index_++;
179  return *this;
180 }
181 
182 
185 {
186  const_iterator old = *this;
187  this->operator++();
188  return old;
189 }
190 
191 
193 {
194  return const_iterator(*this);
195 }
196 
197 
199 {
200  return const_iterator(*this, 2);
201 }
202 
203 
205 {
206  return const_iterator(*this);
207 }
208 
209 
211 {
212  return const_iterator(*this, 2);
213 }
214 
215 
216 // ************************************************************************* //
STL const_iterator.
Definition: phasePair.H:178
const phaseModel & operator*() const
Definition: phasePairI.H:141
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
const phaseModel & phase2() const
Return phase 2.
Definition: phasePairI.H:34
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
const phaseModel & phase1() const
Return phase 1.
Definition: phasePairI.H:28
bool operator==(const const_iterator &) const
Definition: phasePairI.H:123
const word & name() const
Definition: phaseModel.H:109
const phaseModel & operator()() const
Definition: phasePairI.H:155
label index(const phaseModel &phase) const
Return the index of the given phase. Generates a FatalError if.
Definition: phasePairI.H:70
const_iterator cbegin() const
const_iterator set to the beginning of the pair
Definition: phasePairI.H:192
const_iterator & operator++()
Definition: phasePairI.H:176
const uniformDimensionedVectorField & g() const
Return gravitation acceleration.
Definition: phasePairI.H:91
const_iterator cend() const
const_iterator set to beyond the end of the pair
Definition: phasePairI.H:198
label index() const
Return the current index.
Definition: phasePairI.H:116
const_iterator end() const
const_iterator set to beyond the end of the pair
Definition: phasePairI.H:210
const phaseModel & otherPhase(const phaseModel &phase) const
Return the other phase relative to the given phase.
Definition: phasePairI.H:47
const phaseModel & otherPhase() const
Definition: phasePairI.H:162
const_iterator begin() const
const_iterator set to the beginning of the pair
Definition: phasePairI.H:204
bool contains(const phaseModel &phase) const
Return true if this phasePair contains the given phase.
Definition: phasePairI.H:40
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
Definition: phaseModel.H:53