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-2020 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 inline const Foam::fvMesh& Foam::phasePair::mesh() const
98 {
99  return phase1_.mesh();
100 }
101 
102 
103 // * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
104 
105 inline Foam::phasePair::const_iterator::const_iterator
106 (
107  const phasePair& pair,
108  const label index
109 )
110 :
111  pair_(pair),
112  index_(index)
113 {}
114 
115 
116 inline Foam::phasePair::const_iterator::const_iterator(const phasePair& pair)
117 :
118  const_iterator(pair, 0)
119 {}
120 
121 
123 {
124  return index_;
125 }
126 
127 
128 inline bool Foam::phasePair::const_iterator::operator==
129 (
130  const const_iterator& iter
131 ) const
132 {
133  return (this->index_ == iter.index_);
134 }
135 
136 
137 inline bool Foam::phasePair::const_iterator::operator!=
138 (
139  const const_iterator& iter
140 ) const
141 {
142  return !(this->operator==(iter));
143 }
144 
145 
146 inline const Foam::phaseModel&
148 {
149  if (index_ == 0)
150  {
151  return pair_.phase1_;
152  }
153  else
154  {
155  return pair_.phase2_;
156  }
157 }
158 
159 
160 inline const Foam::phaseModel&
162 {
163  return operator*();
164 }
165 
166 
167 inline const Foam::phaseModel&
169 {
170  if (index_ == 0)
171  {
172  return pair_.phase2_;
173  }
174  else
175  {
176  return pair_.phase1_;
177  }
178 }
179 
180 
183 {
184  index_++;
185  return *this;
186 }
187 
188 
191 {
192  const_iterator old = *this;
193  this->operator++();
194  return old;
195 }
196 
197 
199 {
200  return const_iterator(*this);
201 }
202 
203 
205 {
206  return const_iterator(*this, 2);
207 }
208 
209 
211 {
212  return const_iterator(*this);
213 }
214 
215 
217 {
218  return const_iterator(*this, 2);
219 }
220 
221 
222 // ************************************************************************* //
STL const_iterator.
Definition: phasePair.H:181
const phaseModel & operator*() const
Definition: phasePairI.H:147
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:323
const phaseModel & phase1() const
Return phase 1.
Definition: phasePairI.H:28
bool operator==(const const_iterator &) const
Definition: phasePairI.H:129
const word & name() const
Definition: phaseModel.H:110
const phaseModel & operator()() const
Definition: phasePairI.H:161
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:198
const_iterator & operator++()
Definition: phasePairI.H:182
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:204
const Mesh & mesh() const
Return mesh.
label index() const
Return the current index.
Definition: phasePairI.H:122
const_iterator end() const
const_iterator set to beyond the end of the pair
Definition: phasePairI.H:216
const fvMesh & mesh() const
Return the mesh.
Definition: phasePairI.H:97
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:168
const_iterator begin() const
const_iterator set to the beginning of the pair
Definition: phasePairI.H:210
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
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