cellZone.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 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 "cellZone.H"
28 #include "cellZoneMesh.H"
29 #include "polyMesh.H"
30 #include "primitiveMesh.H"
31 #include "IOstream.H"
32 #include "demandDrivenData.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(cellZone, 0);
39  defineRunTimeSelectionTable(cellZone, dictionary);
40  addToRunTimeSelectionTable(cellZone, cellZone, dictionary);
41 }
42 
43 const char * const Foam::cellZone::labelsName = "cellLabels";
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
47 Foam::cellZone::cellZone
48 (
49  const word& name,
50  const labelUList& addr,
51  const label index,
52  const cellZoneMesh& zm
53 )
54 :
55  zone(name, addr, index),
56  zoneMesh_(zm)
57 {}
58 
59 
60 Foam::cellZone::cellZone
61 (
62  const word& name,
63  const Xfer<labelList>& addr,
64  const label index,
65  const cellZoneMesh& zm
66 )
67 :
68  zone(name, addr, index),
69  zoneMesh_(zm)
70 {}
71 
72 
73 Foam::cellZone::cellZone
74 (
75  const word& name,
76  const dictionary& dict,
77  const label index,
78  const cellZoneMesh& zm
79 )
80 :
81  zone(name, dict, this->labelsName, index),
82  zoneMesh_(zm)
83 {}
84 
85 
86 Foam::cellZone::cellZone
87 (
88  const cellZone& cz,
89  const labelUList& addr,
90  const label index,
91  const cellZoneMesh& zm
92 )
93 :
94  zone(cz, addr, index),
95  zoneMesh_(zm)
96 {}
97 
98 Foam::cellZone::cellZone
99 (
100  const cellZone& cz,
101  const Xfer<labelList>& addr,
102  const label index,
103  const cellZoneMesh& zm
104 )
105 :
106  zone(cz, addr, index),
107  zoneMesh_(zm)
108 {}
109 
110 
111 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
112 
114 {}
115 
116 
117 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
118 
119 Foam::label Foam::cellZone::whichCell(const label globalCellID) const
120 {
121  return zone::localID(globalCellID);
122 }
123 
124 
126 {
127  return zoneMesh_;
128 }
129 
130 
131 bool Foam::cellZone::checkDefinition(const bool report) const
132 {
133  return zone::checkDefinition(zoneMesh_.mesh().nCells(), report);
134 }
135 
136 
138 {
139  os << nl << name() << nl << token::BEGIN_BLOCK << nl
140  << " type " << type() << token::END_STATEMENT << nl;
141 
142  writeEntry(this->labelsName, os);
143 
144  os << token::END_BLOCK << endl;
145 }
146 
147 
148 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
149 
151 {
152  clearAddressing();
154 }
155 
156 
158 {
159  clearAddressing();
160  labelList::operator=(addr);
161 }
162 
163 
165 {
166  clearAddressing();
167  labelList::operator=(addr);
168 }
169 
170 
171 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
172 
174 {
175  zn.write(os);
176  os.check("Ostream& operator<<(Ostream&, const cellZone&");
177  return os;
178 }
179 
180 
181 // ************************************************************************* //
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: cellZone.C:137
label whichCell(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: cellZone.C:119
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
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
label localID(const label globalID) const
Map storing the local index for every global index. Used to find.
Definition: zone.C:166
const cellZoneMesh & zoneMesh() const
Return zoneMesh reference.
Definition: cellZone.C:125
void operator=(const cellZone &)
Assign to zone, clearing demand-driven data.
Definition: cellZone.C:150
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
virtual ~cellZone()
Destructor.
Definition: cellZone.C:113
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: cellZone.C:131
Macros for easy insertion into run-time selection tables.
Foam::cellZoneMesh.
Base class for zones.
Definition: zone.H:57
A class for handling words, derived from string.
Definition: word.H:59
virtual bool checkDefinition(const bool report=false) const =0
Check zone definition. Return true if in error.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:61
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
static const char nl
Definition: Ostream.H:262
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
A subset of mesh cells.
Definition: cellZone.H:61
fileName::Type type(const fileName &, const bool followLink=true)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:485
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
void operator=(const UList< label > &)
Assignment to UList operator. Takes linear time.
Definition: List.C:376
Template functions to aid in the implementation of demand driven data.
Ostream & operator<<(Ostream &, const ensightPart &)
virtual void write(Ostream &) const
Write.
Definition: zone.C:233
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: cellZone.H:87
Namespace for OpenFOAM.