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

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