Loading...
Searching...
No Matches
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-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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"
30#include "cellZoneMesh.H"
31#include "polyMesh.H"
32#include "IOstream.H"
35// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36
37namespace Foam
38{
44// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45
47:
48 zone(),
49 zoneMesh_(zm)
50{}
51
52
54(
55 const word& name,
56 const label index,
57 const cellZoneMesh& zm
59:
60 zone(name, index),
61 zoneMesh_(zm)
62{}
63
64
66(
67 const word& name,
68 const labelUList& addr,
69 const label index,
70 const cellZoneMesh& zm
72:
73 zone(name, addr, index),
74 zoneMesh_(zm)
75{}
76
77
79(
80 const word& name,
81 labelList&& addr,
82 const label index,
83 const cellZoneMesh& zm
85:
86 zone(name, std::move(addr), index),
87 zoneMesh_(zm)
88{}
89
90
92(
93 const word& name,
94 const dictionary& dict,
95 const label index,
96 const cellZoneMesh& zm
98:
100 zoneMesh_(zm)
101{}
102
103
105(
106 const cellZone& originalZone,
107 const cellZoneMesh& zm,
108 const label newIndex
110:
111 zone(originalZone, newIndex),
112 zoneMesh_(zm)
113{}
114
115
117(
118 const cellZone& originalZone,
120 const cellZoneMesh& zm,
121 const label newIndex
123:
124 zone(originalZone, labelList(), newIndex),
125 zoneMesh_(zm)
126{}
127
128
130(
131 const cellZone& originalZone,
133 const label index,
134 const cellZoneMesh& zm
136:
137 zone(originalZone, labelList(), index),
138 zoneMesh_(zm)
139{}
140
141
143(
144 const cellZone& originalZone,
145 const labelUList& addr,
146 const label index,
147 const cellZoneMesh& zm
148)
150 cellZone(originalZone, Foam::zero{}, index, zm)
151{
153}
154
155
157(
158 const cellZone& originalZone,
159 labelList&& addr,
160 const label index,
161 const cellZoneMesh& zm
162)
163:
164 cellZone(originalZone, Foam::zero{}, index, zm)
167}
168
169
170// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
171
172Foam::label Foam::cellZone::max_index() const noexcept
173{
174 return zoneMesh_.mesh().nCells();
175}
176
177
178// void Foam::cellZone::sort()
179// {
180// clearAddressing();
181// Foam::sort(static_cast<labelList&>(*this));
182// }
183
184
186{
187 if (this == &zn)
188 {
189 return; // Self-assignment is a no-op
190 }
193 labelList::transfer(static_cast<labelList&>(zn));
194 zn.clearAddressing();
195}
196
197
199{
200 if (this == &zn)
201 {
202 return; // Self-assignment is a no-op
204
205 clearAddressing();
206 labelList::operator=(static_cast<const labelList&>(zn));
207}
208
209
215
216
222
223
225{
228}
229
230
231// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
232
234{
235 if (this == &zn)
236 {
237 return; // Self-assignment is a no-op
239
240 clearAddressing();
241 labelList::operator=(static_cast<const labelList&>(zn));
242}
243
244
246{
249}
250
251
253{
254 clearAddressing();
256}
257
258
259// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
260
261Foam::Ostream& Foam::operator<<(Ostream& os, const cellZone& zn)
262{
263 zn.write(os);
264 os.check(FUNCTION_NAME);
265 return os;
266}
267
268
269// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Foam::cellZoneMesh.
void transfer(List< label > &list)
void operator=(const UList< label > &list)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
void writeEntry(Ostream &os) const
A subset of mesh cells.
Definition cellZone.H:61
void operator=(const cellZone &zn)
Assign addressing, clearing demand-driven data.
Definition cellZone.C:226
static constexpr const char * labelsName()
The name associated with the zone-labels dictionary entry.
Definition cellZone.H:77
virtual void resetAddressing(cellZone &&zn)
Move reset addressing from another zone.
Definition cellZone.C:178
virtual void write(Ostream &os) const
Write (dictionary entries).
Definition cellZone.C:217
label max_index() const noexcept
The maximum index the zone may contain == mesh nCells().
Definition cellZone.C:165
cellZone(const cellZone &)=delete
No copy construct.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling words, derived from Foam::string.
Definition word.H:66
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
label index() const noexcept
The index of this zone in the zone list.
virtual void write(Ostream &os) const
Write (dictionary entries).
Definition zone.C:218
zone()
Default construct: empty zone with name="", index=0.
Definition zone.C:37
virtual void clearAddressing()
Clear addressing (remove lookup maps and other auxiliary information).
Definition zone.C:162
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with cellZone content on a polyMesh.
const direction noexcept
Definition scalarImpl.H:265
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
UList< label > labelUList
A UList of labels.
Definition UList.H:75
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict