surfacePatchIOList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | foam-extend: Open Source CFD
4  \\ / O peration | Version: 3.2
5  \\ / A nd | Web: http://www.foam-extend.org
6  \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9  This file is part of foam-extend.
10 
11  foam-extend is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation, either version 3 of the License, or (at your
14  option) any later version.
15 
16  foam-extend is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "surfacePatchIOList.H"
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
31 
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 // Construct from IOObject
37 (
38  const IOobject& io
39 )
40 :
42  regIOobject(io)
43 {
44  Foam::string functionName =
45  "surfacePatchIOList::surfacePatchIOList"
46  "(const IOobject& io)";
47 
48 
49  if (readOpt() == IOobject::MUST_READ)
50  {
51  surfacePatchList& patches = *this;
52 
53  // read polyPatchList
54  Istream& is = readStream(typeName);
55 
56  PtrList<entry> patchEntries(is);
57  patches.setSize(patchEntries.size());
58 
59  label faceI = 0;
60 
61  forAll(patches, patchI)
62  {
63  const dictionary& dict = patchEntries[patchI].dict();
64 
65  label patchSize = readLabel(dict.lookup("nFaces"));
66  label startFaceI = readLabel(dict.lookup("startFace"));
67 
68  patches[patchI] =
70  (
71  word(dict.lookup("geometricType")),
72  patchEntries[patchI].keyword(),
73  patchSize,
74  startFaceI,
75  patchI
76  );
77 
78 
79  if (startFaceI != faceI)
80  {
81  FatalErrorIn(functionName)
82  << "Patches are not ordered. Start of patch " << patchI
83  << " does not correspond to sum of preceding patches."
84  << endl
85  << "while reading " << io.objectPath()
86  << exit(FatalError);
87  }
88 
89  faceI += patchSize;
90  }
91 
92  // Check state of IOstream
93  is.check(functionName.c_str());
94 
95  close();
96  }
97 }
98 
99 // Construct from IOObject
101 (
102  const IOobject& io,
104 )
105 :
107  regIOobject(io)
108 {}
109 
110 
111 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
112 
114 {}
115 
116 
117 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
118 
119 
120 // writeData member function required by regIOobject
122 {
123  os << *this;
124  return os.good();
125 }
126 
127 
128 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
129 
131 {
132  os << patches.size() << nl << token::BEGIN_LIST;
133 
134  forAll(patches, patchI)
135  {
136  patches[patchI].writeDict(os);
137  }
138 
139  os << token::END_LIST;
140 
141  return os;
142 }
143 
144 
145 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
146 
147 
148 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
149 
150 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::string
A class for handling character strings derived from std::string.
Definition: string.H:74
Foam::IOobject::objectPath
fileName objectPath() const
Return complete path + object name.
Definition: IOobject.H:376
Foam::surfacePatchIOList::writeData
bool writeData(Ostream &) const
writeData member function required by regIOobject
Definition: surfacePatchIOList.C:121
Foam::label
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
Foam::surfacePatchIOList::~surfacePatchIOList
~surfacePatchIOList()
Definition: surfacePatchIOList.C:113
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::PtrList< entry >
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
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:92
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::surfacePatch
'Patch' on surface as subset of triSurface.
Definition: surfacePatch.H:51
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
defineTypeNameAndDebug
defineTypeNameAndDebug(Foam::surfacePatchIOList, 0)
Foam::token::BEGIN_LIST
@ BEGIN_LIST
Definition: token.H:100
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::PtrList::size
label size() const
Return the number of elements in the PtrList.
Definition: PtrListI.H:32
Foam::surfacePatchIOList::surfacePatchIOList
surfacePatchIOList(const surfacePatchIOList &)
Disallow default bitwise copy construct.
Foam::readLabel
label readLabel(Istream &is)
Definition: label.H:64
Foam::surfacePatchIOList
IOobject for a surfacePatchList.
Definition: surfacePatchIOList.H:53
patches
patches[0]
Definition: createSingleCellMesh.H:36
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::IOstream::good
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
Foam::surfacePatchList
List< surfacePatch > surfacePatchList
Definition: surfacePatchList.H:44
Foam::token::END_LIST
@ END_LIST
Definition: token.H:101
surfacePatchIOList.H