phasePairI.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-2018 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 inline const Foam::phaseModel& Foam::phasePair::phase1() const
31 {
32  return phase1_;
33 }
34 
35 
36 inline const Foam::phaseModel& Foam::phasePair::phase2() const
37 {
38  return phase2_;
39 }
40 
41 
42 inline bool Foam::phasePair::contains(const phaseModel& phase) const
43 {
44  return &phase1_ == &phase || & phase2_ == &phase;
45 }
46 
47 
49 (
50  const phaseModel& phase
51 ) const
52 {
53  if (&phase1_ == &phase)
54  {
55  return phase2_;
56  }
57  else if (&phase2_ == &phase)
58  {
59  return phase1_;
60  }
61  else
62  {
64  << "this phasePair does not contain phase " << phase.name()
65  << exit(FatalError);
66 
67  return phase;
68  }
69 }
70 
71 
72 inline Foam::label Foam::phasePair::index(const phaseModel& phase) const
73 {
74  if (&phase1_ == &phase)
75  {
76  return 0;
77  }
78  else if (&phase2_ == &phase)
79  {
80  return 1;
81  }
82  else
83  {
85  << "this phasePair does not contain phase " << phase.name()
86  << exit(FatalError);
87 
88  return -1;
89  }
90 }
91 
92 
94 {
95  return g_;
96 }
97 
98 
99 // * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
100 
101 inline Foam::phasePair::const_iterator::const_iterator
102 (
103  const phasePair& pair,
104  const label index
105 )
106 :
107  pair_(pair),
108  index_(index)
109 {}
110 
111 
112 inline Foam::phasePair::const_iterator::const_iterator(const phasePair& pair)
113 :
114  const_iterator(pair, 0)
115 {}
116 
117 
118 inline Foam::label Foam::phasePair::const_iterator::index() const
119 {
120  return index_;
121 }
122 
123 
124 inline bool Foam::phasePair::const_iterator::operator==
125 (
126  const const_iterator& iter
127 ) const
128 {
129  return (this->index_ == iter.index_);
130 }
131 
132 
133 inline bool Foam::phasePair::const_iterator::operator!=
134 (
135  const const_iterator& iter
136 ) const
137 {
138  return !(this->operator==(iter));
139 }
140 
141 
142 inline const Foam::phaseModel&
144 {
145  if (index_ == 0)
146  {
147  return pair_.phase1_;
148  }
149  else
150  {
151  return pair_.phase2_;
152  }
153 }
154 
155 
156 inline const Foam::phaseModel&
158 {
159  return operator*();
160 }
161 
162 
163 inline const Foam::phaseModel&
165 {
166  if (index_ == 0)
167  {
168  return pair_.phase2_;
169  }
170  else
171  {
172  return pair_.phase1_;
173  }
174 }
175 
176 
179 {
180  index_++;
181  return *this;
182 }
183 
184 
187 {
188  const_iterator old = *this;
189  this->operator++();
190  return old;
191 }
192 
193 
195 {
196  return const_iterator(*this);
197 }
198 
199 
201 {
202  return const_iterator(*this, 2);
203 }
204 
205 
207 {
208  return const_iterator(*this);
209 }
210 
211 
213 {
214  return const_iterator(*this, 2);
215 }
216 
217 
218 // ************************************************************************* //
Foam::phaseModel
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
Definition: phaseModel.H:54
Foam::phasePair
Description for mass transfer between a pair of phases. The direction of the mass transfer is from th...
Definition: phasePair.H:53
Foam::phasePair::const_iterator::operator()
const phaseModel & operator()() const
Definition: phasePairI.H:157
Foam::phasePair::const_iterator
STL const_iterator.
Definition: phasePair.H:180
Foam::phase
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
Definition: phase.H:54
Foam::phasePair::cbegin
const_iterator cbegin() const
const_iterator set to the beginning of the pair
Definition: phasePairI.H:194
Foam::phasePair::index
label index(const phaseModel &phase) const
Return the index of the given phase. Generates a FatalError if.
Definition: phasePairI.H:72
Foam::phasePair::const_iterator::operator++
const_iterator & operator++()
Definition: phasePairI.H:178
Foam::phasePair::g
const uniformDimensionedVectorField & g() const
Return gravitation acceleration.
Definition: phasePairI.H:93
Foam::UniformDimensionedField< vector >
Foam::phasePair::const_iterator::operator*
const phaseModel & operator*() const
Definition: phasePairI.H:143
Foam::FatalError
error FatalError
Foam::phasePair::contains
bool contains(const phaseModel &phase) const
Return true if this phasePair contains the given phase.
Definition: phasePairI.H:42
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::phase::name
const word & name() const
Definition: phase.H:111
Foam::phasePair::const_iterator::index
label index() const
Return the current index.
Definition: phasePairI.H:118
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::phasePairKey::operator==
friend bool operator==(const phasePairKey &a, const phasePairKey &b)
Test for equality.
Foam::phasePair::cend
const_iterator cend() const
const_iterator set to beyond the end of the pair
Definition: phasePairI.H:200
Foam::operator*
tmp< faMatrix< Type > > operator*(const areaScalarField &, const faMatrix< Type > &)
Foam::phasePair::end
const_iterator end() const
const_iterator set to beyond the end of the pair
Definition: phasePairI.H:212
Foam::phasePair::phase2
const phaseModel & phase2() const
Definition: phasePairI.H:36
Foam::phasePair::const_iterator::otherPhase
const phaseModel & otherPhase() const
Definition: phasePairI.H:164
Foam::phasePair::phase1
const phaseModel & phase1() const
Definition: phasePairI.H:30
Foam::phasePair::otherPhase
const phaseModel & otherPhase(const phaseModel &phase) const
Return the other phase relative to the given phase.
Definition: phasePairI.H:49
Foam::phasePair::begin
const_iterator begin() const
const_iterator set to the beginning of the pair
Definition: phasePairI.H:206