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

surfZone.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 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "surfZone.H"
00030 #include "dictionary.H"
00031 #include "word.H"
00032 
00033 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00034 
00035 defineTypeNameAndDebug(Foam::surfZone, 0);
00036 
00037 
00038 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00039 
00040 Foam::surfZone::surfZone()
00041 :
00042     surfZoneIdentifier(),
00043     size_(0),
00044     start_(0)
00045 {}
00046 
00047 
00048 Foam::surfZone::surfZone
00049 (
00050     const word& name,
00051     const label size,
00052     const label start,
00053     const label index,
00054     const word& geometricType
00055 )
00056 :
00057     surfZoneIdentifier(name, index, geometricType),
00058     size_(size),
00059     start_(start)
00060 {}
00061 
00062 
00063 Foam::surfZone::surfZone(Istream& is, const label index)
00064 :
00065     surfZoneIdentifier(),
00066     size_(0),
00067     start_(0)
00068 {
00069     word name(is);
00070     dictionary dict(is);
00071 
00072     operator=(surfZone(name, dict, index));
00073 }
00074 
00075 
00076 Foam::surfZone::surfZone
00077 (
00078     const word& name,
00079     const dictionary& dict,
00080     const label index
00081 )
00082 :
00083     surfZoneIdentifier(name, dict, index),
00084     size_(readLabel(dict.lookup("nFaces"))),
00085     start_(readLabel(dict.lookup("startFace")))
00086 {}
00087 
00088 
00089 Foam::surfZone::surfZone(const surfZone& zone)
00090 :
00091     surfZoneIdentifier(zone, zone.index()),
00092     size_(zone.size()),
00093     start_(zone.start())
00094 {}
00095 
00096 
00097 Foam::surfZone::surfZone(const surfZone& zone, const label index)
00098 :
00099     surfZoneIdentifier(zone, index),
00100     size_(zone.size()),
00101     start_(zone.start())
00102 {}
00103 
00104 
00105 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00106 
00107 void Foam::surfZone::write(Ostream& os) const
00108 {
00109     writeDict(os);
00110 }
00111 
00112 
00113 void Foam::surfZone::writeDict(Ostream& os) const
00114 {
00115     os  << indent << name() << nl
00116         << indent << token::BEGIN_BLOCK << incrIndent << nl;
00117 
00118     surfZoneIdentifier::write(os);
00119     os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
00120     os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
00121 
00122     os  << decrIndent << indent << token::END_BLOCK << endl;
00123 }
00124 
00125 
00126 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00127 
00128 bool Foam::surfZone::operator!=(const surfZone& rhs) const
00129 {
00130     return !(*this == rhs);
00131 }
00132 
00133 
00134 bool Foam::surfZone::operator==(const surfZone& rhs) const
00135 {
00136     return
00137     (
00138         size() == rhs.size()
00139      && start() == rhs.start()
00140      && geometricType() == rhs.geometricType()
00141     );
00142 }
00143 
00144 
00145 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00146 
00147 Foam::Istream& Foam::operator>>(Istream& is, surfZone& zone)
00148 {
00149     zone = surfZone(is, 0);
00150 
00151     is.check("Istream& operator>>(Istream&, surfZone&)");
00152     return is;
00153 }
00154 
00155 
00156 Foam::Ostream& Foam::operator<<(Ostream& os, const surfZone& zone)
00157 {
00158     zone.write(os);
00159     os.check("Ostream& operator<<(Ostream&, const surfZone&");
00160     return os;
00161 }
00162 
00163 
00164 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd