OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

surfZoneIOList.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "surfZoneIOList.H"
00028 
00029 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00030 
00031 defineTypeNameAndDebug(Foam::surfZoneIOList, 0);
00032 
00033 
00034 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00035 
00036 Foam::surfZoneIOList::surfZoneIOList
00037 (
00038     const IOobject& io
00039 )
00040 :
00041     surfZoneList(),
00042     regIOobject(io)
00043 {
00044     Foam::string functionName =
00045         "surfZoneIOList::surfZoneIOList"
00046         "(const IOobject& io)";
00047 
00048 
00049     if (readOpt() == IOobject::MUST_READ)
00050     {
00051         surfZoneList& zones = *this;
00052 
00053         Istream& is = readStream(typeName);
00054 
00055         PtrList<entry> dictEntries(is);
00056         zones.setSize(dictEntries.size());
00057 
00058         label faceI = 0;
00059         forAll(zones, zoneI)
00060         {
00061             const dictionary& dict = dictEntries[zoneI].dict();
00062 
00063             label zoneSize = readLabel(dict.lookup("nFaces"));
00064             label startFaceI = readLabel(dict.lookup("startFace"));
00065 
00066             zones[zoneI] = surfZone
00067             (
00068                 dictEntries[zoneI].keyword(),
00069                 zoneSize,
00070                 startFaceI,
00071                 zoneI
00072             );
00073 
00074             word geoType;
00075             if (dict.readIfPresent("geometricType", geoType))
00076             {
00077                 zones[zoneI].geometricType() = geoType;
00078             }
00079 
00080             if (startFaceI != faceI)
00081             {
00082                 FatalErrorIn(functionName)
00083                     << "surfZones are not ordered. Start of zone " << zoneI
00084                     << " does not correspond to sum of preceding zones." << nl
00085                     << "while reading " << io.objectPath() << endl
00086                     << exit(FatalError);
00087             }
00088 
00089             faceI += zoneSize;
00090         }
00091 
00092         // Check state of IOstream
00093         is.check(functionName.c_str());
00094 
00095         close();
00096     }
00097 }
00098 
00099 
00100 Foam::surfZoneIOList::surfZoneIOList
00101 (
00102     const IOobject& io,
00103     const surfZoneList& zones
00104 )
00105 :
00106     surfZoneList(zones),
00107     regIOobject(io)
00108 {}
00109 
00110 
00111 Foam::surfZoneIOList::surfZoneIOList
00112 (
00113     const IOobject& io,
00114     const Xfer<surfZoneList>& zones
00115 )
00116 :
00117     surfZoneList(zones),
00118     regIOobject(io)
00119 {}
00120 
00121 
00122 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00123 
00124 Foam::surfZoneIOList::~surfZoneIOList()
00125 {}
00126 
00127 
00128 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00129 
00130 
00131 // writeData member function required by regIOobject
00132 bool Foam::surfZoneIOList::writeData(Ostream& os) const
00133 {
00134     os  << *this;
00135     return os.good();
00136 }
00137 
00138 
00139 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00140 
00141 Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIOList& L)
00142 {
00143     os  << L.size() << nl << token::BEGIN_LIST << incrIndent << nl;
00144 
00145     forAll(L, i)
00146     {
00147         L[i].writeDict(os);
00148     }
00149 
00150     os  << decrIndent << token::END_LIST;
00151 
00152     return os;
00153 }
00154 
00155 
00156 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd