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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011 OpenFOAM Foundation
9  Copyright (C) 2017-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "cellZone.H"
31 #include "cellZoneMesh.H"
32 #include "polyMesh.H"
33 #include "primitiveMesh.H"
34 #include "IOstream.H"
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  defineTypeNameAndDebug(cellZone, 0);
41  defineRunTimeSelectionTable(cellZone, dictionary);
42  addToRunTimeSelectionTable(cellZone, cellZone, dictionary);
43 }
44 
45 const char * const Foam::cellZone::labelsName = "cellLabels";
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
50 Foam::cellZone::cellZone
51 (
52  const word& name,
53  const label index,
54  const cellZoneMesh& zm
55 )
56 :
57  zone(name, index),
58  zoneMesh_(zm)
59 {}
60 
61 
62 Foam::cellZone::cellZone
63 (
64  const word& name,
65  const labelUList& addr,
66  const label index,
67  const cellZoneMesh& zm
68 )
69 :
70  zone(name, addr, index),
71  zoneMesh_(zm)
72 {}
73 
74 
75 Foam::cellZone::cellZone
76 (
77  const word& name,
78  labelList&& addr,
79  const label index,
80  const cellZoneMesh& zm
81 )
82 :
83  zone(name, std::move(addr), index),
84  zoneMesh_(zm)
85 {}
86 
87 
88 Foam::cellZone::cellZone
89 (
90  const word& name,
91  const dictionary& dict,
92  const label index,
93  const cellZoneMesh& zm
94 )
95 :
96  zone(name, dict, this->labelsName, index),
97  zoneMesh_(zm)
98 {}
99 
100 
101 Foam::cellZone::cellZone
102 (
103  const cellZone& origZone,
104  const labelUList& addr,
105  const label index,
106  const cellZoneMesh& zm
107 )
108 :
109  zone(origZone, addr, index),
110  zoneMesh_(zm)
111 {}
112 
113 
114 Foam::cellZone::cellZone
115 (
116  const cellZone& origZone,
117  labelList&& addr,
118  const label index,
119  const cellZoneMesh& zm
120 )
121 :
122  zone(origZone, std::move(addr), index),
123  zoneMesh_(zm)
124 {}
125 
126 
127 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
128 
129 Foam::label Foam::cellZone::whichCell(const label globalCellID) const
130 {
131  return zone::localID(globalCellID);
132 }
133 
134 
135 bool Foam::cellZone::checkDefinition(const bool report) const
136 {
137  return zone::checkDefinition(zoneMesh_.mesh().nCells(), report);
138 }
139 
140 
142 {
143  os.beginBlock(name());
144 
145  os.writeEntry("type", type());
147  writeEntry(this->labelsName, os);
148 
149  os.endBlock();
150 }
151 
152 
153 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
154 
156 {
157  clearAddressing();
159 }
160 
161 
163 {
164  clearAddressing();
165  labelList::operator=(addr);
166 }
167 
168 
170 {
171  clearAddressing();
172  labelList::transfer(addr);
173 }
174 
175 
176 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
177 
178 Foam::Ostream& Foam::operator<<(Ostream& os, const cellZone& zn)
179 {
180  zn.write(os);
182  return os;
183 }
184 
185 
186 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
cellZoneMesh.H
Foam::cellZoneMesh.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::cellZone::writeDict
virtual void writeDict(Ostream &os) const
Definition: cellZone.C:134
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::cellZone::labelsName
static const char *const labelsName
Definition: cellZone.H:80
Foam::zone
Base class for mesh zones.
Definition: zone.H:59
primitiveMesh.H
Foam::Ostream::beginBlock
virtual Ostream & beginBlock(const keyType &kw)
Definition: Ostream.C:84
polyMesh.H
Foam::cellZone
A subset of mesh cells.
Definition: cellZone.H:58
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Definition: boundaryPatch.C:76
Foam::zone::write
virtual void write(Ostream &os) const
Definition: zone.C:201
Foam::cellZone::operator=
void operator=(const cellZone &zn)
Definition: cellZone.C:148
Foam::cellZone::whichCell
label whichCell(const label globalCellID) const
Definition: cellZone.C:122
Foam::List::transfer
void transfer(List< T > &list)
IOstream.H
Foam::ZoneMesh< cellZone, polyMesh >
Foam::List::operator=
void operator=(const UList< T > &a)
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::Ostream::endBlock
virtual Ostream & endBlock()
Definition: Ostream.C:102
Foam::IOstream::check
virtual bool check(const char *operation) const
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:119
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::Ostream::write
virtual bool write(const token &tok)=0
Foam
Definition: atmBoundaryLayer.C:26
Foam::zoneIdentifier::write
void write(Ostream &os) const
Definition: zoneIdentifier.C:88
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
cellZone.H
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Definition: POSIX.C:717
Foam::UList
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:99
Foam::zone::localID
label localID(const label globalID) const
Definition: zone.C:145
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:302
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Definition: Ostream.H:232
Foam::name
word name(const expressions::valueTypeCode typeCode)
Definition: exprTraits.C:52
Foam::cellZone::checkDefinition
virtual bool checkDefinition(const bool report=false) const
Definition: cellZone.C:128
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::zone::checkDefinition
virtual bool checkDefinition(const bool report=false) const =0