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