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 
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:65
Foam::cellZone::writeDict
virtual void writeDict(Ostream &os) const
Write dictionary.
Definition: cellZone.C:141
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::cellZone::labelsName
static const char *const labelsName
Definition: cellZone.H:84
Foam::zone
Base class for mesh zones.
Definition: zone.H:63
primitiveMesh.H
Foam::Ostream::beginBlock
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Definition: Ostream.C:91
polyMesh.H
Foam::cellZone
A subset of mesh cells.
Definition: cellZone.H:62
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::zone::write
virtual void write(Ostream &os) const
Write.
Definition: zone.C:208
Foam::cellZone::operator=
void operator=(const cellZone &zn)
Assign addressing, clearing demand-driven data.
Definition: cellZone.C:155
Foam::cellZone::whichCell
label whichCell(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: cellZone.C:129
Foam::List::transfer
void transfer(List< T > &list)
Definition: List.C:456
IOstream.H
Foam::ZoneMesh< cellZone, polyMesh >
Foam::List::operator=
void operator=(const UList< T > &a)
Assignment to UList operator. Takes linear time.
Definition: List.C:498
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::Ostream::endBlock
virtual Ostream & endBlock()
Write end block group.
Definition: Ostream.C:109
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::zoneIdentifier::write
void write(Ostream &os) const
Definition: zoneIdentifier.C:95
Foam::List< label >
cellZone.H
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::UList< label >
Foam::zone::localID
label localID(const label globalID) const
Lookup local address in zone for given global index.
Definition: zone.C:152
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:295
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:236
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::cellZone::checkDefinition
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: cellZone.C:135
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::zone::checkDefinition
virtual bool checkDefinition(const bool report=false) const =0
Check zone definition. Return true if in error.