MeshedSurfaceIO.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011 OpenFOAM Foundation
9 Copyright (C) 2016-2018 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "MeshedSurface.H"
30#include "boundBox.H"
31#include "faceTraits.H"
32#include "Istream.H"
33#include "Ostream.H"
34
35// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36
37template<class Face>
39{
40 is >> this->storedZones()
41 >> this->storedPoints()
42 >> this->storedFaces();
43
44 is.check(FUNCTION_NAME);
45 return is;
46}
47
48
49template<class Face>
51{
52 os << this->surfZones()
53 << this->points()
54 << this->surfFaces();
55
56 os.check(FUNCTION_NAME);
57 return os;
58}
59
60
61template<class Face>
63{
64 os << "points : " << this->points().size() << nl;
66 {
67 os << "triangles : " << this->size() << nl;
68 }
69 else
70 {
71 label nTri = 0, nQuad = 0;
72 for (const Face& f : *this)
73 {
74 const label n = f.size();
75
76 if (n == 3)
77 {
78 ++nTri;
79 }
80 else if (n == 4)
81 {
82 ++nQuad;
83 }
84 }
85
86 os << "faces : " << this->size()
87 << " (tri:" << nTri << " quad:" << nQuad
88 << " poly:" << (this->size() - nTri - nQuad) << ")" << nl;
89 }
90
91 os << "boundingBox : " << boundBox(this->points()) << endl;
92}
93
94
95// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
96
97template<class Face>
99{
100 return surf.read(is);
101}
102
103
104template<class Face>
105Foam::Ostream& Foam::operator<<(Ostream& os, const MeshedSurface<Face>& surf)
106{
107 return surf.write(os);
108}
109
110
111// ************************************************************************* //
label n
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: MeshedSurface.H:99
void writeStats(Ostream &os) const
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
virtual bool read()
Re-read model coefficients if they have changed.
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:64
Traits class for faces.
Definition: faceTraits.H:51
virtual bool write()
Write the output fields.
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
#define FUNCTION_NAME
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
Istream & operator>>(Istream &, directionInfo &)
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
labelList f(nPoints)