FreeFOAM The Cross-Platform CFD Toolkit
surfacePatchIOList.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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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 
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
31 
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 // Construct from IOObject
36 Foam::surfacePatchIOList::surfacePatchIOList
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
100 Foam::surfacePatchIOList::surfacePatchIOList
101 (
102  const IOobject& io,
103  const surfacePatchList& patches
104 )
105 :
106  surfacePatchList(patches),
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 // ************************ vim: set sw=4 sts=4 et: ************************ //