twoPhases.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) 2022 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 Class
25  Foam::twoPhases
26 
27 Description
28  Interface to two phases
29 
30 SourceFiles
31  twoPhases.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef twoPhases_H
36 #define twoPhases_H
37 
38 #include "volFields.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class twoPhases Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 class twoPhases
50 {
51 public:
52 
53  //- Runtime type information
54  TypeName("twoPhases");
55 
56 
57  // Constructors
58 
59  //- Default construct
60  twoPhases()
61  {}
62 
63 
64  //- Destructor
65  virtual ~twoPhases()
66  {}
67 
68 
69  // Member Functions
70 
71  //- Access the mesh
72  const fvMesh& mesh() const
73  {
74  return alpha1().mesh();
75  }
76 
77  //- Return the index associated with a given phase name
78  inline bool index(const word& name) const
79  {
80  if (alpha1().group() == name)
81  {
82  return false;
83  }
84 
85  if (alpha2().group() == name)
86  {
87  return true;
88  }
89 
91  << "Index of phase " << name << " requested from phases"
92  << alpha1().group() << " and " << alpha2().group()
93  << exit(FatalError);
94  return false;
95  }
96 
97  //- Return the volume-fraction of phase 1
98  virtual const volScalarField& alpha1() const = 0;
99 
100  //- Return the volume-fraction of phase 2
101  virtual const volScalarField& alpha2() const = 0;
102 
103  //- Return the volume-fraction of a given phase
104  const volScalarField& alpha(const bool index) const
105  {
106  return index ? alpha2() : alpha1();
107  }
108 };
109 
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 } // End namespace Foam
114 
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116 
117 #endif
118 
119 // ************************************************************************* //
const Mesh & mesh() const
Return mesh.
Generic GeometricField class.
static word group(const word &name)
Return group (extension part of name)
Definition: IOobject.C:134
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Interface to two phases.
Definition: twoPhases.H:49
virtual ~twoPhases()
Destructor.
Definition: twoPhases.H:64
const fvMesh & mesh() const
Access the mesh.
Definition: twoPhases.H:71
virtual const volScalarField & alpha1() const =0
Return the volume-fraction of phase 1.
twoPhases()
Default construct.
Definition: twoPhases.H:59
bool index(const word &name) const
Return the index associated with a given phase name.
Definition: twoPhases.H:77
TypeName("twoPhases")
Runtime type information.
const volScalarField & alpha(const bool index) const
Return the volume-fraction of a given phase.
Definition: twoPhases.H:103
virtual const volScalarField & alpha2() const =0
Return the volume-fraction of phase 2.
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const char *const group
Group name for atomic constants.
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
error FatalError