phaseInterfaceI.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) 2021-2025 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 #include "phaseInterface.H"
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
31 {
32  return phase1();
33 }
34 
35 
37 {
38  return phase2();
39 }
40 
41 
43 {
44  return phase1().fluidThermo();
45 }
46 
47 
49 {
50  return phase2().fluidThermo();
51 }
52 
53 
55 {
56  return phase1().rho();
57 }
58 
59 
61 {
62  return phase2().rho();
63 }
64 
65 
67 {
68  return phase1_;
69 }
70 
71 
73 {
74  return phase2_;
75 }
76 
77 
78 inline bool Foam::phaseInterface::contains(const phaseModel& phase) const
79 {
80  return &phase1_ == &phase || &phase2_ == &phase;
81 }
82 
83 
84 inline bool Foam::phaseInterface::operator==
85 (
86  const phaseInterface& interface
87 ) const
88 {
89  return same(interface, true);
90 }
91 
92 
93 inline bool Foam::phaseInterface::operator!=
94 (
95  const phaseInterface& interface
96 ) const
97 {
98  return !same(interface, true);
99 }
100 
101 
103 (
104  const phaseModel& phase
105 ) const
106 {
107  if (&phase1_ == &phase)
108  {
109  return phase2_;
110  }
111  else if (&phase2_ == &phase)
112  {
113  return phase1_;
114  }
115  else
116  {
118  << "this phaseInterface does not contain phase " << phase.name()
119  << exit(FatalError);
120 
121  return phase;
122  }
123 }
124 
125 
127 {
128  if (&phase1_ == &phase)
129  {
130  return 0;
131  }
132  else if (&phase2_ == &phase)
133  {
134  return 1;
135  }
136  else
137  {
139  << "this phaseInterface does not contain phase " << phase.name()
140  << exit(FatalError);
141 
142  return -1;
143  }
144 }
145 
146 
147 inline const Foam::phaseModel& Foam::phaseInterface::operator[]
148 (
149  const label index
150 ) const
151 {
152  switch (index)
153  {
154  case 0:
155  return phase1_;
156  case 1:
157  return phase2_;
158  default:
160  << "index out of range 0 ... 1" << exit(FatalError);
161  return NullObjectRef<phaseModel>();
162  }
163 }
164 
165 
167 {
168  return phase1().fluid();
169 }
170 
171 
173 {
174  return phase1().mesh();
175 }
176 
177 
178 // * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
179 
180 inline Foam::phaseInterface::const_iterator::const_iterator
181 (
182  const phaseInterface& interface,
183  const label index
184 )
185 :
186  interface_(interface),
187  index_(index)
188 {}
189 
190 
191 inline Foam::phaseInterface::const_iterator::const_iterator
192 (
193  const phaseInterface& interface
194 )
195 :
196  const_iterator(interface, 0)
197 {}
198 
199 
201 {
202  return index_;
203 }
204 
205 
206 inline bool Foam::phaseInterface::const_iterator::operator==
207 (
208  const const_iterator& iter
209 ) const
210 {
211  return (this->index_ == iter.index_);
212 }
213 
214 
215 inline bool Foam::phaseInterface::const_iterator::operator!=
216 (
217  const const_iterator& iter
218 ) const
219 {
220  return !(this->operator==(iter));
221 }
222 
223 
224 inline const Foam::phaseModel&
226 {
227  if (index_ == 0)
228  {
229  return interface_.phase1_;
230  }
231  else
232  {
233  return interface_.phase2_;
234  }
235 }
236 
237 
238 inline const Foam::phaseModel&
240 {
241  return operator*();
242 }
243 
244 
245 inline const Foam::phaseModel&
247 {
248  if (index_ == 0)
249  {
250  return interface_.phase2_;
251  }
252  else
253  {
254  return interface_.phase1_;
255  }
256 }
257 
258 
261 {
262  index_++;
263  return *this;
264 }
265 
266 
269 {
270  const_iterator old = *this;
271  this->operator++();
272  return old;
273 }
274 
275 
277 {
278  return const_iterator(*this);
279 }
280 
281 
283 {
284  return const_iterator(*this, 2);
285 }
286 
287 
289 {
290  return const_iterator(*this);
291 }
292 
293 
295 {
296  return const_iterator(*this, 2);
297 }
298 
299 
300 // ************************************************************************* //
Generic GeometricField class.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
const polyMesh & mesh() const
Return reference to polyMesh.
Definition: fvMesh.H:443
const phaseModel & operator*() const
const phaseModel & otherPhase() const
const phaseModel & operator()() const
label index() const
Return the current index.
Class to represent an interface between phases. Derivations can further specify the configuration of ...
const_iterator end() const
const_iterator set to beyond the end of the interface
const phaseSystem & fluid() const
Return the phase system.
const phaseModel & otherPhase(const phaseModel &phase) const
Return the other phase relative to the given phase.
virtual const rhoFluidThermo & thermo2() const
Return the thermo for phase 2.
const_iterator begin() const
const_iterator set to the beginning of the interface
virtual const rhoFluidThermo & thermo1() const
Return the thermo for phase 1.
const_iterator cend() const
const_iterator set to beyond the end of the interface
bool operator==(const phaseInterface &interface) const
Return true if the phase interfaces are the same.
virtual const volScalarField & rho2() const
Return the density of phase 2.
label index(const phaseModel &phase) const
Return the index of the given phase. Generates a FatalError if.
const_iterator cbegin() const
const_iterator set to the beginning of the interface
const fvMesh & mesh() const
Return the mesh.
bool contains(const phaseModel &phase) const
Return true if this phaseInterface contains the given phase.
virtual const volScalarField & rho1() const
Return the density of phase 1.
virtual const volScalarField & alpha2() const
Return the volume fraction of phase 2.
const phaseModel & phase1() const
Return phase 1.
const phaseModel & phase2() const
Return phase 2.
virtual const volScalarField & alpha1() const
Return the volume fraction of phase 1.
const word & name() const
Return the name of this phase.
Definition: phaseModel.C:145
Class to represent a system of phases.
Definition: phaseSystem.H:74
Base-class for fluid thermodynamic properties based on density.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
tmp< fvMatrix< Type > > operator*(const volScalarField::Internal &, const fvMatrix< Type > &)
error FatalError