volumeType.C
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-2013 OpenFOAM Foundation
9  Copyright (C) 2018-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 \*---------------------------------------------------------------------------*/
28 
29 #include "volumeType.H"
30 #include "dictionary.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 const Foam::Enum
35 <
37 >
39 ({
40  { volumeType::type::UNKNOWN, "unknown" },
41  { volumeType::type::INSIDE, "inside" },
42  { volumeType::type::OUTSIDE, "outside" },
44 });
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 (
51  const word& key,
52  const dictionary& dict,
53  const type deflt
54 )
55 :
56  t_(names.getOrDefault(key, dict, deflt))
57 {}
58 
59 
60 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
61 
62 const Foam::word& Foam::volumeType::str() const
63 {
64  return names[t_];
65 }
66 
67 
68 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
69 
70 Foam::Istream& Foam::operator>>(Istream& is, volumeType& vt)
71 {
72  int val;
73  is >> val;
74 
75  vt.t_ = static_cast<volumeType::type>(val);
76 
77  return is;
78 }
79 
80 
81 Foam::Ostream& Foam::operator<<(Ostream& os, const volumeType& vt)
82 {
83  os << static_cast<int>(vt.t_);
84 
85  return os;
86 }
87 
88 
89 // ************************************************************************* //
dictionary dict
type
Types of root.
Definition: Roots.H:52
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
type
Volume classification types.
Definition: volumeType.H:62
Mixed uniform/non-uniform (eg, after reduction)
Definition: ListPolicy.H:108
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
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
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: error.H:64
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
const word & str() const
The string representation of the volume type enumeration.
Definition: volumeType.C:55
static const Enum< volumeType::type > names
Names for the classification enumeration.
Definition: volumeType.H:75