surfZoneIOList.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-2016 OpenFOAM Foundation
9  Copyright (C) 2018-2020 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 "surfZoneIOList.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
36 }
37 
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
42 (
43  const IOobject& io
44 )
45 :
46  regIOobject(io),
47  surfZoneList()
48 {
49  if
50  (
53  )
54  {
55  surfZoneList& zones = *this;
56 
57  Istream& is = readStream(typeName);
58 
59  PtrList<entry> dictEntries(is);
60  zones.resize(dictEntries.size());
61 
62  label facei = 0;
63  forAll(zones, zonei)
64  {
65  zones[zonei] = surfZone
66  (
67  dictEntries[zonei].keyword(),
68  dictEntries[zonei].dict(),
69  zonei
70  );
71 
72  if (zones[zonei].start() != facei)
73  {
75  << "surfZones are not ordered. Start of zone " << zonei
76  << " does not correspond to sum of preceding zones." << nl
77  << "while reading " << io.objectPath() << endl
78  << exit(FatalError);
79  }
80 
81  facei += zones[zonei].size();
82  }
83 
85  close();
86  }
87 }
88 
89 
91 (
92  const IOobject& io,
93  const UList<surfZone>& content
94 )
95 :
96  regIOobject(io),
97  surfZoneList(content)
98 {}
99 
100 
102 (
103  const IOobject& io,
104  surfZoneList&& content
105 )
106 :
108  surfZoneList(std::move(content))
109 {}
110 
111 
112 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 
115 {
116  const surfZoneList& zones = *this;
117  const label sz = zones.size();
118 
119  if (sz)
120  {
121  os << sz << nl << token::BEGIN_LIST << incrIndent << nl;
122 
123  for (const surfZone& zn : zones)
124  {
125  zn.write(os);
126  }
127 
129  }
130  else
131  {
133  }
134 
135  return os.good();
136 }
137 
138 
139 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
140 
142 {
144 }
145 
146 
147 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
148 
149 Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIOList& zones)
150 {
151  zones.writeData(os);
152 
153  return os;
154 }
155 
156 
157 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:165
Foam::List::resize
void resize(const label len)
Definition: ListI.H:132
Foam::endl
Ostream & endl(Ostream &os)
Definition: Ostream.H:381
Foam::incrIndent
Ostream & incrIndent(Ostream &os)
Definition: Ostream.H:352
forAll
#define forAll(list, i)
Definition: stdFoam.H:349
Foam::IOstream::good
bool good() const noexcept
Definition: IOstream.H:229
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Definition: boundaryPatch.C:76
Foam::surfZoneIOList::writeData
bool writeData(Ostream &os) const
Definition: surfZoneIOList.C:107
Foam::surfZoneIOList
IOobject for a surfZoneList.
Definition: surfZoneIOList.H:49
Foam::surfZoneIOList::operator=
void operator=(const surfZoneIOList &rhs)
Definition: surfZoneIOList.C:134
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::defineTypeName
defineTypeName(ensightPart)
Foam::PtrList< entry >
Foam::List::operator=
void operator=(const UList< T > &a)
Foam::surfZoneIOList::surfZoneIOList
surfZoneIOList(const IOobject &io)
Definition: surfZoneIOList.C:35
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::IOstream::check
virtual bool check(const char *operation) const
Definition: IOstream.C:51
Foam::FatalError
error FatalError
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Definition: atmBoundaryLayer.C:26
Foam::decrIndent
Ostream & decrIndent(Ostream &os)
Definition: Ostream.H:361
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
Foam::IOobject::readOpt
readOption readOpt() const noexcept
Definition: IOobjectI.H:157
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:69
FatalErrorInFunction
#define FatalErrorInFunction
Definition: error.H:465
Foam::nl
constexpr char nl
Definition: Ostream.H:424
surfZoneIOList.H
Foam::regIOobject::close
void close()
Definition: regIOobjectRead.C:164
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
Foam::surfZone
A surface zone on a MeshedSurface.
Definition: surfZone.H:52
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:99
Foam::IOobject::MUST_READ_IF_MODIFIED
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:182
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:302
Foam::surfZoneList
List< surfZone > surfZoneList
Definition: surfZoneList.H:41
Foam::token::END_LIST
@ END_LIST
End list [isseparator].
Definition: token.H:152
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::IOobject::objectPath
fileName objectPath() const
Definition: IOobjectI.H:207
Foam::token::BEGIN_LIST
@ BEGIN_LIST
Begin list [isseparator].
Definition: token.H:151
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:181