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-------------------------------------------------------------------------------
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
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// ************************************************************************* //
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:239
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:57
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
virtual bool write()
Write the output fields.
@ END_STATEMENT
End entry [isseparator].
Definition: token.H:154
A class for handling words, derived from Foam::string.
Definition: word.H:68
Identifies a mesh zone by name and index, with optional physical type and group information.
zoneIdentifier()
Default construct. Uses name="", index=0.
void write(Ostream &os) const
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:83
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict