1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Output for ensightPart
27 \*---------------------------------------------------------------------------*/
29 #include "ensightPart.H"
30 #include "dictionary.H"
31 #include "IOstreams.H"
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
35 void Foam::ensightPart::writeHeader
44 os.write(number() + 1); // Ensight starts with 1
55 void Foam::ensightPart::writeFieldList
58 const List<scalar>& field,
59 const List<label>& idList
65 if (idList[i] >= field.size() || std::isnan(field[idList[i]]))
67 if (idList[i] >= field.size())
74 os.write(field[idList[i]]);
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
84 bool Foam::ensightPart::writeSummary(Ostream& os) const
86 os << indent << type() << nl
87 << indent << token::BEGIN_BLOCK << incrIndent << nl;
89 // Ensight starts with 1
90 os.writeKeyword("id") << (number() + 1) << token::END_STATEMENT << nl;
91 os.writeKeyword("name") << name() << token::END_STATEMENT << nl;
92 os.writeKeyword("offset") << offset() << token::END_STATEMENT << nl;
93 os.writeKeyword("size") << size() << token::END_STATEMENT << nl;
95 os << decrIndent << indent << token::END_BLOCK << nl << endl;
101 bool Foam::ensightPart::writeData(Ostream& os) const
103 os << indent << type() << nl
104 << indent << token::BEGIN_BLOCK << incrIndent << nl;
106 os.writeKeyword("id") << number() << token::END_STATEMENT << nl;
107 os.writeKeyword("name") << name() << token::END_STATEMENT << nl;
108 os.writeKeyword("offset") << offset() << token::END_STATEMENT << nl;
110 forAll(elementTypes(), typeI)
112 word key(elementTypes()[typeI]);
113 if (elemLists_[typeI].size())
115 elemLists_[typeI].writeEntry(key, os);
119 os << decrIndent << indent << token::END_BLOCK << nl << endl;
125 void Foam::ensightPart::writeGeometry(ensightGeoFile& os) const
127 if (size() && meshPtr_)
129 const polyMesh& mesh = *meshPtr_;
130 const pointField& meshPoints = mesh.points();
132 localPoints ptList = calcLocalPoints();
133 labelList& pointMap = ptList.list;
135 writeHeader(os, true);
138 os.writeKeyword("coordinates");
139 os.write(ptList.nPoints);
142 for (direction cmpt=0; cmpt < vector::nComponents; cmpt++)
144 forAll(pointMap, ptI)
146 if (pointMap[ptI] > -1)
148 os.write( meshPoints[ptI].component(cmpt) );
155 forAll(elementTypes(), elemI)
157 if (elemLists_[elemI].size())
162 elementTypes()[elemI],
172 void Foam::ensightPart::writeScalarField
175 const List<scalar>& field
178 if (size() && field.size() && (os.allowUndef() || isFieldDefined(field)))
182 forAll(elementTypes(), elemI)
184 const labelList& idList = elemLists_[elemI];
188 os.writeKeyword( elementTypes()[elemI] );
189 writeFieldList(os, field, idList);
196 void Foam::ensightPart::writeVectorField
199 const List<scalar>& field0,
200 const List<scalar>& field1,
201 const List<scalar>& field2
204 if (size() && field0.size() && (os.allowUndef() || isFieldDefined(field0)))
208 forAll(elementTypes(), elemI)
210 const labelList& idList = elemLists_[elemI];
214 os.writeKeyword( elementTypes()[elemI] );
215 writeFieldList(os, field0, idList);
216 writeFieldList(os, field1, idList);
217 writeFieldList(os, field2, idList);
224 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
226 Foam::Ostream& Foam::operator<<
229 const ensightPart& part
237 Foam::ensightGeoFile& Foam::operator<<
240 const ensightPart& part
243 part.writeGeometry(os);
248 // ************************************************************************* //