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 | Copyright (C) 2011-2013 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "patchIdentifier.H"
27 #include "dictionary.H"
28 #include "ListOps.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 (
34  const word& name,
35  const label index,
36  const word& physicalType,
37  const wordList& inGroups
38 )
39 :
40  name_(name),
41  index_(index),
42  physicalType_(physicalType),
43  inGroups_(inGroups)
44 {}
45 
46 
48 (
49  const word& name,
50  const dictionary& dict,
51  const label index
52 )
53 :
54  name_(name),
55  index_(index)
56 {
57  dict.readIfPresent("physicalType", physicalType_);
58  dict.readIfPresent("inGroups", inGroups_);
59 }
60 
61 
63 (
64  const patchIdentifier& p,
65  const label index
66 )
67 :
68  name_(p.name_),
69  index_(index),
70  physicalType_(p.physicalType_),
71  inGroups_(p.inGroups_)
72 {}
73 
74 
75 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
76 
78 {}
79 
80 
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 
83 bool Foam::patchIdentifier::inGroup(const word& name) const
84 {
85  return findIndex(inGroups_, name) != -1;
86 }
87 
88 
90 {
91  if (physicalType_.size())
92  {
93  os.writeKeyword("physicalType") << physicalType_
95  }
96  if (inGroups_.size())
97  {
98  os.writeKeyword("inGroups") << inGroups_
100  }
101 }
102 
103 
104 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
105 
107 {
108  pi.write(os);
109  os.check("Ostream& operator<<(Ostream&, const patchIdentifier&)");
110  return os;
111 }
112 
113 
114 // ************************************************************************* //
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
A class for handling words, derived from string.
Definition: word.H:59
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:59
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
virtual ~patchIdentifier()
Destructor.
Various functions to operate on Lists.
Identifies patch by name, patch index and physical type.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:133
void write(Ostream &) const
Write patchIdentifier as a dictionary.
patchIdentifier(const word &name, const label index, const word &physicalType=word::null, const wordList &inGroups=wordList())
Construct from components.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
static const char nl
Definition: Ostream.H:260
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
bool inGroup(const word &) const
Test if in group.