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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::functionObjects::fieldInfo
28
29Description
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
44namespace Foam
45{
46namespace functionObjects
47{
48
49// Forward Declarations
50class fieldInfo;
51Istream& operator>>(Istream&, fieldInfo&);
52Ostream& operator<<(Ostream&, const fieldInfo&);
53
54/*---------------------------------------------------------------------------*\
55 Class fieldInfo Declaration
56\*---------------------------------------------------------------------------*/
58class 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
72public:
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
95 :
96 name_(is),
97 component_(readLabel(is)),
98 found_(false)
99 {}
100
101
102 //- Destructor
103 ~fieldInfo() = default;
104
105
106 // Member Functions
108 const wordRe& name() const
109 {
110 return name_;
111 }
113 label component() const
114 {
115 return component_;
116 }
118 Switch& found() const
119 {
120 return found_;
121 }
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 }
131 friend bool operator!=(const fieldInfo& a, const fieldInfo& b)
132 {
133 return !(a == b);
134 }
135
136
137 // IOstream Operators
139 friend Istream& operator>>(Istream& is, fieldInfo& fi)
140 {
141 is >> fi.name_ >> fi.component_ >> fi.found_;
142 return is;
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// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:78
Helper class to store a wordRe and label used by Foam::functionObjects::fieldSelection.
Definition: fieldInfo.H:58
friend bool operator==(const fieldInfo &a, const fieldInfo &b)
Definition: fieldInfo.H:122
fieldInfo(Istream &is)
Construct from stream.
Definition: fieldInfo.H:93
friend Ostream & operator<<(Ostream &os, const fieldInfo &fi)
Definition: fieldInfo.H:143
const wordRe & name() const
Definition: fieldInfo.H:107
friend bool operator!=(const fieldInfo &a, const fieldInfo &b)
Definition: fieldInfo.H:130
~fieldInfo()=default
Destructor.
fieldInfo(const wordRe &name, const label component=-1)
Construct from components.
Definition: fieldInfo.H:85
friend Istream & operator>>(Istream &is, fieldInfo &fi)
Definition: fieldInfo.H:138
fieldInfo()
Default construct.
Definition: fieldInfo.H:76
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:83
OBJstream os(runTime.globalPath()/outputName)
Istream & operator>>(Istream &, fieldInfo &)
Definition: fieldInfo.H:138
Ostream & operator<<(Ostream &, const fieldInfo &)
Definition: fieldInfo.H:143
Namespace for OpenFOAM.
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition: label.H:66
volScalarField & b
Definition: createFields.H:27