All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cellZone.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 
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 
61 (
62  const word& name,
63  labelList&& addr,
64  const label index,
65  const cellZoneMesh& zm
66 )
67 :
68  zone(name, move(addr), index),
69  zoneMesh_(zm)
70 {}
71 
72 
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 
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 
100 (
101  const cellZone& cz,
102  labelList&& addr,
103  const label index,
104  const cellZoneMesh& zm
105 )
106 :
107  zone(cz, move(addr), index),
108  zoneMesh_(zm)
109 {}
110 
111 
112 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
113 
115 {}
116 
117 
118 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119 
120 Foam::label Foam::cellZone::whichCell(const label globalCellID) const
121 {
122  return zone::localID(globalCellID);
123 }
124 
125 
127 {
128  return zoneMesh_;
129 }
130 
131 
132 bool Foam::cellZone::checkDefinition(const bool report) const
133 {
134  return zone::checkDefinition(zoneMesh_.mesh().nCells(), report);
135 }
136 
137 
139 {
140  os << nl << name() << nl << token::BEGIN_BLOCK << nl
141  << " type " << type() << token::END_STATEMENT << nl;
142 
143  writeEntry(os, this->labelsName, *this);
144 
145  os << token::END_BLOCK << endl;
146 }
147 
148 
149 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
150 
152 {
153  clearAddressing();
154  zone::operator=(zn);
155 }
156 
157 
159 {
160  clearAddressing();
161  zone::operator=(move(zn));
162 }
163 
164 
166 {
167  clearAddressing();
168  zone::operator=(addr);
169 }
170 
171 
173 {
174  clearAddressing();
175  zone::operator=(move(addr));
176 }
177 
178 
179 // ************************************************************************* //
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: cellZone.C:138
label whichCell(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: cellZone.C:120
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:126
void operator=(const cellZone &)
Assignment to zone, clearing demand-driven data.
Definition: cellZone.C:151
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual ~cellZone()
Destructor.
Definition: cellZone.C:114
cellZone(const word &name, const labelUList &addr, const label index, const cellZoneMesh &)
Construct from components.
Definition: cellZone.C:48
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: cellZone.C:132
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:60
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
static const char nl
Definition: Ostream.H:260
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
A subset of mesh cells.
Definition: cellZone.H:61
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Template functions to aid in the implementation of demand driven data.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: cellZone.H:79
void operator=(const zone &)
Assignment operator.
Definition: zone.C:242
Namespace for OpenFOAM.