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-------------------------------------------------------------------------------
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 "surfZoneIOList.H"
30
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33namespace Foam
34{
36}
37
38
39// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40
42(
43 const IOobject& io
44)
45:
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:
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
150{
151 zones.writeData(os);
152
153 return os;
154}
155
156
157// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
readOption readOpt() const noexcept
The read option.
Definition: IOobjectI.H:164
fileName objectPath() const
The complete path + object name.
Definition: IOobjectI.H:214
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:180
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
bool good() const noexcept
True if next operation might succeed.
Definition: IOstream.H:233
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
void operator=(const UList< surfZone > &a)
Assignment to UList operator. Takes linear time.
Definition: List.C:480
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:106
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
void close()
Close Istream.
Istream & readStream(const word &, const bool valid=true)
Return Istream and check object type against that given.
IOobject for a surfZoneList.
void operator=(const surfZoneIOList &rhs)
Copy assignment of entries.
bool writeData(Ostream &os) const
The writeData function - required by regIOobject.
A surface zone on a MeshedSurface.
Definition: surfZone.H:59
@ BEGIN_LIST
Begin list [isseparator].
Definition: token.H:155
@ END_LIST
End list [isseparator].
Definition: token.H:156
#define defineTypeName(Type)
Define the typeName.
Definition: className.H:96
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define FUNCTION_NAME
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:349
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:356
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333