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 "ensightParticlePositions.H"
00027 #include <finiteVolume/fvMesh.H>
00028 #include <lagrangian/passiveParticle.H>
00029 #include <lagrangian/Cloud.H>
00030 #include <OpenFOAM/OFstream.H>
00031 #include <OpenFOAM/IOmanip.H>
00032 #include "itoa.H"
00033
00034 using namespace Foam;
00035
00036
00037
00038 void ensightParticlePositions
00039 (
00040 const Foam::fvMesh& mesh,
00041 const Foam::fileName& postProcPath,
00042 const Foam::word& timeFile,
00043 const Foam::word& cloudName,
00044 const bool dataExists
00045 )
00046 {
00047 if (dataExists)
00048 {
00049 Info<< "Converting cloud " << cloudName << " positions" << endl;
00050 }
00051 else
00052 {
00053 Info<< "Creating empty cloud " << cloudName << " positions" << endl;
00054 }
00055
00056 const Time& runTime = mesh.time();
00057
00058 fileName ensightFileName(timeFile + "." + cloudName);
00059 OFstream ensightFile
00060 (
00061 postProcPath/ensightFileName,
00062 runTime.writeFormat(),
00063 runTime.writeVersion(),
00064 runTime.writeCompression()
00065 );
00066
00067
00068 ensightFile
00069 << cloudName.c_str() << nl
00070 << "particle coordinates" << nl;
00071
00072 if (dataExists)
00073 {
00074 Cloud<passiveParticle> parcels(mesh, cloudName, false);
00075
00076
00077 ensightFile.setf(ios_base::scientific, ios_base::floatfield);
00078 ensightFile.precision(5);
00079
00080 ensightFile<< setw(8) << parcels.size() << nl;
00081
00082 label nParcels = 0;
00083
00084
00085 forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
00086 {
00087 const vector& p = elmnt().position();
00088
00089 ensightFile
00090 << setw(8) << ++nParcels
00091 << setw(12) << p.x() << setw(12) << p.y() << setw(12) << p.z()
00092 << nl;
00093 }
00094 }
00095 else
00096 {
00097 label nParcels = 0;
00098 ensightFile<< setw(8) << nParcels << nl;
00099 }
00100 }
00101
00102
00103