1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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
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/>.
27 \*---------------------------------------------------------------------------*/
29 #include "cellShape.H"
31 #include "cellModeller.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 Istream& operator>>(Istream& is, cellShape& s)
42 bool readEndBracket = false;
44 // Read the 'name' token for the symbol
47 if (t.isPunctuation())
49 if (t.pToken() == token::BEGIN_LIST)
51 readEndBracket = true;
57 FatalIOErrorIn("operator>>(Istream&, cellShape& s)", is)
58 << "incorrect first token, expected '(', found "
60 << exit(FatalIOError);
64 // it is allowed to have either a word or a number describing the model
67 s.m = cellModeller::lookup(int(t.labelToken()));
71 s.m = cellModeller::lookup(t.wordToken());
75 FatalIOErrorIn("operator>>(Istream& is, cellShape& s)", is)
76 << "Bad type of token for cellShape symbol " << t.info()
77 << exit(FatalIOError);
81 // Check that a model was found
84 FatalIOErrorIn("operator>>(Istream& is, cellShape& s)", is)
85 << "CellShape has unknown model " << t.info()
86 << exit(FatalIOError);
90 // Read the geometry labels
91 is >> static_cast<labelList&>(s);
96 is.readEnd("cellShape");
103 Ostream& operator<<(Ostream& os, const cellShape & s)
105 // Write beginning of record
106 os << token::BEGIN_LIST;
108 // Write the list label for the symbol (ONE OR THE OTHER !!!)
109 os << (s.m)->index() << token::SPACE;
111 // Write the model name instead of the label (ONE OR THE OTHER !!!)
112 // os << (s.m)->name() << token::SPACE;
114 // Write the geometry
115 os << static_cast<const labelList&>(s);
118 os << token::END_LIST;
124 #if defined (__GNUC__)
127 Ostream& operator<<(Ostream& os, const InfoProxy<cellShape>& ip)
129 const cellShape& cs = ip.t_;
133 os << " cellShape has no model!\n";
137 os << cs.model().info() << endl;
140 os << "\tGeom:\tpoint\tlabel\txyz\n";
144 os << "\t\t" << i << "\t" << cs[i] << endl;
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 } // End namespace Foam
155 // ************************************************************************* //