Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "ensightPart.H"
00030 #include <OpenFOAM/dictionary.H>
00031 #include <OpenFOAM/IOstreams.H>
00032
00033
00034
00035 void Foam::ensightPart::writeHeader
00036 (
00037 ensightFile& os,
00038 bool withDescription
00039 ) const
00040 {
00041 os.write("part");
00042 os.newline();
00043
00044 os.write(number() + 1);
00045 os.newline();
00046
00047 if (withDescription)
00048 {
00049 os.write(name());
00050 os.newline();
00051 }
00052 }
00053
00054
00055 void Foam::ensightPart::writeFieldList
00056 (
00057 ensightFile& os,
00058 const List<scalar>& field,
00059 const List<label>& idList
00060 ) const
00061 {
00062 forAll(idList, i)
00063 {
00064 if (idList[i] >= field.size() || std::isnan(field[idList[i]]))
00065 {
00066 os.writeUndef();
00067 }
00068 else
00069 {
00070 os.write(field[idList[i]]);
00071 }
00072
00073 os.newline();
00074 }
00075 }
00076
00077
00078
00079
00080 bool Foam::ensightPart::writeSummary(Ostream& os) const
00081 {
00082 os << indent << type() << nl
00083 << indent << token::BEGIN_BLOCK << incrIndent << nl;
00084
00085
00086 os.writeKeyword("id") << (number() + 1) << token::END_STATEMENT << nl;
00087 os.writeKeyword("name") << name() << token::END_STATEMENT << nl;
00088 os.writeKeyword("offset") << offset() << token::END_STATEMENT << nl;
00089 os.writeKeyword("size") << size() << token::END_STATEMENT << nl;
00090
00091 os << decrIndent << indent << token::END_BLOCK << nl << endl;
00092
00093 return true;
00094 }
00095
00096
00097 bool Foam::ensightPart::writeData(Ostream& os) const
00098 {
00099 os << indent << type() << nl
00100 << indent << token::BEGIN_BLOCK << incrIndent << nl;
00101
00102 os.writeKeyword("id") << number() << token::END_STATEMENT << nl;
00103 os.writeKeyword("name") << name() << token::END_STATEMENT << nl;
00104 os.writeKeyword("offset") << offset() << token::END_STATEMENT << nl;
00105
00106 forAll(elementTypes(), typeI)
00107 {
00108 word key(elementTypes()[typeI]);
00109 if (elemLists_[typeI].size())
00110 {
00111 elemLists_[typeI].writeEntry(key, os);
00112 }
00113 }
00114
00115 os << decrIndent << indent << token::END_BLOCK << nl << endl;
00116
00117 return true;
00118 }
00119
00120
00121 void Foam::ensightPart::writeGeometry(ensightGeoFile& os) const
00122 {
00123 if (size() && meshPtr_)
00124 {
00125 const polyMesh& mesh = *meshPtr_;
00126 const pointField& meshPoints = mesh.points();
00127
00128 localPoints ptList = calcLocalPoints();
00129 labelList& pointMap = ptList.list;
00130
00131 writeHeader(os, true);
00132
00133
00134 os.writeKeyword("coordinates");
00135 os.write(ptList.nPoints);
00136 os.newline();
00137
00138 for (direction cmpt=0; cmpt < vector::nComponents; cmpt++)
00139 {
00140 forAll(pointMap, ptI)
00141 {
00142 if (pointMap[ptI] > -1)
00143 {
00144 os.write( meshPoints[ptI].component(cmpt) );
00145 os.newline();
00146 }
00147 }
00148 }
00149
00150
00151 forAll(elementTypes(), elemI)
00152 {
00153 if (elemLists_[elemI].size())
00154 {
00155 writeConnectivity
00156 (
00157 os,
00158 elementTypes()[elemI],
00159 elemLists_[elemI],
00160 pointMap
00161 );
00162 }
00163 }
00164 }
00165 }
00166
00167
00168 void Foam::ensightPart::writeScalarField
00169 (
00170 ensightFile& os,
00171 const List<scalar>& field
00172 ) const
00173 {
00174 if (size() && field.size() && (os.allowUndef() || isFieldDefined(field)))
00175 {
00176 writeHeader(os);
00177
00178 forAll(elementTypes(), elemI)
00179 {
00180 const labelList& idList = elemLists_[elemI];
00181
00182 if (idList.size())
00183 {
00184 os.writeKeyword( elementTypes()[elemI] );
00185 writeFieldList(os, field, idList);
00186 }
00187 }
00188 }
00189 }
00190
00191
00192 void Foam::ensightPart::writeVectorField
00193 (
00194 ensightFile& os,
00195 const List<scalar>& field0,
00196 const List<scalar>& field1,
00197 const List<scalar>& field2
00198 ) const
00199 {
00200 if (size() && field0.size() && (os.allowUndef() || isFieldDefined(field0)))
00201 {
00202 writeHeader(os);
00203
00204 forAll(elementTypes(), elemI)
00205 {
00206 const labelList& idList = elemLists_[elemI];
00207
00208 if (idList.size())
00209 {
00210 os.writeKeyword( elementTypes()[elemI] );
00211 writeFieldList(os, field0, idList);
00212 writeFieldList(os, field1, idList);
00213 writeFieldList(os, field2, idList);
00214 }
00215 }
00216 }
00217 }
00218
00219
00220
00221
00222 Foam::Ostream& Foam::operator<<
00223 (
00224 Ostream& os,
00225 const ensightPart& part
00226 )
00227 {
00228 part.writeData(os);
00229 return os;
00230 }
00231
00232
00233 Foam::ensightGeoFile& Foam::operator<<
00234 (
00235 ensightGeoFile& os,
00236 const ensightPart& part
00237 )
00238 {
00239 part.writeGeometry(os);
00240 return os;
00241 }
00242
00243
00244