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

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