fieldInfo.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) 2019-2021 OpenCFD Ltd.
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 Class
27  Foam::functionObjects::fieldInfo
28 
29 Description
30  Helper class to store a wordRe and label used by
31  Foam::functionObjects::fieldSelection
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef functionObjects_fieldInfo_H
36 #define functionObjects_fieldInfo_H
37 
38 #include "label.H"
39 #include "wordRes.H"
40 #include "Switch.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 namespace functionObjects
47 {
48 
49 // Forward Declarations
50 class fieldInfo;
51 Istream& operator>>(Istream&, fieldInfo&);
52 Ostream& operator<<(Ostream&, const fieldInfo&);
53 
54 /*---------------------------------------------------------------------------*\
55  Class fieldInfo Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class fieldInfo
59 {
60  // Pivate Data
61 
62  //- Pattern for the field name(s)
63  wordRe name_;
64 
65  //- Field component
66  label component_;
67 
68  //- Found
69  mutable Switch found_;
70 
71 
72 public:
73 
74  // Constructors
75 
76  //- Default construct
77  fieldInfo()
78  :
79  name_(),
80  component_(-1),
81  found_(false)
82  {}
83 
84 
85  //- Construct from components
86  fieldInfo(const wordRe& name, const label component = -1)
87  :
88  name_(name),
89  component_(component),
90  found_(false)
91  {}
92 
93  //- Construct from stream
94  fieldInfo(Istream& is)
95  :
96  name_(is),
97  component_(readLabel(is)),
98  found_(false)
99  {}
100 
101 
102  //- Destructor
103  ~fieldInfo() = default;
104 
105 
106  // Member Functions
107 
108  const wordRe& name() const
109  {
110  return name_;
111  }
112 
113  label component() const
114  {
115  return component_;
116  }
117 
118  Switch& found() const
119  {
120  return found_;
121  }
122 
123  friend bool operator==(const fieldInfo& a, const fieldInfo& b)
124  {
125  return
126  a.name_ == b.name_
127  && a.component_ == b.component_
128  && a.found_ == b.found_;
129  }
130 
131  friend bool operator!=(const fieldInfo& a, const fieldInfo& b)
132  {
133  return !(a == b);
134  }
135 
136 
137  // IOstream Operators
138 
139  friend Istream& operator>>(Istream& is, fieldInfo& fi)
140  {
141  is >> fi.name_ >> fi.component_ >> fi.found_;
142  return is;
143  }
144  friend Ostream& operator<<(Ostream& os, const fieldInfo& fi)
145  {
146  os << fi.name_ << ' ' << fi.component_ << ' ' << fi.found_;
147  return os;
148  }
149 };
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace functionObjects
155 } // End namespace Foam
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 #endif
160 
161 // ************************************************************************* //
wordRes.H
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Foam::functionObjects::fieldInfo::~fieldInfo
~fieldInfo()=default
Destructor.
Foam::functionObjects::fieldInfo::name
const wordRe & name() const
Definition: fieldInfo.H:107
Foam::functionObjects::fieldInfo::fieldInfo
fieldInfo(const wordRe &name, const label component=-1)
Construct from components.
Definition: fieldInfo.H:85
Foam::functionObjects::fieldInfo
Helper class to store a wordRe and label used by Foam::functionObjects::fieldSelection.
Definition: fieldInfo.H:57
Foam::functionObjects::fieldInfo::fieldInfo
fieldInfo(Istream &is)
Construct from stream.
Definition: fieldInfo.H:93
Foam::functionObjects::operator<<
Ostream & operator<<(Ostream &, const fieldInfo &)
Definition: fieldInfo.H:143
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:80
Foam::functionObjects::operator>>
Istream & operator>>(Istream &, fieldInfo &)
Definition: fieldInfo.H:138
Foam::functionObjects::fieldInfo::fieldInfo
fieldInfo()
Default construct.
Definition: fieldInfo.H:76
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::functionObjects::fieldInfo::operator!=
friend bool operator!=(const fieldInfo &a, const fieldInfo &b)
Definition: fieldInfo.H:130
Switch.H
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::fieldInfo::found
Switch & found() const
Definition: fieldInfo.H:117
Foam::functionObjects::fieldInfo::operator<<
friend Ostream & operator<<(Ostream &os, const fieldInfo &fi)
Definition: fieldInfo.H:143
label.H
Foam::readLabel
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition: label.H:66
Foam::functionObjects::fieldInfo::component
label component() const
Definition: fieldInfo.H:112
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::functionObjects::fieldInfo::operator==
friend bool operator==(const fieldInfo &a, const fieldInfo &b)
Definition: fieldInfo.H:122
Foam::functionObjects::fieldInfo::operator>>
friend Istream & operator>>(Istream &is, fieldInfo &fi)
Definition: fieldInfo.H:138