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

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