zoneIdentifier.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) 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 \*---------------------------------------------------------------------------*/
27 
28 #include "zoneIdentifier.H"
29 #include "dictionary.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 :
35  name_(),
36  index_(0)
37 {}
38 
39 
41 (
42  const word& name,
43  const label index
44 )
45 :
46  name_(name),
47  index_(index)
48 {}
49 
50 
52 (
53  const word& name,
54  const label index,
55  const word& physicalType,
56  const wordList& inGroups
57 )
58 :
59  name_(name),
60  index_(index),
61  physicalType_(physicalType),
62  inGroups_(inGroups)
63 {}
64 
65 
67 (
68  const word& name,
69  const dictionary& dict,
70  const label index
71 )
72 :
73  zoneIdentifier(name, index)
74 {
75  dict.readIfPresent("physicalType", physicalType_);
76  dict.readIfPresent("inGroups", inGroups_);
77 }
78 
79 
81 (
82  const zoneIdentifier& ident,
83  const label index
84 )
85 :
86  name_(ident.name_),
87  index_(index),
88  physicalType_(ident.physicalType_),
89  inGroups_(ident.inGroups_)
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
96 {
97  if (!physicalType_.empty())
98  {
99  os.writeEntry("physicalType", physicalType_);
100  }
101 
102  if (!inGroups_.empty())
103  {
104  os.writeKeyword("inGroups");
105  // Flat output of list
106  inGroups_.writeList(os, 0) << token::END_STATEMENT << nl;
107  }
108 }
109 
110 
111 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
112 
113 Foam::Ostream& Foam::operator<<(Ostream& os, const zoneIdentifier& ident)
114 {
115  ident.write(os);
117  return os;
118 }
119 
120 
121 // ************************************************************************* //
Foam::zoneIdentifier::zoneIdentifier
zoneIdentifier()
Definition: zoneIdentifier.C:26
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
zoneIdentifier.H
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Definition: boundaryPatch.C:76
Foam::token::END_STATEMENT
@ END_STATEMENT
End entry [isseparator].
Definition: token.H:150
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::IOstream::check
virtual bool check(const char *operation) const
Definition: IOstream.C:51
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
os
OBJstream os(runTime.globalPath()/outputName)
Foam::Ostream::write
virtual bool write(const token &tok)=0
Foam::Ostream::writeKeyword
virtual Ostream & writeKeyword(const keyType &kw)
Definition: Ostream.C:50
Foam::nl
constexpr char nl
Definition: Ostream.H:424
Foam::zoneIdentifier::write
void write(Ostream &os) const
Definition: zoneIdentifier.C:88
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
dictionary.H
Foam::zoneIdentifier
Identifies a mesh zone by name and index, with optional physical type and group information.
Definition: zoneIdentifier.H:53
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:302
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Definition: Ostream.H:232
Foam::name
word name(const expressions::valueTypeCode typeCode)
Definition: exprTraits.C:52
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:398