Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
meshes
meshShapes
cellShape
cellShapeIO.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 | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
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
13
the Free Software Foundation, either version 3 of the License, or
14
(at your option) any later version.
15
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.
20
21
You should have received a copy of the GNU General Public License
22
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23
24
Description
25
Reads a cellShape
26
27
\*---------------------------------------------------------------------------*/
28
29
#include "
cellShape.H
"
30
#include <
OpenFOAM/token.H
>
31
#include <
OpenFOAM/cellModeller.H
>
32
33
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34
35
namespace
Foam
36
{
37
38
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39
40
Istream
&
operator>>
(
Istream
& is,
cellShape
& s)
41
{
42
bool
readEndBracket =
false
;
43
44
// Read the 'name' token for the symbol
45
token
t(is);
46
47
if
(t.
isPunctuation
())
48
{
49
if
(t.
pToken
() ==
token::BEGIN_LIST
)
50
{
51
readEndBracket =
true
;
52
53
is >> t;
54
}
55
else
56
{
57
FatalIOErrorIn
(
"operator>>(Istream&, cellShape& s)"
, is)
58
<<
"incorrect first token, expected '(', found "
59
<< t.
info
()
60
<<
exit
(
FatalIOError
);
61
}
62
}
63
64
// it is allowed to have either a word or a number describing the model
65
if
(t.
isLabel
())
66
{
67
s.m =
cellModeller::lookup
(
int
(t.
labelToken
()));
68
}
69
else
if
(t.
isWord
())
70
{
71
s.m =
cellModeller::lookup
(t.
wordToken
());
72
}
73
else
74
{
75
FatalIOErrorIn
(
"operator>>(Istream& is, cellShape& s)"
, is)
76
<<
"Bad type of token for cellShape symbol "
<< t.
info
()
77
<<
exit
(
FatalIOError
);
78
return
is;
79
}
80
81
// Check that a model was found
82
if
(!s.m)
83
{
84
FatalIOErrorIn
(
"operator>>(Istream& is, cellShape& s)"
, is)
85
<<
"CellShape has unknown model "
<< t.
info
()
86
<<
exit
(
FatalIOError
);
87
return
is;
88
}
89
90
// Read the geometry labels
91
is >>
static_cast<
labelList
&
>
(s);
92
93
if
(readEndBracket)
94
{
95
// Read end)
96
is.
readEnd
(
"cellShape"
);
97
}
98
99
return
is;
100
}
101
102
103
Ostream
&
operator<<
(
Ostream
& os,
const
cellShape
& s)
104
{
105
// Write beginning of record
106
os <<
token::BEGIN_LIST
;
107
108
// Write the list label for the symbol (ONE OR THE OTHER !!!)
109
os << (s.m)->index() <<
token::SPACE
;
110
111
// Write the model name instead of the label (ONE OR THE OTHER !!!)
112
// os << (s.m)->name() << token::SPACE;
113
114
// Write the geometry
115
os << static_cast<const labelList&>(s);
116
117
// End of record
118
os <<
token::END_LIST
;
119
120
return
os;
121
}
122
123
124
#if defined (__GNUC__)
125
template
<>
126
#endif
127
Ostream
& operator<<(Ostream& os, const InfoProxy<cellShape>& ip)
128
{
129
const
cellShape
& cs = ip.t_;
130
131
if
(!(&cs.
model
()))
132
{
133
os <<
" cellShape has no model!\n"
;
134
}
135
else
136
{
137
os << cs.
model
().
info
() <<
endl
;
138
}
139
140
os <<
"\tGeom:\tpoint\tlabel\txyz\n"
;
141
142
forAll
(cs, i)
143
{
144
os <<
"\t\t"
<< i <<
"\t"
<< cs[i] <<
endl
;
145
}
146
147
return
os;
148
}
149
150
151
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152
153
}
// End namespace Foam
154
155
// ************************ vim: set sw=4 sts=4 et: ************************ //