FreeFOAM The Cross-Platform CFD Toolkit
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 | 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 
26 #include "surfZoneIOList.H"
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
31 
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 Foam::surfZoneIOList::surfZoneIOList
36 (
37  const IOobject& io
38 )
39 :
40  surfZoneList(),
41  regIOobject(io)
42 {
43  Foam::string functionName =
44  "surfZoneIOList::surfZoneIOList"
45  "(const IOobject& io)";
46 
47 
48  if (readOpt() == IOobject::MUST_READ)
49  {
50  surfZoneList& zones = *this;
51 
52  Istream& is = readStream(typeName);
53 
54  PtrList<entry> dictEntries(is);
55  zones.setSize(dictEntries.size());
56 
57  label faceI = 0;
58  forAll(zones, zoneI)
59  {
60  const dictionary& dict = dictEntries[zoneI].dict();
61 
62  label zoneSize = readLabel(dict.lookup("nFaces"));
63  label startFaceI = readLabel(dict.lookup("startFace"));
64 
65  zones[zoneI] = surfZone
66  (
67  dictEntries[zoneI].keyword(),
68  zoneSize,
69  startFaceI,
70  zoneI
71  );
72 
73  word geoType;
74  if (dict.readIfPresent("geometricType", geoType))
75  {
76  zones[zoneI].geometricType() = geoType;
77  }
78 
79  if (startFaceI != faceI)
80  {
81  FatalErrorIn(functionName)
82  << "surfZones are not ordered. Start of zone " << zoneI
83  << " does not correspond to sum of preceding zones." << nl
84  << "while reading " << io.objectPath() << endl
85  << exit(FatalError);
86  }
87 
88  faceI += zoneSize;
89  }
90 
91  // Check state of IOstream
92  is.check(functionName.c_str());
93 
94  close();
95  }
96 }
97 
98 
99 Foam::surfZoneIOList::surfZoneIOList
100 (
101  const IOobject& io,
102  const surfZoneList& zones
103 )
104 :
105  surfZoneList(zones),
106  regIOobject(io)
107 {}
108 
109 
110 Foam::surfZoneIOList::surfZoneIOList
111 (
112  const IOobject& io,
113  const Xfer<surfZoneList>& zones
114 )
115 :
116  surfZoneList(zones),
117  regIOobject(io)
118 {}
119 
120 
121 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
122 
124 {}
125 
126 
127 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
128 
129 
130 // writeData member function required by regIOobject
132 {
133  os << *this;
134  return os.good();
135 }
136 
137 
138 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
139 
141 {
142  os << L.size() << nl << token::BEGIN_LIST << incrIndent << nl;
143 
144  forAll(L, i)
145  {
146  L[i].writeDict(os);
147  }
148 
149  os << decrIndent << token::END_LIST;
150 
151  return os;
152 }
153 
154 
155 // ************************ vim: set sw=4 sts=4 et: ************************ //