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 
114 {
115  ident.write(os);
117  return os;
118 }
119 
120 
121 // ************************************************************************* //
Foam::zoneIdentifier::zoneIdentifier
zoneIdentifier()
Default construct. Uses name="", index=0.
Definition: zoneIdentifier.C:33
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
zoneIdentifier.H
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::token::END_STATEMENT
End entry [isseparator].
Definition: token.H:154
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::Ostream::writeKeyword
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:57
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::zoneIdentifier::write
void write(Ostream &os) const
Definition: zoneIdentifier.C:95
Foam::List< word >
dictionary.H
Foam::zoneIdentifier
Identifies a mesh zone by name and index, with optional physical type and group information.
Definition: zoneIdentifier.H:57
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:295
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:236
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:405