patchIdentifier.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) 2011-2013 OpenFOAM Foundation
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 "patchIdentifier.H"
29 #include "dictionary.H"
30 #include "ListOps.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
35 (
36  const word& name,
37  const label index,
38  const word& physicalType,
39  const wordList& inGroups
40 )
41 :
42  name_(name),
43  index_(index),
44  physicalType_(physicalType),
45  inGroups_(inGroups)
46 {}
47 
48 
50 (
51  const word& name,
52  const dictionary& dict,
53  const label index
54 )
55 :
56  name_(name),
57  index_(index)
58 {
59  dict.readIfPresent("physicalType", physicalType_);
60  dict.readIfPresent("inGroups", inGroups_);
61 }
62 
63 
65 (
66  const patchIdentifier& p,
67  const label index
68 )
69 :
70  name_(p.name_),
71  index_(index),
72  physicalType_(p.physicalType_),
73  inGroups_(p.inGroups_)
74 {}
75 
76 
77 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
78 
80 {
81  return inGroups_.found(name);
82 }
83 
84 
86 {
87  if (physicalType_.size())
88  {
89  os.writeEntry("physicalType", physicalType_);
90  }
91  if (inGroups_.size())
92  {
93  os.writeKeyword("inGroups");
94  // Write list with flatOutput
95  inGroups_.writeList(os, 0) << token::END_STATEMENT << nl;
96  }
97 }
98 
99 
100 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
101 
103 {
104  p.write(os);
105  os.check(FUNCTION_NAME);
106  return os;
107 }
108 
109 
110 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::patchIdentifier::patchIdentifier
patchIdentifier(const word &name, const label index, const word &physicalType=word::null, const wordList &inGroups=wordList())
Construct from components.
Definition: patchIdentifier.C:35
Foam::patchIdentifier
Identifies a patch by name, patch index and physical type.
Definition: patchIdentifier.H:57
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::patchIdentifier::inGroup
bool inGroup(const word &name) const
Check if the patch is in named group.
Definition: patchIdentifier.C:79
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::token::END_STATEMENT
End entry [isseparator].
Definition: token.H:116
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:51
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::Ostream::writeKeyword
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:57
patchIdentifier.H
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::List< word >
dictionary.H
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:261
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:219
Foam::patchIdentifier::write
void write(Ostream &os) const
Write patchIdentifier as a dictionary.
Definition: patchIdentifier.C:85
ListOps.H
Various functions to operate on Lists.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::patchIdentifier::name
const word & name() const
Return the patch name.
Definition: patchIdentifier.H:109
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102