volumeType.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) 2011-2014 OpenFOAM Foundation
9  Copyright (C) 2015-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::volumeType
29 
30 Description
31  An enumeration wrapper for classification of a location as being
32  inside/outside of a volume.
33 
34 SourceFiles
35  volumeType.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_volumeType_H
40 #define Foam_volumeType_H
41 
42 #include "contiguous.H"
43 #include "Enum.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward Declarations
51 class volumeType;
52 Istream& operator>>(Istream& is, volumeType& vt);
53 Ostream& operator<<(Ostream& os, const volumeType& vt);
54 
55 
56 /*---------------------------------------------------------------------------*\
57  Class volumeType Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class volumeType
61 {
62 public:
63 
64  //- Volume classification types
65  enum type : char
66  {
67  UNKNOWN = 0,
68  INSIDE = 0x1,
69  OUTSIDE = 0x2,
70  MIXED = 0x3
71  };
72 
73  // Static data
74 
75  //- Names for the classification enumeration
76  static const Enum<volumeType::type> names;
77 
78 
79 private:
80 
81  // Private data
82 
83  //- Volume type
84  type t_;
85 
86 
87 public:
88 
89  // Constructors
90 
91  //- Default construct as \c UNKNOWN state
92  constexpr volumeType() noexcept
93  :
94  t_(UNKNOWN)
95  {}
96 
97  //- Implicit construct from enumeration
99  :
100  t_(t)
101  {}
102 
103  //- Construct as getOrDefault by name from dictionary
104  volumeType(const word& key, const dictionary& dict, const type deflt);
105 
106  //- Construct from integer
107  explicit volumeType(const int t)
108  :
109  t_(static_cast<volumeType::type>(t & 0x3))
110  {}
111 
112 
113  // Member Functions
114 
115  //- Implicit cast to the enumeration
116  operator type() const noexcept
117  {
118  return t_;
119  }
120 
121  //- The string representation of the volume type enumeration
122  const word& str() const;
123 
124 
125  // IOstream Operators
126 
128  friend Ostream& operator<<(Ostream& os, const volumeType& vt);
129 };
130 
131 
132 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
133 
134 //- Contiguous data for volumeType
135 template<> struct is_contiguous<volumeType> : std::true_type {};
136 
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 } // End namespace Foam
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 #endif
145 
146 // ************************************************************************* //
dictionary dict
type
Volume classification types.
Definition: volumeType.H:62
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
An enumeration wrapper for classification of a location as being inside/outside of a volume...
Definition: volumeType.H:55
Unknown state.
Definition: volumeType.H:64
friend Ostream & operator<<(Ostream &os, const volumeType &vt)
friend Istream & operator>>(Istream &is, volumeType &vt)
A class for handling words, derived from Foam::string.
Definition: word.H:63
Istream & operator>>(Istream &, directionInfo &)
constexpr volumeType() noexcept
Default construct as UNKNOWN state.
Definition: volumeType.H:95
A location inside the volume.
Definition: volumeType.H:65
A location outside the volume.
Definition: volumeType.H:66
A location that is partly inside and outside.
Definition: volumeType.H:67
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
A template class to specify that a data type can be considered as being contiguous in memory...
Definition: contiguous.H:70
const word & str() const
The string representation of the volume type enumeration.
Definition: volumeType.C:55
Namespace for OpenFOAM.
static const Enum< volumeType::type > names
Names for the classification enumeration.
Definition: volumeType.H:75