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

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