Loading...
Searching...
No Matches
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-2024 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\*---------------------------------------------------------------------------*/
29#include "surfZoneIOList.H"
30
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33namespace Foam
34{
36}
37
38
39// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40
41bool Foam::surfZoneIOList::readIOcontents()
42{
43 if
44 (
45 this->isReadRequired()
46 )
47 {
48 surfZoneList& zones = *this;
49
50 // Read entries
51 Istream& is = readStream(typeName);
52
53 PtrList<entry> entries(is);
54 zones.resize(entries.size());
55
56 // Transcribe
57 label startOffset = 0;
58 forAll(zones, zonei)
59 {
60 zones[zonei] = surfZone
61 (
62 entries[zonei].keyword(),
63 entries[zonei].dict(),
64 zonei
65 );
66
67 if (zones[zonei].start() != startOffset)
68 {
70 << "surfZones are not ordered. Start of zone " << zonei
71 << " does not correspond to sum of preceding zones." << nl
72 << "while reading " << this->objectRelPath() << endl
73 << exit(FatalError);
74 }
75
76 startOffset += zones[zonei].size();
77 }
78
79 is.check(FUNCTION_NAME);
80 close();
81 return true;
82 }
83
84 // Nothing read
85 return false;
86}
87
88
89// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
90
92(
93 const IOobject& io
94)
95:
98{
99 readIOcontents(); // allowOptionalRead = false
100}
101
102
104(
105 const IOobject& io,
106 const UList<surfZone>& content
108:
110 surfZoneList(content)
111{}
112
113
115(
116 const IOobject& io,
117 surfZoneList&& content
118)
119:
121 surfZoneList(std::move(content))
122{}
123
124
125// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
126
128{
129 const surfZoneList& zones = *this;
130 const label len = zones.size();
131
132 if (len)
133 {
134 os << len << nl << token::BEGIN_LIST << incrIndent << nl;
135
136 for (const surfZone& zn : zones)
137 {
138 zn.write(os);
139 }
140
142 }
143 else
144 {
146 }
148 return os.good();
149}
150
151
152// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
153
157}
158
159
160// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
161
162Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIOList& zones)
163{
164 zones.writeData(os);
165
166 return os;
167}
168
169
170// ************************************************************************* //
bool isReadRequired() const noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
fileName objectRelPath() const
The object path relative to the case.
Definition IOobject.C:581
void operator=(const UList< surfZone > &list)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
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:89
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
void close()
Close Istream.
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
Definition regIOobject.C:43
IOobject for a surfZoneList.
surfZoneIOList(const IOobject &io)
Construct from IOobject.
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:55
@ BEGIN_LIST
Begin list [isseparator].
Definition token.H:174
@ END_LIST
End list [isseparator].
Definition token.H:175
#define defineTypeName(Type)
Define the typeName.
Definition className.H:113
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
OBJstream os(runTime.globalPath()/outputName)
const auto & io
#define FUNCTION_NAME
Namespace for OpenFOAM.
List< surfZone > surfZoneList
List of surfZone.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition Ostream.H:490
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition Ostream.H:499
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299