surfZoneIOList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "surfZoneIOList.H"
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
33 }
34 
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
39 (
40  const IOobject& io
41 )
42 :
43  surfZoneList(),
44  regIOobject(io)
45 {
47  "surfZoneIOList::surfZoneIOList"
48  "(const IOobject& io)";
49 
50 
51  if
52  (
55  )
56  {
57  surfZoneList& zones = *this;
58 
59  Istream& is = readStream(typeName);
60 
61  PtrList<entry> dictEntries(is);
62  zones.setSize(dictEntries.size());
63 
64  label facei = 0;
65  forAll(zones, zoneI)
66  {
67  const dictionary& dict = dictEntries[zoneI].dict();
68 
69  label zoneSize = dict.lookup<label>("nFaces");
70  label startFacei = dict.lookup<label>("startFace");
71 
72  zones[zoneI] = surfZone
73  (
74  dictEntries[zoneI].keyword(),
75  zoneSize,
76  startFacei,
77  zoneI
78  );
79 
80  word geoType;
81  if (dict.readIfPresent("geometricType", geoType))
82  {
83  zones[zoneI].geometricType() = geoType;
84  }
85 
86  if (startFacei != facei)
87  {
89  << "surfZones are not ordered. Start of zone " << zoneI
90  << " does not correspond to sum of preceding zones." << nl
91  << "while reading " << objectPath() << endl
92  << exit(FatalError);
93  }
94 
95  facei += zoneSize;
96  }
97 
98  // Check state of IOstream
99  is.check(functionName.c_str());
100 
101  close();
102  }
103 }
104 
105 
107 (
108  const IOobject& io,
109  const surfZoneList& zones
110 )
111 :
112  surfZoneList(zones),
113  regIOobject(io)
114 {}
115 
116 
118 (
119  const IOobject& io,
120  surfZoneList&& zones
121 )
122 :
123  surfZoneList(move(zones)),
124  regIOobject(io)
125 {}
126 
127 
128 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
129 
131 {}
132 
133 
134 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
135 
136 
137 // writeData member function required by regIOobject
139 {
140  os << *this;
141  return os.good();
142 }
143 
144 
145 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
146 
148 {
149  os << L.size() << nl << token::BEGIN_LIST << incrIndent << nl;
150 
151  forAll(L, i)
152  {
153  L[i].writeDict(os);
154  }
155 
156  os << decrIndent << token::END_LIST;
157 
158  return os;
159 }
160 
161 
162 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:119
readOption readOpt() const
Definition: IOobject.H:360
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:330
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
void setSize(const label)
Reset size of List.
Definition: List.C:281
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
A functionName is a word starting with '#'.
Definition: functionName.H:60
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
fileName objectPath() const
Return complete path + object name.
Definition: regIOobject.H:159
void close()
Close Istream.
Istream & readStream(const word &, const bool read=true)
Return Istream and check object type against that given.
A class for handling character strings derived from std::string.
Definition: string.H:79
IOobject for a surfZoneList.
bool writeData(Ostream &) const
writeData member function required by regIOobject
~surfZoneIOList()
Destructor.
surfZoneIOList(const IOobject &)
Construct from IOobject.
A surface zone on a MeshedSurface.
Definition: surfZone.H:65
@ BEGIN_LIST
Definition: token.H:106
@ END_LIST
Definition: token.H:107
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
defineTypeNameAndDebug(combustionModel, 0)
error FatalError
Ostream & operator<<(Ostream &, const ensightPart &)
static const char nl
Definition: Ostream.H:260
dictionary dict