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-2018 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 #include "demandDrivenData.H"
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41  defineTypeNameAndDebug(cellZone, 0);
42  defineRunTimeSelectionTable(cellZone, dictionary);
43  addToRunTimeSelectionTable(cellZone, cellZone, dictionary);
44 }
45 
46 const char * const Foam::cellZone::labelsName = "cellLabels";
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
52 (
53  const word& name,
54  const label index,
55  const cellZoneMesh& zm
56 )
57 :
58  zone(name, index),
59  zoneMesh_(zm)
60 {}
61 
62 
64 (
65  const word& name,
66  const labelUList& addr,
67  const label index,
68  const cellZoneMesh& zm
69 )
70 :
71  zone(name, addr, index),
72  zoneMesh_(zm)
73 {}
74 
75 
77 (
78  const word& name,
79  labelList&& addr,
80  const label index,
81  const cellZoneMesh& zm
82 )
83 :
84  zone(name, std::move(addr), index),
85  zoneMesh_(zm)
86 {}
87 
88 
90 (
91  const word& name,
92  const dictionary& dict,
93  const label index,
94  const cellZoneMesh& zm
95 )
96 :
97  zone(name, dict, this->labelsName, index),
98  zoneMesh_(zm)
99 {}
100 
101 
103 (
104  const cellZone& origZone,
105  const labelUList& addr,
106  const label index,
107  const cellZoneMesh& zm
108 )
109 :
110  zone(origZone, addr, index),
111  zoneMesh_(zm)
112 {}
113 
114 
116 (
117  const cellZone& origZone,
118  labelList&& addr,
119  const label index,
120  const cellZoneMesh& zm
121 )
122 :
123  zone(origZone, std::move(addr), index),
124  zoneMesh_(zm)
125 {}
126 
127 
128 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
129 
130 Foam::label Foam::cellZone::whichCell(const label globalCellID) const
131 {
132  return zone::localID(globalCellID);
133 }
134 
135 
137 {
138  return zoneMesh_;
139 }
140 
141 
142 bool Foam::cellZone::checkDefinition(const bool report) const
143 {
144  return zone::checkDefinition(zoneMesh_.mesh().nCells(), report);
145 }
146 
147 
149 {
150  os << nl << name() << nl << token::BEGIN_BLOCK << nl
151  << " type " << type() << token::END_STATEMENT << nl;
152 
153  writeEntry(this->labelsName, os);
154 
155  os << token::END_BLOCK << endl;
156 }
157 
158 
159 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
160 
162 {
163  clearAddressing();
165 }
166 
167 
169 {
170  clearAddressing();
171  labelList::operator=(addr);
172 }
173 
174 
176 {
177  clearAddressing();
178  labelList::transfer(addr);
179 }
180 
181 
182 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
183 
185 {
186  zn.write(os);
187  os.check(FUNCTION_NAME);
188  return os;
189 }
190 
191 
192 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
cellZoneMesh.H
Foam::cellZoneMesh.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::cellZone::writeDict
virtual void writeDict(Ostream &os) const
Write dictionary.
Definition: cellZone.C:148
Foam::cellZone::cellZone
cellZone(const cellZone &)=delete
No copy construct.
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::cellZone::labelsName
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: cellZone.H:85
Foam::zone
Base class for mesh zones.
Definition: zone.H:63
primitiveMesh.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
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:228
Foam::cellZone::zoneMesh
const cellZoneMesh & zoneMesh() const
Return zoneMesh reference.
Definition: cellZone.C:136
Foam::cellZone::operator=
void operator=(const cellZone &zn)
Assign to zone, clearing demand-driven data.
Definition: cellZone.C:161
Foam::cellZone::whichCell
label whichCell(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: cellZone.C:130
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::List< label >::transfer
void transfer(List< label > &list)
Definition: List.C:459
IOstream.H
Foam::ZoneMesh< cellZone, polyMesh >
Foam::List< label >::operator=
void operator=(const UList< label > &a)
Assignment to UList operator. Takes linear time.
Definition: List.C:501
Foam::token::END_STATEMENT
End entry [isseparator].
Definition: token.H:121
Foam::token::END_BLOCK
End block [isseparator].
Definition: token.H:127
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
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:121
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::token::BEGIN_BLOCK
Begin block [isseparator].
Definition: token.H:126
Foam::nl
constexpr char nl
Definition: Ostream.H:385
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
Map storing the local index for every global index. Used to find.
Definition: zone.C:172
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:270
Foam::cellZone::checkDefinition
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: cellZone.C:142
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.