initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / triSurface / triSurface / surfacePatch / surfacePatch.C
blob2ebe9ee2156cf814f490d54f3df13b0c4a7822e7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Description
27 \*---------------------------------------------------------------------------*/
29 #include "surfacePatch.H"
30 #include "dictionary.H"
31 #include "word.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(Foam::surfacePatch, 0);
39 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
41 // Construct null
42 Foam::surfacePatch::surfacePatch()
44     geometricSurfacePatch("", "", -1),
45     size_(0),
46     start_(0)
51 // Construct from components
52 Foam::surfacePatch::surfacePatch
54     const word& geometricType,
55     const word& name,
56     const label size,
57     const label start,
58     const label index
61     geometricSurfacePatch(geometricType, name, index),
62     size_(size),
63     start_(start)
67 // Construct from Istream
68 Foam::surfacePatch::surfacePatch(Istream& is, const label index)
70     geometricSurfacePatch(is, index),
71     size_(0),
72     start_(0)
74     size_ = readLabel(is);
75     start_ = readLabel(is);
78 // Construct from dictionary
79 Foam::surfacePatch::surfacePatch
81     const word& name,
82     const dictionary& dict,
83     const label index
86     geometricSurfacePatch(name, dict, index),
87     size_(readLabel(dict.lookup("nFaces"))),
88     start_(readLabel(dict.lookup("startFace")))
92 // Construct as copy
93 Foam::surfacePatch::surfacePatch(const Foam::surfacePatch& sp)
95     geometricSurfacePatch(sp),
96     size_(sp.size()),
97     start_(sp.start())
101 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
103 void Foam::surfacePatch::write(Ostream& os) const
105     os  << nl
106         << static_cast<const geometricSurfacePatch&>(*this) << endl
107         << size() << tab << start();
110 void Foam::surfacePatch::writeDict(Ostream& os) const
112     os  << nl << name() << nl << token::BEGIN_BLOCK << nl;
114     geometricSurfacePatch::writeDict(os);
116     os  << "    nFaces " << size() << ';' << nl
117         << "    startFace " << start() << ';' << nl
118         << token::END_BLOCK << endl;
122 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
124 bool Foam::surfacePatch::operator!=(const surfacePatch& p) const
126     return !(*this == p);
130 bool Foam::surfacePatch::operator==(const surfacePatch& p) const
132     return
133     (
134         (geometricType() == p.geometricType())
135      && (size() == p.size())
136      && (start() == p.start())
137     );
141 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
143 Foam::Ostream& Foam::operator<<(Ostream& os, const surfacePatch& p)
145     p.write(os);
146     os.check("Ostream& operator<<(Ostream& f, const surfacePatch& p");
147     return os;
151 // ************************************************************************* //