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 // ************************************************************************* //
dictionary dict
zoneIdentifier()
Default construct. Uses name="", index=0.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:45
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Definition: UList.H:632
End entry [isseparator].
Definition: token.H:157
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
Definition: UListIO.C:72
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:52
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
void write(Ostream &os) const
Write (physicalType, inGroups) dictionary entries (without surrounding braces)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:76
Identifies a mesh zone by name and index, with optional physical type and group information.