FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "surfZoneIOList.H"
00027 
00028 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00029 
00030 defineTypeNameAndDebug(Foam::surfZoneIOList, 0);
00031 
00032 
00033 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00034 
00035 Foam::surfZoneIOList::surfZoneIOList
00036 (
00037     const IOobject& io
00038 )
00039 :
00040     surfZoneList(),
00041     regIOobject(io)
00042 {
00043     Foam::string functionName =
00044         "surfZoneIOList::surfZoneIOList"
00045         "(const IOobject& io)";
00046 
00047 
00048     if (readOpt() == IOobject::MUST_READ)
00049     {
00050         surfZoneList& zones = *this;
00051 
00052         Istream& is = readStream(typeName);
00053 
00054         PtrList<entry> dictEntries(is);
00055         zones.setSize(dictEntries.size());
00056 
00057         label faceI = 0;
00058         forAll(zones, zoneI)
00059         {
00060             const dictionary& dict = dictEntries[zoneI].dict();
00061 
00062             label zoneSize = readLabel(dict.lookup("nFaces"));
00063             label startFaceI = readLabel(dict.lookup("startFace"));
00064 
00065             zones[zoneI] = surfZone
00066             (
00067                 dictEntries[zoneI].keyword(),
00068                 zoneSize,
00069                 startFaceI,
00070                 zoneI
00071             );
00072 
00073             word geoType;
00074             if (dict.readIfPresent("geometricType", geoType))
00075             {
00076                 zones[zoneI].geometricType() = geoType;
00077             }
00078 
00079             if (startFaceI != faceI)
00080             {
00081                 FatalErrorIn(functionName)
00082                     << "surfZones are not ordered. Start of zone " << zoneI
00083                     << " does not correspond to sum of preceding zones." << nl
00084                     << "while reading " << io.objectPath() << endl
00085                     << exit(FatalError);
00086             }
00087 
00088             faceI += zoneSize;
00089         }
00090 
00091         // Check state of IOstream
00092         is.check(functionName.c_str());
00093 
00094         close();
00095     }
00096 }
00097 
00098 
00099 Foam::surfZoneIOList::surfZoneIOList
00100 (
00101     const IOobject& io,
00102     const surfZoneList& zones
00103 )
00104 :
00105     surfZoneList(zones),
00106     regIOobject(io)
00107 {}
00108 
00109 
00110 Foam::surfZoneIOList::surfZoneIOList
00111 (
00112     const IOobject& io,
00113     const Xfer<surfZoneList>& zones
00114 )
00115 :
00116     surfZoneList(zones),
00117     regIOobject(io)
00118 {}
00119 
00120 
00121 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00122 
00123 Foam::surfZoneIOList::~surfZoneIOList()
00124 {}
00125 
00126 
00127 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00128 
00129 
00130 // writeData member function required by regIOobject
00131 bool Foam::surfZoneIOList::writeData(Ostream& os) const
00132 {
00133     os  << *this;
00134     return os.good();
00135 }
00136 
00137 
00138 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00139 
00140 Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIOList& L)
00141 {
00142     os  << L.size() << nl << token::BEGIN_LIST << incrIndent << nl;
00143 
00144     forAll(L, i)
00145     {
00146         L[i].writeDict(os);
00147     }
00148 
00149     os  << decrIndent << token::END_LIST;
00150 
00151     return os;
00152 }
00153 
00154 
00155 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines