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-------------------------------------------------------------------------------
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"
31#include "cellZoneMesh.H"
32#include "polyMesh.H"
33#include "primitiveMesh.H"
34#include "IOstream.H"
35
36// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37
38namespace Foam
39{
43}
44
45const char * const Foam::cellZone::labelsName = "cellLabels";
46
47
48// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49
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
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
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
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
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
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
129Foam::label Foam::cellZone::whichCell(const label globalCellID) const
130{
131 return zone::localID(globalCellID);
132}
133
134
135bool 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();
166}
167
168
170{
171 clearAddressing();
173}
174
175
176// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
177
179{
180 zn.write(os);
182 return os;
183}
184
185
186// ************************************************************************* //
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.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
void operator=(const UList< label > &a)
Assignment to UList operator. Takes linear time.
Definition: List.C:480
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
virtual Ostream & endBlock()
Write end block group.
Definition: Ostream.C:105
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:239
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Definition: Ostream.C:87
A subset of mesh cells.
Definition: cellZone.H:65
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: cellZone.C:135
void operator=(const cellZone &zn)
Assign addressing, clearing demand-driven data.
Definition: cellZone.C:155
label whichCell(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: cellZone.C:129
static const char *const labelsName
Definition: cellZone.H:84
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
virtual bool write()
Write the output fields.
Foam::dictionary writeDict() const
Write to dictionary.
A class for handling words, derived from Foam::string.
Definition: word.H:68
Base class for mesh zones.
Definition: zone.H:67
label localID(const label globalID) const
Lookup local address in zone for given global index.
Definition: zone.C:154
virtual void write(Ostream &os) const
Write.
Definition: zone.C:210
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
Namespace for OpenFOAM.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict