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

surfacePatchIOList.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 <triSurface/surfacePatchIOList.H>
00027 
00028 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00029 
00030 defineTypeNameAndDebug(Foam::surfacePatchIOList, 0);
00031 
00032 
00033 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00034 
00035 // Construct from IOObject
00036 Foam::surfacePatchIOList::surfacePatchIOList
00037 (
00038     const IOobject& io
00039 )
00040 :
00041     surfacePatchList(),
00042     regIOobject(io)
00043 {
00044     Foam::string functionName =
00045         "surfacePatchIOList::surfacePatchIOList"
00046         "(const IOobject& io)";
00047 
00048 
00049     if (readOpt() == IOobject::MUST_READ)
00050     {
00051         surfacePatchList& patches = *this;
00052 
00053         // read polyPatchList
00054         Istream& is = readStream(typeName);
00055 
00056         PtrList<entry> patchEntries(is);
00057         patches.setSize(patchEntries.size());
00058 
00059         label faceI = 0;
00060 
00061         forAll(patches, patchI)
00062         {
00063             const dictionary& dict = patchEntries[patchI].dict();
00064 
00065             label patchSize = readLabel(dict.lookup("nFaces"));
00066             label startFaceI = readLabel(dict.lookup("startFace"));
00067 
00068             patches[patchI] = 
00069                 surfacePatch
00070                 (
00071                     word(dict.lookup("geometricType")),
00072                     patchEntries[patchI].keyword(),
00073                     patchSize,
00074                     startFaceI,
00075                     patchI
00076                 );
00077 
00078 
00079             if (startFaceI != faceI)
00080             {
00081                 FatalErrorIn(functionName)
00082                     << "Patches are not ordered. Start of patch " << patchI
00083                     << " does not correspond to sum of preceding patches."
00084                     << endl
00085                     << "while reading " << io.objectPath()
00086                     << exit(FatalError);
00087             }
00088 
00089             faceI += patchSize;
00090         }
00091 
00092         // Check state of IOstream
00093         is.check(functionName.c_str());
00094 
00095         close();
00096     }
00097 }
00098 
00099 // Construct from IOObject
00100 Foam::surfacePatchIOList::surfacePatchIOList
00101 (
00102     const IOobject& io,
00103     const surfacePatchList& patches    
00104 )
00105 :
00106     surfacePatchList(patches),
00107     regIOobject(io)
00108 {}
00109 
00110 
00111 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00112 
00113 Foam::surfacePatchIOList::~surfacePatchIOList()
00114 {}
00115 
00116 
00117 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00118 
00119 
00120 // writeData member function required by regIOobject
00121 bool Foam::surfacePatchIOList::writeData(Ostream& os) const
00122 {
00123     os << *this;
00124     return os.good();
00125 }
00126 
00127 
00128 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00129 
00130 Foam::Ostream& Foam::operator<<(Ostream& os, const surfacePatchIOList& patches)
00131 {
00132     os  << patches.size() << nl << token::BEGIN_LIST;
00133 
00134     forAll(patches, patchI)
00135     {
00136         patches[patchI].writeDict(os);
00137     }
00138 
00139     os  << token::END_LIST;
00140 
00141     return os;
00142 }
00143 
00144 
00145 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00146 
00147 
00148 // * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
00149 
00150 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines