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 #include "ensightOutputFunctions.H"
00027
00028 #include <lagrangian/passiveParticle.H>
00029 #include <OpenFOAM/IOField.H>
00030 #include <finiteVolume/volFields.H>
00031 #include <finiteVolume/surfaceFields.H>
00032
00033 #include <OpenFOAM/OFstream.H>
00034 #include <OpenFOAM/IOmanip.H>
00035
00036 namespace Foam
00037 {
00038
00039
00040
00041 void ensightCaseEntry
00042 (
00043 OFstream& caseFile,
00044 const string& ensightType,
00045 const word& fieldName,
00046 const fileName& dataMask,
00047 const fileName& local,
00048 const label cloudNo,
00049 const label timeSet
00050 )
00051 {
00052 caseFile.setf(ios_base::left);
00053
00054 fileName dirName(dataMask);
00055 if (local.size())
00056 {
00057 dirName = dirName/local;
00058 }
00059
00060 if (cloudNo >= 0)
00061 {
00062 label ts = 1;
00063 if (timeSet > ts)
00064 {
00065 ts = timeSet;
00066 }
00067
00068
00069 caseFile
00070 << ensightType.c_str()
00071 << " per measured node: " << ts << " "
00072 << setw(15)
00073 << ("c" + Foam::name(cloudNo) + fieldName).c_str()
00074 << " "
00075 << (dirName/fieldName).c_str()
00076 << nl;
00077 }
00078 else
00079 {
00080 caseFile
00081 << ensightType.c_str()
00082 << " per element: "
00083 << setw(15) << fieldName
00084 << " "
00085 << (dirName/fieldName).c_str()
00086 << nl;
00087 }
00088 }
00089
00090
00091 void ensightParticlePositions
00092 (
00093 const polyMesh& mesh,
00094 const fileName& dataDir,
00095 const fileName& subDir,
00096 const word& cloudName,
00097 IOstream::streamFormat format
00098 )
00099 {
00100 Cloud<passiveParticle> parcels(mesh, cloudName, false);
00101
00102 fileName cloudDir = subDir/cloud::prefix/cloudName;
00103 fileName postFileName = cloudDir/"positions";
00104
00105
00106 mkDir(dataDir/cloudDir);
00107 ensightFile os(dataDir/postFileName, format);
00108
00109
00110 os.writeBinaryHeader();
00111 os.write(postFileName);
00112 os.newline();
00113 os.write("particle coordinates");
00114 os.newline();
00115 os.write(parcels.size(), 8);
00116 os.newline();
00117
00118
00119 if (format == IOstream::BINARY)
00120 {
00121 forAll (parcels, i)
00122 {
00123 os.write(i+1);
00124 }
00125
00126 forAllIter(Cloud<passiveParticle>, parcels, elmnt)
00127 {
00128 const vector& p = elmnt().position();
00129
00130 os.write(p.x());
00131 os.write(p.y());
00132 os.write(p.z());
00133 }
00134 }
00135 else
00136 {
00137 label nParcels = 0;
00138
00139 forAllIter(Cloud<passiveParticle>, parcels, elmnt)
00140 {
00141 const vector& p = elmnt().position();
00142
00143 os.write(++nParcels, 8);
00144 os.write(p.x());
00145 os.write(p.y());
00146 os.write(p.z());
00147 os.newline();
00148 }
00149 }
00150 }
00151
00152
00153
00154 template<class Type>
00155 void ensightLagrangianField
00156 (
00157 const IOobject& fieldObject,
00158 const fileName& dataDir,
00159 const fileName& subDir,
00160 const word& cloudName,
00161 IOstream::streamFormat format
00162 )
00163 {
00164 Info<< " " << fieldObject.name() << flush;
00165
00166 fileName cloudDir = subDir/cloud::prefix/cloudName;
00167 fileName postFileName = cloudDir/fieldObject.name();
00168
00169 string title =
00170 postFileName + " with " + pTraits<Type>::typeName + " values";
00171
00172 ensightFile os(dataDir/postFileName, format);
00173 os.write(title);
00174 os.newline();
00175
00176 IOField<Type> field(fieldObject);
00177
00178
00179 label count = 0;
00180
00181 forAll(field, i)
00182 {
00183 Type val = field[i];
00184
00185 if (mag(val) < 1.0e-90)
00186 {
00187 val = pTraits<Type>::zero;
00188 }
00189
00190 for (direction cmpt=0; cmpt < pTraits<Type>::nComponents; cmpt++)
00191 {
00192 os.write( component(val, cmpt) );
00193 }
00194
00195 count += pTraits<Type>::nComponents;
00196
00197 if (count % 6 == 0)
00198 {
00199 os.newline();
00200 }
00201 }
00202
00203
00204 if (count % 6)
00205 {
00206 os.newline();
00207 }
00208 }
00209
00210
00211
00212 template <class Type>
00213 void ensightVolField
00214 (
00215 const ensightParts& partsList,
00216 const IOobject& fieldObject,
00217 const fvMesh& mesh,
00218 const fileName& dataDir,
00219 const fileName& subDir,
00220 IOstream::streamFormat format
00221 )
00222 {
00223 Info<< " " << fieldObject.name() << flush;
00224
00225 fileName postFileName = subDir/fieldObject.name();
00226
00227 ensightFile os(dataDir/postFileName, format);
00228 os.write(postFileName);
00229 os.newline();
00230
00231
00232 partsList.writeField
00233 (
00234 os,
00235 GeometricField<Type, fvPatchField, volMesh>
00236 (
00237 fieldObject,
00238 mesh
00239 )
00240 );
00241 }
00242
00243
00244
00245 }
00246
00247
00248